Skip to main content

MockComm

Struct MockComm 

Source
pub struct MockComm {
    pub rank: usize,
    pub world_size: usize,
    /* private fields */
}
Expand description

Mock communication backend for testing distributed operations.

This implementation simulates collective operations in-memory, allowing testing of distributed code paths on a single machine.

Fields§

§rank: usize

This rank’s ID in the mesh

§world_size: usize

Total number of ranks

Implementations§

Source§

impl MockComm

Source

pub fn new(rank: usize, world_size: usize) -> Self

Create a new MockComm for a specific rank

Source

pub fn with_shared_state(rank: usize, state: Arc<RwLock<MockCommState>>) -> Self

Create a new MockComm with shared state (for multi-rank simulation)

Source

pub fn create_group(world_size: usize) -> Vec<Self>

Create a group of MockComm instances that share state

Trait Implementations§

Source§

impl Debug for MockComm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MeshComm for MockComm

Source§

fn all_reduce( &self, buf: &mut [u8], dtype: DType, op: ReduceOp, _group: &str, ) -> Result<(), String>

All-reduce operation: reduce values across all ranks in a group
Source§

fn all_gather( &self, local: &[u8], out: &mut [u8], _dtype: DType, _group: &str, ) -> Result<(), String>

All-gather: gather data from all ranks
Source§

fn broadcast( &self, buf: &mut [u8], root_rank: usize, _group: &str, ) -> Result<(), String>

Broadcast from root rank to all ranks in group
Source§

fn reduce_scatter( &self, buf: &mut [u8], out: &mut [u8], op: ReduceOp, group: &str, ) -> Result<(), String>

Reduce-scatter: reduce and distribute results
Source§

fn barrier(&self, _group: &str) -> Result<(), String>

Barrier synchronization
Source§

fn send(&self, buf: &[u8], dest_rank: usize) -> Result<(), String>

Send data to a specific rank
Source§

fn recv(&self, buf: &mut [u8], src_rank: usize) -> Result<(), String>

Receive data from a specific rank

Auto Trait Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.