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>
impl<'b, B, C, D> PartitionMut<'b, B, C, D>
sourcepub fn new(buf: &mut B, counts: C, displs: D) -> PartitionMut<'_, B, C, D>
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
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,
impl<'b, B, C, D> AsDatatype for PartitionMut<'b, B, C, D>where
B: 'b + AsDatatype + ?Sized,
§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 PartitionMut<'b, B, C, D>
impl<'b, B, C, D> Partitioned for PartitionMut<'b, B, C, D>
source§impl<'b, B, C, D> PointerMut for PartitionMut<'b, B, C, D>where
B: 'b + PointerMut + ?Sized,
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
fn pointer_mut(&mut self) -> *mut c_void
A mutable pointer to the starting address in memory
impl<'b, B, C, D> PartitionedBufferMut for PartitionMut<'b, B, C, D>
Auto Trait Implementations§
impl<'b, B, C, D> Freeze for PartitionMut<'b, B, C, D>
impl<'b, B, C, D> RefUnwindSafe for PartitionMut<'b, B, C, D>
impl<'b, B, C, D> Send for PartitionMut<'b, B, C, D>
impl<'b, B, C, D> Sync for PartitionMut<'b, B, C, D>
impl<'b, B, C, D> Unpin for PartitionMut<'b, B, C, D>
impl<'b, B, C, D> !UnwindSafe for PartitionMut<'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,
§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.