Function initialize

Source
pub fn initialize() -> Option<Universe>
Expand description

Initialize MPI.

If the MPI library has not been initialized so far, initializes and returns a representation of the MPI communication Universe which provides access to additional functions. Otherwise returns None.

Equivalent to: initialize_with_threading(Threading::Single)

§Examples

See examples/simple.rs

§Standard section(s)

8.7

Examples found in repository?
examples/simple.rs (line 7)
6fn main() {
7    let universe = mpi::initialize().unwrap();
8    let world = universe.world();
9    println!(
10        "Hello parallel world from process {} of {}!",
11        world.rank(),
12        world.size()
13    );
14}
More examples
Hide additional examples
examples/comm_name.rs (line 9)
8fn main() {
9    let universe = mpi::initialize().unwrap();
10    let world = universe.world();
11    assert_eq!("MPI_COMM_WORLD", world.get_name());
12    world.set_name(CNAME);
13    assert_eq!(CNAME, world.get_name());
14}
examples/cartesian_map.rs (line 7)
6fn main() {
7    let universe = mpi::initialize().unwrap();
8
9    let comm = universe.world();
10
11    let new_rank = comm.cartesian_map(&[2, comm.size() / 4], &[false, false]);
12
13    println!("{} -> {:?}", comm.rank(), new_rank);
14}
examples/duplicate.rs (line 8)
7fn main() {
8    let universe = mpi::initialize().unwrap();
9    let world = universe.world();
10    let moon = world.duplicate();
11
12    world.barrier();
13    moon.barrier();
14
15    assert_eq!(CommunicatorRelation::Congruent, world.compare(&moon));
16}
examples/pack.rs (line 7)
6fn main() {
7    let universe = mpi::initialize().unwrap();
8    let world = universe.world();
9
10    let ints = [3i32, 2, 1];
11    let packed = world.pack(&ints[..]);
12
13    let mut new_ints = [0, 0, 0];
14    unsafe {
15        world.unpack_into(&packed, &mut new_ints[..], 0);
16    }
17
18    assert_eq!([3, 2, 1], new_ints);
19}
examples/time.rs (line 7)
6fn main() {
7    let universe = mpi::initialize().unwrap();
8    let world = universe.world();
9
10    let t_start = mpi::time();
11    world.barrier();
12    let t_end = mpi::time();
13
14    println!("barrier took: {} s", t_end - t_start);
15    println!(
16        "the clock has a resoltion of {} seconds",
17        mpi::time_resolution()
18    );
19}