pub struct Universe { /* private fields */ }
Expand description
Global context
Implementations§
Source§impl Universe
impl Universe
Sourcepub fn world(&self) -> SystemCommunicator
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?
More examples
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}
Additional examples can be found in:
- examples/all_gather_bool.rs
- examples/structured.rs
- examples/all_to_all.rs
- examples/scan.rs
- examples/scatter.rs
- examples/immediate_all_to_all.rs
- examples/datatype_dup.rs
- examples/complex_datatype.rs
- examples/immediate_scan.rs
- examples/immediate_scatter.rs
- examples/barrier.rs
- examples/buffered.rs
- examples/broadcast_complex.rs
- examples/all_gather_varcount.rs
- examples/ready_send.rs
- examples/broadcast.rs
- examples/immediate_all_gather_varcount.rs
- examples/scatter_varcount.rs
- examples/gather_varcount.rs
- examples/wait_any.rs
- examples/immediate_broadcast.rs
- examples/contiguous.rs
- examples/immediate_scatter_varcount.rs
- examples/vector.rs
- examples/immediate_gather_varcount.rs
- examples/readme.rs
- examples/send_receive.rs
- examples/immediate_reduce.rs
- examples/reduce.rs
- examples/all_gather.rs
- examples/immediate_barrier.rs
- examples/immediate_all_gather.rs
- examples/gather.rs
- examples/group.rs
- examples/cartesian.rs
- examples/immediate.rs
- examples/split.rs
- examples/immediate_gather.rs
Sourcepub fn buffer_size(&self) -> usize
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}
Sourcepub fn set_buffer_size(&mut self, size: usize)
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}
Sourcepub fn detach_buffer(&mut self)
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§
Auto Trait Implementations§
impl Freeze for Universe
impl RefUnwindSafe for Universe
impl Send for Universe
impl Sync for Universe
impl Unpin for Universe
impl UnwindSafe for Universe
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.