pub struct RingAllReduce { /* private fields */ }Expand description
Bandwidth-optimal ring all-reduce / all-gather driver.
A single RingAllReduce simulates the whole ring in-process: each public
method takes the per-rank inputs, drives all world_size ranks through the
collective using a LocalTransport, and returns each rank’s result (all
ranks end up holding identical data).
Implementations§
Source§impl RingAllReduce
impl RingAllReduce
Sourcepub fn new(world_size: usize) -> Result<Self>
pub fn new(world_size: usize) -> Result<Self>
Create a driver for a ring of world_size workers.
Returns an error when world_size is zero.
Sourcepub fn world_size(&self) -> usize
pub fn world_size(&self) -> usize
Number of workers in the ring.
Sourcepub fn all_reduce_all<A>(
&self,
inputs: &[Array1<A>],
op: ReduceOp,
) -> Result<Vec<Array1<A>>>
pub fn all_reduce_all<A>( &self, inputs: &[Array1<A>], op: ReduceOp, ) -> Result<Vec<Array1<A>>>
Run the full simulated ring all-reduce across every rank at once.
inputs[r] is rank r’s vector; all vectors must be non-empty and share
the same length. The returned vector holds each rank’s result, which are
all identical and equal to the elementwise reduction under op.
Sourcepub fn all_gather<A>(&self, inputs: &[Array1<A>]) -> Result<Vec<Array1<A>>>
pub fn all_gather<A>(&self, inputs: &[Array1<A>]) -> Result<Vec<Array1<A>>>
Run the simulated ring all-gather across every rank at once.
inputs[r] is rank r’s contribution; contributions may differ in length
(this is a gather, not a reduction) but each must be non-empty. The result
holds, for every rank, the concatenation inputs[0] || inputs[1] || ... || inputs[N - 1] in rank order.
Trait Implementations§
Source§impl Clone for RingAllReduce
impl Clone for RingAllReduce
Source§fn clone(&self) -> RingAllReduce
fn clone(&self) -> RingAllReduce
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RingAllReduce
Auto Trait Implementations§
impl Freeze for RingAllReduce
impl RefUnwindSafe for RingAllReduce
impl Send for RingAllReduce
impl Sync for RingAllReduce
impl Unpin for RingAllReduce
impl UnsafeUnpin for RingAllReduce
impl UnwindSafe for RingAllReduce
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.