pub struct DistributedOptimizationContext<M: MPIInterface> { /* private fields */ }Expand description
Distributed optimization context
Implementations§
Source§impl<M: MPIInterface> DistributedOptimizationContext<M>
impl<M: MPIInterface> DistributedOptimizationContext<M>
Sourcepub fn new(mpi: M, config: DistributedConfig) -> Self
pub fn new(mpi: M, config: DistributedConfig) -> Self
Create a new distributed optimization context
Sourcepub fn distribute_work(&mut self, total_work: usize) -> WorkAssignment
pub fn distribute_work(&mut self, total_work: usize) -> WorkAssignment
Distribute work among processes
Sourcepub fn synchronize(&self) -> ScirsResult<()>
pub fn synchronize(&self) -> ScirsResult<()>
Synchronize all processes
Sourcepub fn broadcast_parameters(&self, params: &mut Array1<f64>) -> ScirsResult<()>
pub fn broadcast_parameters(&self, params: &mut Array1<f64>) -> ScirsResult<()>
Broadcast parameters from master to all workers
Sourcepub fn gather_results(
&self,
local_result: &Array1<f64>,
) -> ScirsResult<Option<Array2<f64>>>
pub fn gather_results( &self, local_result: &Array1<f64>, ) -> ScirsResult<Option<Array2<f64>>>
Gather results from all workers to master
Sourcepub fn allreduce_sum(
&self,
local_data: &Array1<f64>,
) -> ScirsResult<Array1<f64>>
pub fn allreduce_sum( &self, local_data: &Array1<f64>, ) -> ScirsResult<Array1<f64>>
Perform all-reduce operation (sum)
Sourcepub fn allreduce_min(
&self,
local_data: &Array1<f64>,
) -> ScirsResult<Array1<f64>>
pub fn allreduce_min( &self, local_data: &Array1<f64>, ) -> ScirsResult<Array1<f64>>
Perform all-reduce operation (element-wise minimum)
Sourcepub fn broadcast_from(
&self,
params: &mut Array1<f64>,
root: i32,
) -> ScirsResult<()>
pub fn broadcast_from( &self, params: &mut Array1<f64>, root: i32, ) -> ScirsResult<()>
Broadcast a vector from an arbitrary root rank to all processes
Sourcepub fn select_global_best(
&self,
local_best: &Array1<f64>,
local_value: f64,
) -> ScirsResult<(Array1<f64>, f64)>
pub fn select_global_best( &self, local_best: &Array1<f64>, local_value: f64, ) -> ScirsResult<(Array1<f64>, f64)>
Select the globally-best candidate across the whole communicator.
Given each process’s local best point and its objective value, returns
the best (point, value) pair over all processes. The global-best value
is obtained with a Min all-reduce; the owning rank (lowest rank on
ties) is identified by a second Min all-reduce over rank indices, and
its point is broadcast so every process agrees on the winning candidate.
Sourcepub fn ring_exchange(
&self,
outgoing: &Array1<f64>,
) -> ScirsResult<Option<Array1<f64>>>
pub fn ring_exchange( &self, outgoing: &Array1<f64>, ) -> ScirsResult<Option<Array1<f64>>>
Exchange a vector around a unidirectional process ring.
Sends outgoing to rank (rank + 1) % size and returns the vector
received from rank (rank - 1 + size) % size. A deadlock-free ordering
is used (rank 0 receives before sending, every other rank sends before
receiving), so it is safe with blocking point-to-point primitives for any
communicator size. Returns None when there is only a single process.
Sourcepub fn stats(&self) -> &DistributedStats
pub fn stats(&self) -> &DistributedStats
Get performance statistics
Auto Trait Implementations§
impl<M> Freeze for DistributedOptimizationContext<M>where
M: Freeze,
impl<M> RefUnwindSafe for DistributedOptimizationContext<M>where
M: RefUnwindSafe,
impl<M> Send for DistributedOptimizationContext<M>where
M: Send,
impl<M> Sync for DistributedOptimizationContext<M>where
M: Sync,
impl<M> Unpin for DistributedOptimizationContext<M>where
M: Unpin,
impl<M> UnsafeUnpin for DistributedOptimizationContext<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for DistributedOptimizationContext<M>where
M: UnwindSafe,
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> 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 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.