hello/hello.rs
1//! The classic MPI hello-world: every process prints its rank and the world
2//! size. Run with e.g. `mpiexec -n 4 ./target/debug/examples/hello`.
3
4use mpi::traits::*;
5
6fn main() {
7 let universe = mpi::initialize().unwrap();
8 let world = universe.world();
9 let size = world.size();
10 let rank = world.rank();
11 let processor = mpi::processor_name().unwrap_or_else(|_| "unknown".into());
12
13 println!("Hello from rank {rank} of {size} on {processor}");
14
15 // Make sure the output is interleaved cleanly before exit.
16 world.barrier();
17 if rank == 0 {
18 println!("All {size} processes checked in.");
19 }
20}