Rust MPI bindings with runtime library loading. Fork of rsmpi v0.8.1.
Status: Experimental / Proof of Concept. This project aims to eventually merge its runtime-loading backend upstream into rsmpi.
The key addition over upstream rsmpi is the mpi-rt-sys-backend: a backend based on MPItrampoline's MPIABI that loads MPI at runtime via dlopen, requiring no C compiler, system MPI headers, or libclang at build time.
The primary goal is to enable calling Rust MPI code from Julia and Python without build-time MPI dependencies. By loading MPI at runtime, Rust libraries can share the same MPI communicator with MPI.jl and mpi4py, enabling seamless multi-language HPC workflows.
[dependencies]
mpi = { git = "https://github.com/tensor4all/rsmpi-rt", default-features = false, features = ["mpi-rt-sys-backend"] }use mpi::traits::*;
fn main() {
let universe = mpi::initialize().unwrap();
let world = universe.world();
println!("Hello from rank {} of {}", world.rank(), world.size());
}export MPI_RT_LIB=/path/to/libmpiwrapper.so
mpiexec -n 4 cargo run| Feature | Description | Default |
|---|---|---|
mpi-sys-backend |
Bindgen-based (requires C compiler, system MPI, libclang) | Yes |
mpi-rt-sys-backend |
MPItrampoline/MPIABI-based runtime loading (no build-time MPI deps) | No |
The two backends are mutually exclusive.
No build-time MPI dependencies. The MPI library is loaded at runtime via MPIwrapper.
[dependencies]
mpi = { git = "https://github.com/tensor4all/rsmpi-rt", default-features = false, features = ["mpi-rt-sys-backend"] }With optional features:
[dependencies]
mpi = { git = "https://github.com/tensor4all/rsmpi-rt", default-features = false, features = ["mpi-rt-sys-backend", "user-operations", "derive"] }Runtime setup: Set MPI_RT_LIB to the path of an MPIwrapper library:
export MPI_RT_LIB=/path/to/libmpiwrapper.so
mpiexec -n 4 ./my_programTo build MPIwrapper (requires a system MPI):
git clone https://github.com/eschnett/MPIwrapper
cd MPIwrapper
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local
cmake --build build
cmake --install build
export MPI_RT_LIB=$HOME/.local/lib/libmpiwrapper.soTraditional compile-time binding via rust-bindgen. Same as upstream rsmpi. Requires a C compiler, system MPI installation, and libclang.
[dependencies]
mpi = { git = "https://github.com/tensor4all/rsmpi-rt" }See the upstream rsmpi README for detailed build requirements.
| Feature | Description |
|---|---|
user-operations |
User-defined reduction operations via libffi |
derive |
#[derive(Equivalence)] for sending structs over MPI |
complex |
Support for num-complex types |
Integration tests verify that Rust MPI code can run alongside mpi4py and MPI.jl under the same mpiexec, sharing MPI_COMM_WORLD via MPMD launch:
# Run the cross-language interop test (requires Python/mpi4py and Julia/MPI.jl)
bash tests/interop/run_interop.shSee tests/interop/ for details.
- API docs (GitHub Pages)
- Architecture overview
- MPIABI and dynamic loading
- Backend comparison
- Code generation
Generate docs locally:
cargo doc --workspace --no-deps --features mpi-sys-backend,user-operations,derive,complexSee examples/.
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.