Skip to main content

Crate mpi

Crate mpi 

Source
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/hello

A 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 attribute module: 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::collective in rsmpi: the CommunicatorCollectives trait (rootless collectives, blanket-implemented for every Communicator), the Root trait (rooted collectives, implemented for Process), the Operation trait, and SystemOperation / UserOperation.
datatype
Datatypes and buffers.
environment
Process-wide MPI environment: initialization, finalization and the Universe handle. Mirrors mpi::environment in 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 mpiexec and mpirun binaries.
point_to_point
Point-to-point communication. Mirrors mpi::point_to_point in rsmpi: the Source (receive) and Destination (send) traits, Status, Message (matched probe) and the send_receive free functions.
raw
Bridge between Rust types and their underlying raw handles. Mirrors mpi::raw in rsmpi. In a C-backed MPI these expose the opaque MPI_* 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::request in rsmpi: Request borrows the buffer involved in an in-flight operation for the lifetime of the request, Scope bounds that borrow, and WaitGuard / CancelGuard complete a request when they go out of scope.
topology
Groups and communicators. Mirrors mpi::topology in rsmpi (0.8.x), where the former SystemCommunicator/UserCommunicator split is unified into a single SimpleCommunicator. Backwards-compatible aliases for the old names are provided.
traits
Convenient re-export of every public trait, mirroring mpi::traits in rsmpi. The idiomatic import is:
window
One-sided (RMA) communication: Windows of memory that remote ranks can put into, get from, and accumulate into 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 (int in 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 the derive feature).