Skip to main content

Relay

Struct Relay 

Source
pub struct Relay<'a> { /* private fields */ }
Expand description

One output box, relayed by the cubes a Levels::across split hands it: each contracts its own run, then takes its turn at the box’s carry in the order of the runs. The first turn writes its partial, each after adds its own into what is there a line at a time, and the last hands the sum on to the output. The carry is the TileArg the relay was opened on; the turns are passed on through turns, one counter a cube (Partitioning::relay_counters).

A cube opens its accumulator on the relayed tile, takes its turn with take, drains into the tile, and passes it on with pass, every unit of the cube reaching both. A sum whose partials must be rescaled against one another before they add, as an online softmax’s are, reads and rescales what the turns before it left (carried) in its turn, then drains as any other. The relay publishes a turn’s lines at device scope before passing the box on and acquires them after taking it, so it runs only where the runtime hands one cube’s writes to another within a dispatch (device_memory_scope), and reads its turn with a u32 atomic add, which every GPU runtime offers. A waiting cube holds its place on the device: the relay rests on a box’s earlier runs having started by the time a later one waits, which a grid whose runs are neighbours gives.

Implementations§

Source§

impl<'a> Relay<'a>

Source

pub fn has_turn(&self) -> bool

Whether this cube’s run holds a tile, and so takes a turn: a cube past the last such run holds nothing and never meets the box. Uniform across the cube.

Source

pub fn tile(&self) -> Tile

This cube’s box of the carry, relayed: what its accumulator opens on, starting from the monoid’s identity, and what it drains into once it has taken its turn. The first turn replaces what the box held; every later one adds into it.

Source

pub fn carried(&self) -> Tile

This cube’s box of the carry as the turns before this one left it, to read and to rescale in place once this cube has taken its turn and before it drains. It holds nothing on the first turn, whose drain replaces it.

Source

pub fn is_first(&self) -> bool

Whether this cube takes its box’s first turn, whose drain replaces what the carry held. Uniform across the cube.

Source

pub fn is_last(&self) -> bool

Whether this cube takes its box’s last turn, whose carry pass hands on to the output. Uniform across the cube.

Source

pub fn take(&self)

Wait for this cube’s turn at its box, and acquire what the turns before it wrote. Every unit of the cube reaches it.

The counter is read with fetch_add(0). On Metal, an atomic load spinning on the counter can keep returning the value it first read long after the previous turn’s store has landed, and the cube then never leaves the loop. A plain load serves once the Metal backend’s atomic load reads the counter coherently on every spin.

Source

pub fn pass(&self, out: &mut Tile)

Hand the box on: to the next turn, or, on the last, into out with a cast, once every plane’s lines of the carry are in. Every unit of the cube reaches it.

Source

pub fn __expand_has_turn( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType

Whether this cube’s run holds a tile, and so takes a turn: a cube past the last such run holds nothing and never meets the box. Uniform across the cube.

Source

pub fn __expand_tile( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <Tile as CubeType>::ExpandType

This cube’s box of the carry, relayed: what its accumulator opens on, starting from the monoid’s identity, and what it drains into once it has taken its turn. The first turn replaces what the box held; every later one adds into it.

Source

pub fn __expand_carried( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <Tile as CubeType>::ExpandType

This cube’s box of the carry as the turns before this one left it, to read and to rescale in place once this cube has taken its turn and before it drains. It holds nothing on the first turn, whose drain replaces it.

Source

pub fn __expand_is_first( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType

Whether this cube takes its box’s first turn, whose drain replaces what the carry held. Uniform across the cube.

Source

pub fn __expand_is_last( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <bool as CubeType>::ExpandType

Whether this cube takes its box’s last turn, whose carry pass hands on to the output. Uniform across the cube.

Source

pub fn __expand_take(scope: &Scope, this: &<Self as CubeType>::ExpandType)

Wait for this cube’s turn at its box, and acquire what the turns before it wrote. Every unit of the cube reaches it.

The counter is read with fetch_add(0). On Metal, an atomic load spinning on the counter can keep returning the value it first read long after the previous turn’s store has landed, and the cube then never leaves the loop. A plain load serves once the Metal backend’s atomic load reads the counter coherently on every spin.

Source

pub fn __expand_pass( scope: &Scope, this: &<Self as CubeType>::ExpandType, out: &mut <Tile as CubeType>::ExpandType, )

Hand the box on: to the next turn, or, on the last, into out with a cast, once every plane’s lines of the carry are in. Every unit of the cube reaches it.

Trait Implementations§

Source§

impl<'a> CubeType for Relay<'a>

Source§

type ExpandType = RelayExpand<'a>

Auto Trait Implementations§

§

impl<'a> !Send for Relay<'a>

§

impl<'a> !Sync for Relay<'a>

§

impl<'a> Freeze for Relay<'a>

§

impl<'a> RefUnwindSafe for Relay<'a>

§

impl<'a> Unpin for Relay<'a>

§

impl<'a> UnsafeUnpin for Relay<'a>

§

impl<'a> UnwindSafe for Relay<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more