pub struct DistributedContext { /* private fields */ }Expand description
A handle to the distributed runtime.
Implementations§
Source§impl DistributedContext
impl DistributedContext
Sourcepub fn new(backend: Box<dyn DistributedBackend>) -> Self
pub fn new(backend: Box<dyn DistributedBackend>) -> Self
Create a new distributed context with the given backend.
Sourcepub fn with_metrics(
backend: Box<dyn DistributedBackend>,
metrics: SharedMetrics,
) -> Self
pub fn with_metrics( backend: Box<dyn DistributedBackend>, metrics: SharedMetrics, ) -> Self
Create a new distributed context with metrics enabled.
Sourcepub fn world_size(&self) -> usize
pub fn world_size(&self) -> usize
Get the total number of nodes in the cluster.
Sourcepub async fn all_reduce(&self, buffer: &mut [u8], op: ReduceOp) -> Result<()>
pub async fn all_reduce(&self, buffer: &mut [u8], op: ReduceOp) -> Result<()>
Perform an all-reduce operation on the buffer.
After this call, all nodes will have the same values in their buffers.
op controls whether the result is a sum or mean across nodes.
Sourcepub async fn barrier(&self) -> Result<()>
pub async fn barrier(&self) -> Result<()>
Synchronize all nodes at a barrier.
All nodes must call this method, and none will proceed until all have.
Sourcepub fn metrics_snapshot(&self) -> Option<MetricsSnapshot>
pub fn metrics_snapshot(&self) -> Option<MetricsSnapshot>
Get metrics snapshot if enabled.
Auto Trait Implementations§
impl Freeze for DistributedContext
impl !RefUnwindSafe for DistributedContext
impl Send for DistributedContext
impl Sync for DistributedContext
impl Unpin for DistributedContext
impl UnsafeUnpin for DistributedContext
impl !UnwindSafe for DistributedContext
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
Mutably borrows from an owned value. Read more
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>
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 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>
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