Function send_receive_into

Source
pub fn send_receive_into<M, D, B, S>(
    msg: &M,
    destination: &D,
    buf: &mut B,
    source: &S,
) -> Status
where M: Buffer + ?Sized, D: Destination, B: BufferMut + ?Sized, S: Source,
Expand description

Sends the contents of msg to destination and simultaneously receives a message from source into buf.

ยงStandard section(s)

3.10

Examples found in repository?
examples/contiguous.rs (line 30)
9fn main() {
10    let universe = mpi::initialize().unwrap();
11    let world = universe.world();
12    let rank = world.rank();
13    let size = world.size();
14
15    let next_rank = if rank + 1 < size { rank + 1 } else { 0 };
16    let next_process = world.process_at_rank(next_rank);
17    let previous_rank = if rank > 0 { rank - 1 } else { size - 1 };
18    let previous_process = world.process_at_rank(previous_rank);
19
20    let b1 = (1..).map(|x| rank * x).take(3).collect::<Vec<_>>();
21    let mut b2 = std::iter::repeat(-1).take(3).collect::<Vec<_>>();
22    println!("Rank {} sending message: {:?}.", rank, b1);
23    world.barrier();
24
25    let t = UserDatatype::contiguous(3, &Rank::equivalent_datatype());
26    let status;
27    {
28        let v1 = unsafe { View::with_count_and_datatype(&b1[..], 1, &t) };
29        let mut v2 = unsafe { MutView::with_count_and_datatype(&mut b2[..], 1, &t) };
30        status = p2p::send_receive_into(&v1, &next_process, &mut v2, &previous_process);
31    }
32
33    println!(
34        "Rank {} received message: {:?}, status: {:?}.",
35        rank, b2, status
36    );
37    world.barrier();
38
39    let b3 = (1..).map(|x| previous_rank * x).take(3).collect::<Vec<_>>();
40    assert_eq!(b3, b2);
41}
More examples
Hide additional examples
examples/vector.rs (line 30)
9fn main() {
10    let universe = mpi::initialize().unwrap();
11    let world = universe.world();
12    let rank = world.rank();
13    let size = world.size();
14
15    let next_rank = if rank + 1 < size { rank + 1 } else { 0 };
16    let next_process = world.process_at_rank(next_rank);
17    let previous_rank = if rank > 0 { rank - 1 } else { size - 1 };
18    let previous_process = world.process_at_rank(previous_rank);
19
20    let b1 = (1..).map(|x| rank * x).take(6).collect::<Vec<_>>();
21    let mut b2 = std::iter::repeat(-1).take(6).collect::<Vec<_>>();
22    println!("Rank {} sending message: {:?}.", rank, b1);
23    world.barrier();
24
25    let t = UserDatatype::vector(2, 2, 3, &Rank::equivalent_datatype());
26    let status;
27    {
28        let v1 = unsafe { View::with_count_and_datatype(&b1[..], 1, &t) };
29        let mut v2 = unsafe { MutView::with_count_and_datatype(&mut b2[..], 1, &t) };
30        status = p2p::send_receive_into(&v1, &next_process, &mut v2, &previous_process);
31    }
32
33    println!(
34        "Rank {} received message: {:?}, status: {:?}.",
35        rank, b2, status
36    );
37    world.barrier();
38
39    let b3 = (1..)
40        .map(|x| if x % 3 == 0 { -1 } else { previous_rank * x })
41        .take(6)
42        .collect::<Vec<_>>();
43    assert_eq!(b3, b2);
44}