Expand description
§mpi-rs — a pure-Rust Message Passing Interface
This crate (published as mpi-rs, imported as mpi) is a
from-scratch, pure-Rust implementation of MPI whose public API mirrors
rsmpi (the mpi crate) so that existing
rsmpi programs compile and run against it with little or no change. Unlike
rsmpi, it does not link against a C MPI library (Open MPI / MPICH): the
runtime — process bootstrap, the byte transport, and every collective
algorithm — is implemented here in safe Rust on top of the standard library
only (the default build has zero external dependencies).
§Quick start
use mpi::traits::*;
let universe = mpi::initialize().unwrap();
let world = universe.world();
let size = world.size();
let rank = world.rank();
if rank == 0 {
let msg = [1.0f64, 2.0, 3.0];
world.process_at_rank(1).send(&msg[..]);
} else if rank == 1 {
let (msg, status) = world.process_at_rank(0).receive_vec::<f64>();
println!("rank 1 received {:?} (status {:?})", msg, status);
}Run it with the bundled launcher:
mpiexec -n 4 ./target/debug/examples/helloA program that is not launched under mpiexec runs as a singleton job
(world size 1, rank 0), exactly like a C MPI singleton MPI_Init.
Re-exports§
pub use environment::initialize;pub use environment::initialize_with_threading;pub use environment::library_version;pub use environment::processor_name;pub use environment::threading_support;pub use environment::time;pub use environment::time_resolution;pub use environment::version;pub use environment::Threading;pub use environment::Universe;
Modules§
- attribute
- Attribute caching on communicators. Mirrors rsmpi’s
attributemodule: a keyval identifies a slot, and arbitrary typed values can be cached on a communicator and retrieved later. - collective
- Collective communication and reduction operations. Mirrors
mpi::collectivein rsmpi: theCommunicatorCollectivestrait (rootless collectives, blanket-implemented for everyCommunicator), theRoottrait (rooted collectives, implemented forProcess), theOperationtrait, andSystemOperation/UserOperation. - datatype
- Datatypes and buffers.
- environment
- Process-wide MPI environment: initialization, finalization and the
Universehandle. Mirrorsmpi::environmentin rsmpi. - error
- Error classes and error handlers (
MPI_Errhandler,MPI_ERR_*). - io
- Parallel file I/O (
File), corresponding to MPI’s I/O chapter (MPI_File_*), which released rsmpi does not currently expose. - launcher
- The pure-Rust MPI process launcher, shared by the
mpiexecandmpirunbinaries. - point_
to_ point - Point-to-point communication. Mirrors
mpi::point_to_pointin rsmpi: theSource(receive) andDestination(send) traits,Status,Message(matched probe) and thesend_receivefree functions. - raw
- Bridge between Rust types and their underlying raw handles. Mirrors
mpi::rawin rsmpi. In a C-backed MPI these expose the opaqueMPI_*handles; here the “raw” form of a handle is the pure-Rust identifier the runtime uses internally (e.g. a communicator context id). - request
- Non-blocking request handling. Mirrors
mpi::requestin rsmpi:Requestborrows the buffer involved in an in-flight operation for the lifetime of the request,Scopebounds that borrow, andWaitGuard/CancelGuardcomplete a request when they go out of scope. - topology
- Groups and communicators. Mirrors
mpi::topologyin rsmpi (0.8.x), where the formerSystemCommunicator/UserCommunicatorsplit is unified into a singleSimpleCommunicator. Backwards-compatible aliases for the old names are provided. - traits
- Convenient re-export of every public trait, mirroring
mpi::traitsin rsmpi. The idiomatic import is: - window
- One-sided (RMA) communication:
Windows of memory that remote ranks canputinto,getfrom, andaccumulateinto without the target making a matching call. This corresponds to MPI’s one-sided chapter (MPI_Win_*), which released rsmpi does not currently expose.
Enums§
- MpiError
- Errors that can occur while managing the MPI environment.
Constants§
- ANY_
SOURCE - A convenience re-export of the wildcard constants.
Wildcard matching any source rank (
MPI_ANY_SOURCE). - ANY_TAG
- A convenience re-export of the wildcard constants.
Wildcard matching any tag (
MPI_ANY_TAG).
Type Aliases§
- Address
- A byte displacement / absolute address (
MPI_Aint). - Count
- The integer type counting elements in a buffer (
intin the C API). - Rank
- The integer type used to identify a process within a communicator
(
MPI_Comm_rank). - Tag
- The integer type used to tag point-to-point messages.
Derive Macros§
- Equivalence
- Derive macro for
datatype::Equivalence(enabled by thederivefeature).