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 methods
fn recv_bytes_timeout(
&self,
from: u32,
tag: u32,
_timeout: Duration,
) -> Result<Option<Vec<u8>>, CollectiveError> { ... }
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§
Sourcefn world_size(&self) -> u32
fn world_size(&self) -> u32
Total number of participating ranks.
Sourcefn send_bytes(
&self,
to: u32,
tag: u32,
bytes: &[u8],
) -> Result<(), CollectiveError>
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).
Sourcefn recv_bytes(&self, from: u32, tag: u32) -> Result<Vec<u8>, CollectiveError>
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§
Sourcefn recv_bytes_timeout(
&self,
from: u32,
tag: u32,
_timeout: Duration,
) -> Result<Option<Vec<u8>>, CollectiveError>
fn recv_bytes_timeout( &self, from: u32, tag: u32, _timeout: Duration, ) -> Result<Option<Vec<u8>>, CollectiveError>
Like Self::recv_bytes but gives up after timeout, returning
Ok(None). The default blocks (transports with no deadline support
ignore the timeout); crate::NetTransport overrides it with a real
wait_timeout. This is the basis for not letting a slow or offline
edge node stall a collective (bounded staleness).
Sourcefn barrier(&self) -> Result<(), CollectiveError>
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".