Struct mpi::datatype::PartitionMut

source ·
pub struct PartitionMut<'b, B: 'b + ?Sized, C, D> { /* private fields */ }
Expand description

Adds a partitioning to an existing BufferMut so that it becomes Partitioned

Implementations§

source§

impl<'b, B, C, D> PartitionMut<'b, B, C, D>
where B: 'b + BufferMut + ?Sized, C: Borrow<[Count]>, D: Borrow<[Count]>,

source

pub fn new(buf: &mut B, counts: C, displs: D) -> PartitionMut<'_, B, C, D>

Partition buf using counts and displs

Examples found in repository?
examples/all_gather_varcount.rs (line 28)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
fn main() {
    let universe = mpi::initialize().unwrap();
    let world = universe.world();

    let rank = world.rank();
    let size = world.size();

    let msg: Vec<_> = (0..rank).collect();

    let counts: Vec<Count> = (0..size).collect();
    let displs: Vec<Count> = counts
        .iter()
        .scan(0, |acc, &x| {
            let tmp = *acc;
            *acc += x;
            Some(tmp)
        })
        .collect();

    let mut buf = vec![0; (size * (size - 1) / 2) as usize];
    {
        let mut partition = PartitionMut::new(&mut buf[..], counts, &displs[..]);
        world.all_gather_varcount_into(&msg[..], &mut partition);
    }

    assert!(buf
        .iter()
        .zip((0..size).flat_map(|r| (0..r)))
        .all(|(&i, j)| i == j));
    println!("Process {} got message {:?}", rank, buf);
}
More examples
Hide additional examples
examples/immediate_all_gather_varcount.rs (line 28)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fn main() {
    let universe = mpi::initialize().unwrap();
    let world = universe.world();

    let rank = world.rank();
    let size = world.size();

    let msg: Vec<_> = (0..rank).collect();

    let counts: Vec<Count> = (0..size).collect();
    let displs: Vec<Count> = counts
        .iter()
        .scan(0, |acc, &x| {
            let tmp = *acc;
            *acc += x;
            Some(tmp)
        })
        .collect();

    let mut buf = vec![0; (size * (size - 1) / 2) as usize];
    {
        let mut partition = PartitionMut::new(&mut buf[..], counts, &displs[..]);
        mpi::request::scope(|scope| {
            let req = world.immediate_all_gather_varcount_into(scope, &msg[..], &mut partition);
            req.wait();
        });
    }

    assert!(buf
        .iter()
        .zip((0..size).flat_map(|r| (0..r)))
        .all(|(&i, j)| i == j));
    println!("Process {} got message {:?}", rank, buf);
}
examples/gather_varcount.rs (line 32)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
fn main() {
    let universe = mpi::initialize().unwrap();
    let world = universe.world();

    let rank = world.rank();
    let size = world.size();

    let root_rank = 0;
    let root_process = world.process_at_rank(root_rank);

    let msg: Vec<_> = (0..rank).collect();

    if rank == root_rank {
        let counts: Vec<Count> = (0..size).collect();
        let displs: Vec<Count> = counts
            .iter()
            .scan(0, |acc, &x| {
                let tmp = *acc;
                *acc += x;
                Some(tmp)
            })
            .collect();

        let mut buf = vec![0; (size * (size - 1) / 2) as usize];
        {
            let mut partition = PartitionMut::new(&mut buf[..], counts, &displs[..]);
            root_process.gather_varcount_into_root(&msg[..], &mut partition);
        }

        assert!(buf
            .iter()
            .zip((0..size).flat_map(|r| (0..r)))
            .all(|(&i, j)| i == j));
        println!("{:?}", buf);
    } else {
        root_process.gather_varcount_into(&msg[..]);
    }
}
examples/immediate_gather_varcount.rs (line 32)
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
fn main() {
    let universe = mpi::initialize().unwrap();
    let world = universe.world();

    let rank = world.rank();
    let size = world.size();

    let root_rank = 0;
    let root_process = world.process_at_rank(root_rank);

    let msg: Vec<_> = (0..rank).collect();

    if rank == root_rank {
        let counts: Vec<Count> = (0..size).collect();
        let displs: Vec<Count> = counts
            .iter()
            .scan(0, |acc, &x| {
                let tmp = *acc;
                *acc += x;
                Some(tmp)
            })
            .collect();

        let mut buf = vec![0; (size * (size - 1) / 2) as usize];
        {
            let mut partition = PartitionMut::new(&mut buf[..], counts, &displs[..]);
            mpi::request::scope(|scope| {
                root_process
                    .immediate_gather_varcount_into_root(scope, &msg[..], &mut partition)
                    .wait();
            })
        }

        assert!(buf
            .iter()
            .zip((0..size).flat_map(|r| (0..r)))
            .all(|(&i, j)| i == j));
        println!("{:?}", buf);
    } else {
        mpi::request::scope(|scope| {
            root_process
                .immediate_gather_varcount_into(scope, &msg[..])
                .wait();
        });
    }
}

Trait Implementations§

source§

impl<'b, B, C, D> AsDatatype for PartitionMut<'b, B, C, D>
where B: 'b + AsDatatype + ?Sized,

§

type Out = <B as AsDatatype>::Out

The type of the associated MPI datatype (e.g. SystemDatatype or UserDatatype)
source§

fn as_datatype(&self) -> Self::Out

The associated MPI datatype
source§

impl<'b, B, C, D> Partitioned for PartitionMut<'b, B, C, D>
where B: 'b + ?Sized, C: Borrow<[Count]>, D: Borrow<[Count]>,

source§

fn counts(&self) -> &[Count]

The count of elements in each partition.
source§

fn displs(&self) -> &[Count]

The displacement from the start of the buffer for each partition.
source§

impl<'b, B, C, D> PointerMut for PartitionMut<'b, B, C, D>
where B: 'b + PointerMut + ?Sized,

source§

fn pointer_mut(&mut self) -> *mut c_void

A mutable pointer to the starting address in memory
source§

impl<'b, B, C, D> PartitionedBufferMut for PartitionMut<'b, B, C, D>
where B: 'b + PointerMut + AsDatatype + ?Sized, C: Borrow<[Count]>, D: Borrow<[Count]>,

Auto Trait Implementations§

§

impl<'b, B, C, D> Freeze for PartitionMut<'b, B, C, D>
where C: Freeze, D: Freeze, B: ?Sized,

§

impl<'b, B, C, D> RefUnwindSafe for PartitionMut<'b, B, C, D>

§

impl<'b, B, C, D> Send for PartitionMut<'b, B, C, D>
where C: Send, D: Send, B: Send + ?Sized,

§

impl<'b, B, C, D> Sync for PartitionMut<'b, B, C, D>
where C: Sync, D: Sync, B: Sync + ?Sized,

§

impl<'b, B, C, D> Unpin for PartitionMut<'b, B, C, D>
where C: Unpin, D: Unpin, B: ?Sized,

§

impl<'b, B, C, D> !UnwindSafe for PartitionMut<'b, B, C, D>

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,

§

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,

§

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

§

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>,

§

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>,

§

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>,

§

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

§

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>,

§

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.