Skip to main content

Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required methods
    fn rank(&self) -> u32;
    fn world_size(&self) -> u32;
    fn send_bytes(
        &self,
        to: u32,
        tag: u32,
        bytes: &[u8],
    ) -> Result<(), CollectiveError>;
    fn recv_bytes(
        &self,
        from: u32,
        tag: u32,
    ) -> Result<Vec<u8>, CollectiveError>;

    // Provided method
    fn barrier(&self) -> Result<(), CollectiveError> { ... }
}
Expand description

Two-sided, tagged, byte-oriented point-to-point transport between world_size ranks.

Implementations must be safe to share across threads (Send + Sync) and must let a reader on one rank pull a message that a writer on another rank pushed with the same (src, tag) — the send/recv are matched, like MPI. recv learns the payload length from the wire, so callers need not know it in advance.

Required Methods§

Source

fn rank(&self) -> u32

This process’s rank in 0..world_size.

Source

fn world_size(&self) -> u32

Total number of participating ranks.

Source

fn send_bytes( &self, to: u32, tag: u32, bytes: &[u8], ) -> Result<(), CollectiveError>

Send bytes to rank to, tagged tag. Returns once the bytes are handed to the transport (not necessarily delivered).

Source

fn recv_bytes(&self, from: u32, tag: u32) -> Result<Vec<u8>, CollectiveError>

Block until a message with matching (from, tag) arrives, and return its payload.

Provided Methods§

Source

fn barrier(&self) -> Result<(), CollectiveError>

Block until every rank has reached this barrier.

Default is a gather-to-root rendezvous over send/recv: every non-root sends a token to rank 0 and waits for the release; rank 0 collects all tokens then releases everyone. Lockstep is preserved across repeated barriers because a non-root cannot enter the next barrier until it observes the current release.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§