Thin wrapper to a Message Passing Interface (MPI)
Contents
Introduction
MsgPass (Message Passing) is a thin Rust wrapper to MPI. We consider a small subset of MPI functions. This subset will grow as our projects require more functionality. We implement (by hand) C functions that Rust can easily call using the FFI (in the c_code directory).
We try to test all functions as much as possible, but test coverage could be better. The tests must be called with mpiexec, thus it is easy to use the run-tests.bash script.
Note: We can communicate strings by converting them to an array of bytes. For instance:
let mut bytes = vec!;
str_to_bytes;
comm.broadcast_bytes?;
Installation
Debian/Ubuntu Linux
First, install OpenMPI, MPICH, or Intel MPI. For instance,
or
or
The use the corresponding feature:
intel: use Intel MPImpich: use MPICH- (default): use OpenMPI
For Intel MPI, remember to call setvars.sh first:
macOS
On macOS, install the following packages:
Also, export the following environment variable:
Setting Cargo.toml
👆 Check the crate version and update your Cargo.toml accordingly:
[]
= "*"
Or, considering the optional features:
[]
= { = "*", = ["intel"] }
Examples
See also:
The example below (available in the examples directory) will send an array from ROOT to all the other processors.
use *;
Running the code above with mpiexec -np 4 ex_send_receive (see run-examples.bash), we get an output similar to the one below:
### ex_send_receive ######################################################
2: y = [1.0, 2.0, 3.0]
0: x = [1.0, 2.0, 3.0]
3: y = [1.0, 2.0, 3.0]
1: y = [1.0, 2.0, 3.0]
Roadmap
- Implement basic functionality
- Initialize and finalize
- Abort and barrier
- Wrap more MPI functions
- Implement send/receive
- Implement reduce/allreduce
- Implement scatter/gather/allgather
- Handle complex numbers