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>
impl<'a> Relay<'a>
Sourcepub fn has_turn(&self) -> bool
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.
Sourcepub fn tile(&self) -> Tile
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.
Sourcepub fn is_first(&self) -> bool
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.
Sourcepub fn is_last(&self) -> bool
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.
Sourcepub fn take(&self)
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.
Sourcepub fn pass(&self, out: &mut Tile)
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.
Sourcepub fn __expand_has_turn(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <bool as CubeType>::ExpandType
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.
Sourcepub fn __expand_tile(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <Tile as CubeType>::ExpandType
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.
Sourcepub fn __expand_carried(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <Tile as CubeType>::ExpandType
pub fn __expand_carried( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <Tile as CubeType>::ExpandType
Sourcepub fn __expand_is_first(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <bool as CubeType>::ExpandType
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.
Sourcepub fn __expand_is_last(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <bool as CubeType>::ExpandType
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.
Sourcepub fn __expand_take(scope: &Scope, this: &<Self as CubeType>::ExpandType)
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.
Sourcepub fn __expand_pass(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
out: &mut <Tile as CubeType>::ExpandType,
)
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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