Struct Universe

Source
pub struct Universe { /* private fields */ }
Expand description

Global context

Implementations§

Source§

impl Universe

Source

pub fn world(&self) -> SystemCommunicator

The ‘world communicator’

Contains all processes initially partaking in the computation.

§Examples

See examples/simple.rs

Examples found in repository?
examples/simple.rs (line 8)
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 10)
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 9)
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 9)
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 8)
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 8)
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}
Source

pub fn buffer_size(&self) -> usize

The size in bytes of the buffer used for buffered communication.

Examples found in repository?
examples/buffered.rs (line 14)
9fn main() {
10    let mut universe = mpi::initialize().unwrap();
11    // Try to attach a buffer.
12    universe.set_buffer_size(BUFFER_SIZE);
13    // Check buffer size matches.
14    assert_eq!(universe.buffer_size(), BUFFER_SIZE);
15    // Try to detach the buffer.
16    universe.detach_buffer();
17    // Attach another buffer.
18    universe.set_buffer_size(BUFFER_SIZE);
19
20    let world = universe.world();
21
22    let x = vec![std::f32::consts::PI; 1024];
23    let mut y = vec![0.0; 1024];
24    mpi::request::scope(|scope| {
25        let _rreq = WaitGuard::from(
26            world
27                .any_process()
28                .immediate_receive_into(scope, &mut y[..]),
29        );
30        world.this_process().buffered_send(&x[..]);
31    });
32    assert_eq!(x, y);
33}
Source

pub fn set_buffer_size(&mut self, size: usize)

Set the size in bytes of the buffer used for buffered communication.

Examples found in repository?
examples/buffered.rs (line 12)
9fn main() {
10    let mut universe = mpi::initialize().unwrap();
11    // Try to attach a buffer.
12    universe.set_buffer_size(BUFFER_SIZE);
13    // Check buffer size matches.
14    assert_eq!(universe.buffer_size(), BUFFER_SIZE);
15    // Try to detach the buffer.
16    universe.detach_buffer();
17    // Attach another buffer.
18    universe.set_buffer_size(BUFFER_SIZE);
19
20    let world = universe.world();
21
22    let x = vec![std::f32::consts::PI; 1024];
23    let mut y = vec![0.0; 1024];
24    mpi::request::scope(|scope| {
25        let _rreq = WaitGuard::from(
26            world
27                .any_process()
28                .immediate_receive_into(scope, &mut y[..]),
29        );
30        world.this_process().buffered_send(&x[..]);
31    });
32    assert_eq!(x, y);
33}
Source

pub fn detach_buffer(&mut self)

Detach the buffer used for buffered communication.

Examples found in repository?
examples/buffered.rs (line 16)
9fn main() {
10    let mut universe = mpi::initialize().unwrap();
11    // Try to attach a buffer.
12    universe.set_buffer_size(BUFFER_SIZE);
13    // Check buffer size matches.
14    assert_eq!(universe.buffer_size(), BUFFER_SIZE);
15    // Try to detach the buffer.
16    universe.detach_buffer();
17    // Attach another buffer.
18    universe.set_buffer_size(BUFFER_SIZE);
19
20    let world = universe.world();
21
22    let x = vec![std::f32::consts::PI; 1024];
23    let mut y = vec![0.0; 1024];
24    mpi::request::scope(|scope| {
25        let _rreq = WaitGuard::from(
26            world
27                .any_process()
28                .immediate_receive_into(scope, &mut y[..]),
29        );
30        world.this_process().buffered_send(&x[..]);
31    });
32    assert_eq!(x, y);
33}

Trait Implementations§

Source§

impl Debug for Universe

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Universe

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.