pub struct Partition<'b, B: 'b + ?Sized, C, D> { /* private fields */ }
Expand description
Adds a partitioning to an existing Buffer
so that it becomes Partitioned
Implementations§
Source§impl<'b, B, C, D> Partition<'b, B, C, D>
impl<'b, B, C, D> Partition<'b, B, C, D>
Sourcepub fn new(buf: &B, counts: C, displs: D) -> Partition<'_, B, C, D>
pub fn new(buf: &B, counts: C, displs: D) -> Partition<'_, B, C, D>
Partition buf
using counts
and displs
Examples found in repository?
examples/scatter_varcount.rs (line 30)
7fn main() {
8 let universe = mpi::initialize().unwrap();
9 let world = universe.world();
10
11 let rank = world.rank();
12 let size = world.size();
13
14 let root_rank = 0;
15 let root_process = world.process_at_rank(root_rank);
16
17 let mut buf = vec![0; rank as usize];
18
19 if rank == root_rank {
20 let msg: Vec<_> = (0..size).flat_map(|i| (0..i)).collect();
21 let counts: Vec<Count> = (0..size).collect();
22 let displs: Vec<Count> = counts
23 .iter()
24 .scan(0, |acc, &x| {
25 let tmp = *acc;
26 *acc += x;
27 Some(tmp)
28 })
29 .collect();
30 let partition = Partition::new(&msg[..], counts, &displs[..]);
31 root_process.scatter_varcount_into_root(&partition, &mut buf[..]);
32 } else {
33 root_process.scatter_varcount_into(&mut buf[..]);
34 }
35
36 assert!(buf.iter().zip(0..rank).all(|(&i, j)| i == j));
37 println!("Process {} got message: {:?}", rank, buf);
38}
More examples
examples/immediate_scatter_varcount.rs (line 30)
7fn main() {
8 let universe = mpi::initialize().unwrap();
9 let world = universe.world();
10
11 let rank = world.rank();
12 let size = world.size();
13
14 let root_rank = 0;
15 let root_process = world.process_at_rank(root_rank);
16
17 let mut buf = vec![0; rank as usize];
18
19 if rank == root_rank {
20 let msg: Vec<_> = (0..size).flat_map(|i| (0..i)).collect();
21 let counts: Vec<Count> = (0..size).collect();
22 let displs: Vec<Count> = counts
23 .iter()
24 .scan(0, |acc, &x| {
25 let tmp = *acc;
26 *acc += x;
27 Some(tmp)
28 })
29 .collect();
30 let partition = Partition::new(&msg[..], counts, &displs[..]);
31 mpi::request::scope(|scope| {
32 root_process
33 .immediate_scatter_varcount_into_root(scope, &partition, &mut buf[..])
34 .wait();
35 });
36 } else {
37 mpi::request::scope(|scope| {
38 root_process
39 .immediate_scatter_varcount_into(scope, &mut buf[..])
40 .wait();
41 });
42 }
43
44 assert!(buf.iter().zip(0..rank).all(|(&i, j)| i == j));
45 println!("Process {} got message: {:?}", rank, buf);
46}
Trait Implementations§
Source§impl<'b, B, C, D> AsDatatype for Partition<'b, B, C, D>where
B: 'b + AsDatatype + ?Sized,
impl<'b, B, C, D> AsDatatype for Partition<'b, B, C, D>where
B: 'b + AsDatatype + ?Sized,
Source§type Out = <B as AsDatatype>::Out
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
fn as_datatype(&self) -> Self::Out
The associated MPI datatype
Source§impl<'b, B, C, D> Partitioned for Partition<'b, B, C, D>
impl<'b, B, C, D> Partitioned for Partition<'b, B, C, D>
impl<'b, B, C, D> PartitionedBuffer for Partition<'b, B, C, D>
Auto Trait Implementations§
impl<'b, B, C, D> Freeze for Partition<'b, B, C, D>
impl<'b, B, C, D> RefUnwindSafe for Partition<'b, B, C, D>
impl<'b, B, C, D> Send for Partition<'b, B, C, D>
impl<'b, B, C, D> Sync for Partition<'b, B, C, D>
impl<'b, B, C, D> Unpin for Partition<'b, B, C, D>
impl<'b, B, C, D> UnwindSafe for Partition<'b, B, C, D>
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
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 Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
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>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
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>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.