Skip to main content

CartesianCommunicator

Struct CartesianCommunicator 

Source
pub struct CartesianCommunicator { /* private fields */ }
Expand description

A communicator carrying a Cartesian grid topology (MPI_Cart_create). Coordinates are laid out row-major (the last dimension varies fastest), matching the MPI standard.

Implementations§

Source§

impl CartesianCommunicator

Source

pub fn num_dimensions(&self) -> usize

The number of grid dimensions (MPI_Cartdim_get).

Source

pub fn dimensions(&self) -> &[Count]

The extent of each dimension.

Source

pub fn periods(&self) -> &[bool]

Whether each dimension is periodic.

Source

pub fn coordinates(&self, rank: Rank) -> Vec<Count>

The Cartesian coordinates of a given rank (MPI_Cart_coords).

Source

pub fn my_coordinates(&self) -> Vec<Count>

This process’s Cartesian coordinates.

Examples found in repository?
examples/selftest.rs (line 255)
11fn main() {
12    let universe = mpi::initialize().unwrap();
13    let world = universe.world();
14    let rank = world.rank();
15    let size = world.size();
16
17    // ---- point-to-point: typed scalar ----
18    if size >= 2 {
19        if rank == 0 {
20            world.process_at_rank(1).send(&42u64);
21        } else if rank == 1 {
22            let (v, status) = world.process_at_rank(0).receive::<u64>();
23            assert_eq!(v, 42);
24            assert_eq!(status.source_rank(), 0);
25        }
26    }
27
28    // ---- point-to-point: vector + probe ----
29    if size >= 2 {
30        if rank == 0 {
31            let data: Vec<i32> = vec![10, 20, 30, 40, 50];
32            world.process_at_rank(1).send(&data[..]);
33        } else if rank == 1 {
34            let status = world.process_at_rank(0).probe();
35            let count = status.count(i32::equivalent_datatype());
36            assert_eq!(count, 5, "probe reported wrong count");
37            let (data, _s) = world.process_at_rank(0).receive_vec::<i32>();
38            assert_eq!(data, vec![10, 20, 30, 40, 50]);
39        }
40    }
41
42    // ---- send_receive ring ----
43    {
44        let next = (rank + 1) % size;
45        let prev = (rank - 1 + size) % size;
46        let (got, _status): (i32, _) = mpi::point_to_point::send_receive(
47            &rank,
48            &world.process_at_rank(next),
49            &world.process_at_rank(prev),
50        );
51        assert_eq!(got, prev, "send_receive ring mismatch");
52    }
53
54    // ---- broadcast ----
55    {
56        let root = world.process_at_rank(0);
57        let mut buf = if rank == 0 {
58            vec![2, 4, 8, 16]
59        } else {
60            vec![0; 4]
61        };
62        root.broadcast_into(&mut buf[..]);
63        assert_eq!(buf, vec![2, 4, 8, 16], "broadcast mismatch");
64    }
65
66    // ---- scatter ----
67    {
68        let root = world.process_at_rank(0);
69        let mut mine = 0i32;
70        if rank == 0 {
71            let send: Vec<i32> = (0..size).collect();
72            root.scatter_into_root(&send[..], &mut mine);
73        } else {
74            root.scatter_into(&mut mine);
75        }
76        assert_eq!(mine, rank, "scatter mismatch");
77    }
78
79    // ---- gather ----
80    {
81        let root = world.process_at_rank(0);
82        if rank == 0 {
83            let mut buf = vec![-1i32; size as usize];
84            root.gather_into_root(&rank, &mut buf[..]);
85            let expected: Vec<i32> = (0..size).collect();
86            assert_eq!(buf, expected, "gather mismatch");
87        } else {
88            root.gather_into(&rank);
89        }
90    }
91
92    // ---- all_gather ----
93    {
94        let mut buf = vec![-1i32; size as usize];
95        world.all_gather_into(&rank, &mut buf[..]);
96        let expected: Vec<i32> = (0..size).collect();
97        assert_eq!(buf, expected, "all_gather mismatch");
98    }
99
100    // ---- all_to_all ----
101    {
102        let send: Vec<i32> = (0..size).map(|j| rank * 100 + j).collect();
103        let mut recv = vec![-1i32; size as usize];
104        world.all_to_all_into(&send[..], &mut recv[..]);
105        for i in 0..size {
106            assert_eq!(recv[i as usize], i * 100 + rank, "all_to_all mismatch");
107        }
108    }
109
110    // ---- reduce to root (sum) ----
111    {
112        let root = world.process_at_rank(0);
113        if rank == 0 {
114            let mut sum = 0i32;
115            root.reduce_into_root(&rank, &mut sum, SystemOperation::sum());
116            assert_eq!(sum, (0..size).sum::<i32>(), "reduce sum mismatch");
117        } else {
118            root.reduce_into(&rank, SystemOperation::sum());
119        }
120    }
121
122    // ---- all_reduce (max) ----
123    {
124        let mut m = 0i32;
125        world.all_reduce_into(&rank, &mut m, SystemOperation::max());
126        assert_eq!(m, size - 1, "all_reduce max mismatch");
127    }
128
129    // ---- inclusive scan ----
130    {
131        let mut acc = 0i32;
132        world.scan_into(&rank, &mut acc, SystemOperation::sum());
133        let expected: i32 = (0..=rank).sum();
134        assert_eq!(acc, expected, "scan mismatch");
135    }
136
137    // ---- exclusive scan ----
138    {
139        let mut acc = -1i32;
140        world.exclusive_scan_into(&rank, &mut acc, SystemOperation::sum());
141        if rank > 0 {
142            let expected: i32 = (0..rank).sum();
143            assert_eq!(acc, expected, "exclusive_scan mismatch");
144        }
145    }
146
147    // ---- reduce_scatter_block ----
148    {
149        let send: Vec<i32> = vec![rank + 1; size as usize];
150        let mut recv = [0i32; 1];
151        world.reduce_scatter_block_into(&send[..], &mut recv[..], SystemOperation::sum());
152        let expected: i32 = (0..size).map(|k| k + 1).sum();
153        assert_eq!(recv[0], expected, "reduce_scatter_block mismatch");
154    }
155
156    // ---- user-defined operation (sum) matches built-in ----
157    {
158        let op = UserOperation::commutative(|inv: &[i32], inout: &mut [i32]| {
159            for (i, o) in inv.iter().zip(inout.iter_mut()) {
160                *o += *i;
161            }
162        });
163        let mut u = 0i32;
164        world.all_reduce_into(&rank, &mut u, op);
165        assert_eq!(u, (0..size).sum::<i32>(), "user op mismatch");
166    }
167
168    // ---- communicator split by parity ----
169    {
170        let color = mpi::topology::Color::with_value(rank % 2);
171        let sub = world.split_by_color(color).expect("split produced None");
172        let expected_size = (0..size).filter(|r| r % 2 == rank % 2).count() as i32;
173        assert_eq!(sub.size(), expected_size, "split size mismatch");
174        // Ranks in the sub-communicator sum to a known value.
175        let mut s = 0i32;
176        sub.all_reduce_into(&sub.rank(), &mut s, SystemOperation::sum());
177        let expected_sum: i32 = (0..sub.size()).sum();
178        assert_eq!(s, expected_sum, "split all_reduce mismatch");
179    }
180
181    // ---- communicator duplicate ----
182    {
183        let dup = world.duplicate();
184        assert_eq!(dup.size(), size);
185        assert_eq!(dup.rank(), rank);
186        dup.barrier();
187    }
188
189    // ---- group ----
190    {
191        let g = world.group();
192        assert_eq!(g.size(), size, "group size mismatch");
193        assert_eq!(g.rank(), Some(rank), "group rank mismatch");
194    }
195
196    // ---- group set algebra ----
197    {
198        let g = world.group();
199        let evens: Vec<i32> = (0..size).filter(|r| r % 2 == 0).collect();
200        let odds: Vec<i32> = (0..size).filter(|r| r % 2 == 1).collect();
201        let ge = g.include(&evens);
202        let go = g.include(&odds);
203        assert_eq!(ge.size() + go.size(), size, "group split size mismatch");
204        assert_eq!(ge.union(&go).size(), size, "group union mismatch");
205        assert_eq!(
206            ge.intersection(&go).size(),
207            0,
208            "group intersection mismatch"
209        );
210    }
211
212    // ---- varying-count all-gather (allgatherv) ----
213    {
214        let counts: Vec<i32> = (0..size).map(|i| i + 1).collect();
215        let mut displs = vec![0i32; size as usize];
216        for i in 1..size as usize {
217            displs[i] = displs[i - 1] + counts[i - 1];
218        }
219        let total: i32 = counts.iter().sum();
220        let send = vec![rank; (rank + 1) as usize];
221        let mut recvbuf = vec![-1i32; total as usize];
222        {
223            let mut part = PartitionMut::new(&mut recvbuf[..], counts.clone(), displs.clone());
224            world.all_gather_varcount_into(&send[..], &mut part);
225        }
226        for i in 0..size as usize {
227            let start = displs[i] as usize;
228            for k in 0..counts[i] as usize {
229                assert_eq!(recvbuf[start + k], i as i32, "allgatherv mismatch");
230            }
231        }
232    }
233
234    // ---- varying-count all-to-all (alltoallv) ----
235    {
236        let counts: Vec<i32> = vec![1; size as usize];
237        let displs: Vec<i32> = (0..size).collect();
238        let send: Vec<i32> = (0..size).map(|j| rank * 10 + j).collect();
239        let mut recv = vec![-1i32; size as usize];
240        {
241            let sp = Partition::new(&send[..], counts.clone(), displs.clone());
242            let mut rp = PartitionMut::new(&mut recv[..], counts.clone(), displs.clone());
243            world.all_to_all_varcount_into(&sp, &mut rp);
244        }
245        for i in 0..size {
246            assert_eq!(recv[i as usize], i * 10 + rank, "alltoallv mismatch");
247        }
248    }
249
250    // ---- Cartesian topology (1-D periodic ring) ----
251    {
252        let cart = world
253            .create_cartesian_communicator(&[size], &[true], false)
254            .expect("cartesian create returned None");
255        assert_eq!(cart.my_coordinates(), vec![rank], "cart coords mismatch");
256        let (src, dst) = cart.shift(0, 1);
257        assert_eq!(dst, Some((rank + 1) % size), "cart shift dest mismatch");
258        assert_eq!(
259            src,
260            Some((rank - 1 + size) % size),
261            "cart shift source mismatch"
262        );
263        assert_eq!(cart.rank_from_coordinates(&[0]), Some(0));
264        cart.barrier();
265    }
266
267    // ---- error handlers ----
268    {
269        use mpi::error::{class, error_string, ErrorHandler};
270        world.set_error_handler(ErrorHandler::Return);
271        assert_eq!(
272            world.error_handler(),
273            ErrorHandler::Return,
274            "errhandler mismatch"
275        );
276        world.set_error_handler(ErrorHandler::Fatal);
277        assert_eq!(world.error_handler(), ErrorHandler::Fatal);
278        assert!(!error_string(class::TRUNCATE).is_empty());
279    }
280
281    // ---- generalized request (completed from another thread) ----
282    {
283        use mpi::request::GeneralizedRequest;
284        let (req, completer) = GeneralizedRequest::start();
285        let handle = std::thread::spawn(move || completer.complete());
286        let _status = req.wait();
287        handle.join().unwrap();
288    }
289
290    // ---- pack / unpack ----
291    {
292        let val = vec![rank, rank * 2, rank * 3];
293        let packed = world.pack(&val[..]);
294        let mut out = vec![0i32; 3];
295        let pos = unsafe { world.unpack_into(&packed, &mut out[..], 0) };
296        assert_eq!(out, val, "pack/unpack mismatch");
297        assert_eq!(pos as usize, packed.len(), "unpack position mismatch");
298    }
299
300    // ---- communicator naming ----
301    {
302        assert_eq!(world.get_name(), "MPI_COMM_WORLD", "comm name mismatch");
303        let d = world.duplicate();
304        d.set_name("dup");
305        assert_eq!(d.get_name(), "dup", "set/get name mismatch");
306    }
307
308    // ---- non-blocking all-reduce + barrier ----
309    {
310        let send = rank;
311        let mut recv = 0i32;
312        mpi::request::scope(|s| {
313            world
314                .immediate_all_reduce_into(s, &send, &mut recv, SystemOperation::sum())
315                .wait();
316        });
317        assert_eq!(
318            recv,
319            (0..size).sum::<i32>(),
320            "immediate all_reduce mismatch"
321        );
322        world.immediate_barrier().wait();
323    }
324
325    // ---- non-blocking broadcast (Root) ----
326    {
327        let root = world.process_at_rank(0);
328        let mut buf = if rank == 0 {
329            vec![7, 7, 7]
330        } else {
331            vec![0, 0, 0]
332        };
333        mpi::request::scope(|s| {
334            root.immediate_broadcast_into(s, &mut buf[..]).wait();
335        });
336        assert_eq!(buf, vec![7, 7, 7], "immediate broadcast mismatch");
337    }
338
339    // ---- in-place all-reduce (MPI_IN_PLACE) ----
340    {
341        let mut b = vec![rank, rank + 1];
342        world.all_reduce_into_in_place(&mut b[..], SystemOperation::sum());
343        let s: i32 = (0..size).sum();
344        assert_eq!(b, vec![s, s + size], "in-place all_reduce mismatch");
345    }
346
347    // ---- persistent send/receive, reused across iterations ----
348    {
349        let next = (rank + 1) % size;
350        let prev = (rank - 1 + size) % size;
351        let sendbuf = [rank, rank * 2];
352        let mut recvbuf = vec![-1i32; 2];
353        {
354            let mut sreq = world.process_at_rank(next).send_init(&sendbuf[..]);
355            let mut rreq = world.process_at_rank(prev).receive_init(&mut recvbuf[..]);
356            for _ in 0..3 {
357                rreq.start();
358                sreq.start();
359                sreq.wait();
360                rreq.wait();
361            }
362        } // requests dropped -> buffer borrows released
363        assert_eq!(recvbuf, vec![prev, prev * 2], "persistent request mismatch");
364    }
365
366    world.barrier();
367    if rank == 0 {
368        println!("SELFTEST PASS: all checks passed on {size} ranks.");
369    }
370}
Source

pub fn rank_from_coordinates(&self, coords: &[Count]) -> Option<Rank>

The rank at the given coordinates (MPI_Cart_rank). Returns None if a non-periodic coordinate is out of range; periodic coordinates wrap.

Examples found in repository?
examples/selftest.rs (line 263)
11fn main() {
12    let universe = mpi::initialize().unwrap();
13    let world = universe.world();
14    let rank = world.rank();
15    let size = world.size();
16
17    // ---- point-to-point: typed scalar ----
18    if size >= 2 {
19        if rank == 0 {
20            world.process_at_rank(1).send(&42u64);
21        } else if rank == 1 {
22            let (v, status) = world.process_at_rank(0).receive::<u64>();
23            assert_eq!(v, 42);
24            assert_eq!(status.source_rank(), 0);
25        }
26    }
27
28    // ---- point-to-point: vector + probe ----
29    if size >= 2 {
30        if rank == 0 {
31            let data: Vec<i32> = vec![10, 20, 30, 40, 50];
32            world.process_at_rank(1).send(&data[..]);
33        } else if rank == 1 {
34            let status = world.process_at_rank(0).probe();
35            let count = status.count(i32::equivalent_datatype());
36            assert_eq!(count, 5, "probe reported wrong count");
37            let (data, _s) = world.process_at_rank(0).receive_vec::<i32>();
38            assert_eq!(data, vec![10, 20, 30, 40, 50]);
39        }
40    }
41
42    // ---- send_receive ring ----
43    {
44        let next = (rank + 1) % size;
45        let prev = (rank - 1 + size) % size;
46        let (got, _status): (i32, _) = mpi::point_to_point::send_receive(
47            &rank,
48            &world.process_at_rank(next),
49            &world.process_at_rank(prev),
50        );
51        assert_eq!(got, prev, "send_receive ring mismatch");
52    }
53
54    // ---- broadcast ----
55    {
56        let root = world.process_at_rank(0);
57        let mut buf = if rank == 0 {
58            vec![2, 4, 8, 16]
59        } else {
60            vec![0; 4]
61        };
62        root.broadcast_into(&mut buf[..]);
63        assert_eq!(buf, vec![2, 4, 8, 16], "broadcast mismatch");
64    }
65
66    // ---- scatter ----
67    {
68        let root = world.process_at_rank(0);
69        let mut mine = 0i32;
70        if rank == 0 {
71            let send: Vec<i32> = (0..size).collect();
72            root.scatter_into_root(&send[..], &mut mine);
73        } else {
74            root.scatter_into(&mut mine);
75        }
76        assert_eq!(mine, rank, "scatter mismatch");
77    }
78
79    // ---- gather ----
80    {
81        let root = world.process_at_rank(0);
82        if rank == 0 {
83            let mut buf = vec![-1i32; size as usize];
84            root.gather_into_root(&rank, &mut buf[..]);
85            let expected: Vec<i32> = (0..size).collect();
86            assert_eq!(buf, expected, "gather mismatch");
87        } else {
88            root.gather_into(&rank);
89        }
90    }
91
92    // ---- all_gather ----
93    {
94        let mut buf = vec![-1i32; size as usize];
95        world.all_gather_into(&rank, &mut buf[..]);
96        let expected: Vec<i32> = (0..size).collect();
97        assert_eq!(buf, expected, "all_gather mismatch");
98    }
99
100    // ---- all_to_all ----
101    {
102        let send: Vec<i32> = (0..size).map(|j| rank * 100 + j).collect();
103        let mut recv = vec![-1i32; size as usize];
104        world.all_to_all_into(&send[..], &mut recv[..]);
105        for i in 0..size {
106            assert_eq!(recv[i as usize], i * 100 + rank, "all_to_all mismatch");
107        }
108    }
109
110    // ---- reduce to root (sum) ----
111    {
112        let root = world.process_at_rank(0);
113        if rank == 0 {
114            let mut sum = 0i32;
115            root.reduce_into_root(&rank, &mut sum, SystemOperation::sum());
116            assert_eq!(sum, (0..size).sum::<i32>(), "reduce sum mismatch");
117        } else {
118            root.reduce_into(&rank, SystemOperation::sum());
119        }
120    }
121
122    // ---- all_reduce (max) ----
123    {
124        let mut m = 0i32;
125        world.all_reduce_into(&rank, &mut m, SystemOperation::max());
126        assert_eq!(m, size - 1, "all_reduce max mismatch");
127    }
128
129    // ---- inclusive scan ----
130    {
131        let mut acc = 0i32;
132        world.scan_into(&rank, &mut acc, SystemOperation::sum());
133        let expected: i32 = (0..=rank).sum();
134        assert_eq!(acc, expected, "scan mismatch");
135    }
136
137    // ---- exclusive scan ----
138    {
139        let mut acc = -1i32;
140        world.exclusive_scan_into(&rank, &mut acc, SystemOperation::sum());
141        if rank > 0 {
142            let expected: i32 = (0..rank).sum();
143            assert_eq!(acc, expected, "exclusive_scan mismatch");
144        }
145    }
146
147    // ---- reduce_scatter_block ----
148    {
149        let send: Vec<i32> = vec![rank + 1; size as usize];
150        let mut recv = [0i32; 1];
151        world.reduce_scatter_block_into(&send[..], &mut recv[..], SystemOperation::sum());
152        let expected: i32 = (0..size).map(|k| k + 1).sum();
153        assert_eq!(recv[0], expected, "reduce_scatter_block mismatch");
154    }
155
156    // ---- user-defined operation (sum) matches built-in ----
157    {
158        let op = UserOperation::commutative(|inv: &[i32], inout: &mut [i32]| {
159            for (i, o) in inv.iter().zip(inout.iter_mut()) {
160                *o += *i;
161            }
162        });
163        let mut u = 0i32;
164        world.all_reduce_into(&rank, &mut u, op);
165        assert_eq!(u, (0..size).sum::<i32>(), "user op mismatch");
166    }
167
168    // ---- communicator split by parity ----
169    {
170        let color = mpi::topology::Color::with_value(rank % 2);
171        let sub = world.split_by_color(color).expect("split produced None");
172        let expected_size = (0..size).filter(|r| r % 2 == rank % 2).count() as i32;
173        assert_eq!(sub.size(), expected_size, "split size mismatch");
174        // Ranks in the sub-communicator sum to a known value.
175        let mut s = 0i32;
176        sub.all_reduce_into(&sub.rank(), &mut s, SystemOperation::sum());
177        let expected_sum: i32 = (0..sub.size()).sum();
178        assert_eq!(s, expected_sum, "split all_reduce mismatch");
179    }
180
181    // ---- communicator duplicate ----
182    {
183        let dup = world.duplicate();
184        assert_eq!(dup.size(), size);
185        assert_eq!(dup.rank(), rank);
186        dup.barrier();
187    }
188
189    // ---- group ----
190    {
191        let g = world.group();
192        assert_eq!(g.size(), size, "group size mismatch");
193        assert_eq!(g.rank(), Some(rank), "group rank mismatch");
194    }
195
196    // ---- group set algebra ----
197    {
198        let g = world.group();
199        let evens: Vec<i32> = (0..size).filter(|r| r % 2 == 0).collect();
200        let odds: Vec<i32> = (0..size).filter(|r| r % 2 == 1).collect();
201        let ge = g.include(&evens);
202        let go = g.include(&odds);
203        assert_eq!(ge.size() + go.size(), size, "group split size mismatch");
204        assert_eq!(ge.union(&go).size(), size, "group union mismatch");
205        assert_eq!(
206            ge.intersection(&go).size(),
207            0,
208            "group intersection mismatch"
209        );
210    }
211
212    // ---- varying-count all-gather (allgatherv) ----
213    {
214        let counts: Vec<i32> = (0..size).map(|i| i + 1).collect();
215        let mut displs = vec![0i32; size as usize];
216        for i in 1..size as usize {
217            displs[i] = displs[i - 1] + counts[i - 1];
218        }
219        let total: i32 = counts.iter().sum();
220        let send = vec![rank; (rank + 1) as usize];
221        let mut recvbuf = vec![-1i32; total as usize];
222        {
223            let mut part = PartitionMut::new(&mut recvbuf[..], counts.clone(), displs.clone());
224            world.all_gather_varcount_into(&send[..], &mut part);
225        }
226        for i in 0..size as usize {
227            let start = displs[i] as usize;
228            for k in 0..counts[i] as usize {
229                assert_eq!(recvbuf[start + k], i as i32, "allgatherv mismatch");
230            }
231        }
232    }
233
234    // ---- varying-count all-to-all (alltoallv) ----
235    {
236        let counts: Vec<i32> = vec![1; size as usize];
237        let displs: Vec<i32> = (0..size).collect();
238        let send: Vec<i32> = (0..size).map(|j| rank * 10 + j).collect();
239        let mut recv = vec![-1i32; size as usize];
240        {
241            let sp = Partition::new(&send[..], counts.clone(), displs.clone());
242            let mut rp = PartitionMut::new(&mut recv[..], counts.clone(), displs.clone());
243            world.all_to_all_varcount_into(&sp, &mut rp);
244        }
245        for i in 0..size {
246            assert_eq!(recv[i as usize], i * 10 + rank, "alltoallv mismatch");
247        }
248    }
249
250    // ---- Cartesian topology (1-D periodic ring) ----
251    {
252        let cart = world
253            .create_cartesian_communicator(&[size], &[true], false)
254            .expect("cartesian create returned None");
255        assert_eq!(cart.my_coordinates(), vec![rank], "cart coords mismatch");
256        let (src, dst) = cart.shift(0, 1);
257        assert_eq!(dst, Some((rank + 1) % size), "cart shift dest mismatch");
258        assert_eq!(
259            src,
260            Some((rank - 1 + size) % size),
261            "cart shift source mismatch"
262        );
263        assert_eq!(cart.rank_from_coordinates(&[0]), Some(0));
264        cart.barrier();
265    }
266
267    // ---- error handlers ----
268    {
269        use mpi::error::{class, error_string, ErrorHandler};
270        world.set_error_handler(ErrorHandler::Return);
271        assert_eq!(
272            world.error_handler(),
273            ErrorHandler::Return,
274            "errhandler mismatch"
275        );
276        world.set_error_handler(ErrorHandler::Fatal);
277        assert_eq!(world.error_handler(), ErrorHandler::Fatal);
278        assert!(!error_string(class::TRUNCATE).is_empty());
279    }
280
281    // ---- generalized request (completed from another thread) ----
282    {
283        use mpi::request::GeneralizedRequest;
284        let (req, completer) = GeneralizedRequest::start();
285        let handle = std::thread::spawn(move || completer.complete());
286        let _status = req.wait();
287        handle.join().unwrap();
288    }
289
290    // ---- pack / unpack ----
291    {
292        let val = vec![rank, rank * 2, rank * 3];
293        let packed = world.pack(&val[..]);
294        let mut out = vec![0i32; 3];
295        let pos = unsafe { world.unpack_into(&packed, &mut out[..], 0) };
296        assert_eq!(out, val, "pack/unpack mismatch");
297        assert_eq!(pos as usize, packed.len(), "unpack position mismatch");
298    }
299
300    // ---- communicator naming ----
301    {
302        assert_eq!(world.get_name(), "MPI_COMM_WORLD", "comm name mismatch");
303        let d = world.duplicate();
304        d.set_name("dup");
305        assert_eq!(d.get_name(), "dup", "set/get name mismatch");
306    }
307
308    // ---- non-blocking all-reduce + barrier ----
309    {
310        let send = rank;
311        let mut recv = 0i32;
312        mpi::request::scope(|s| {
313            world
314                .immediate_all_reduce_into(s, &send, &mut recv, SystemOperation::sum())
315                .wait();
316        });
317        assert_eq!(
318            recv,
319            (0..size).sum::<i32>(),
320            "immediate all_reduce mismatch"
321        );
322        world.immediate_barrier().wait();
323    }
324
325    // ---- non-blocking broadcast (Root) ----
326    {
327        let root = world.process_at_rank(0);
328        let mut buf = if rank == 0 {
329            vec![7, 7, 7]
330        } else {
331            vec![0, 0, 0]
332        };
333        mpi::request::scope(|s| {
334            root.immediate_broadcast_into(s, &mut buf[..]).wait();
335        });
336        assert_eq!(buf, vec![7, 7, 7], "immediate broadcast mismatch");
337    }
338
339    // ---- in-place all-reduce (MPI_IN_PLACE) ----
340    {
341        let mut b = vec![rank, rank + 1];
342        world.all_reduce_into_in_place(&mut b[..], SystemOperation::sum());
343        let s: i32 = (0..size).sum();
344        assert_eq!(b, vec![s, s + size], "in-place all_reduce mismatch");
345    }
346
347    // ---- persistent send/receive, reused across iterations ----
348    {
349        let next = (rank + 1) % size;
350        let prev = (rank - 1 + size) % size;
351        let sendbuf = [rank, rank * 2];
352        let mut recvbuf = vec![-1i32; 2];
353        {
354            let mut sreq = world.process_at_rank(next).send_init(&sendbuf[..]);
355            let mut rreq = world.process_at_rank(prev).receive_init(&mut recvbuf[..]);
356            for _ in 0..3 {
357                rreq.start();
358                sreq.start();
359                sreq.wait();
360                rreq.wait();
361            }
362        } // requests dropped -> buffer borrows released
363        assert_eq!(recvbuf, vec![prev, prev * 2], "persistent request mismatch");
364    }
365
366    world.barrier();
367    if rank == 0 {
368        println!("SELFTEST PASS: all checks passed on {size} ranks.");
369    }
370}
Source

pub fn shift( &self, direction: usize, disp: Count, ) -> (Option<Rank>, Option<Rank>)

Compute the source and destination ranks for a shift along direction by disp steps (MPI_Cart_shift). Returns (source, dest), either of which is None at a non-periodic boundary.

Examples found in repository?
examples/selftest.rs (line 256)
11fn main() {
12    let universe = mpi::initialize().unwrap();
13    let world = universe.world();
14    let rank = world.rank();
15    let size = world.size();
16
17    // ---- point-to-point: typed scalar ----
18    if size >= 2 {
19        if rank == 0 {
20            world.process_at_rank(1).send(&42u64);
21        } else if rank == 1 {
22            let (v, status) = world.process_at_rank(0).receive::<u64>();
23            assert_eq!(v, 42);
24            assert_eq!(status.source_rank(), 0);
25        }
26    }
27
28    // ---- point-to-point: vector + probe ----
29    if size >= 2 {
30        if rank == 0 {
31            let data: Vec<i32> = vec![10, 20, 30, 40, 50];
32            world.process_at_rank(1).send(&data[..]);
33        } else if rank == 1 {
34            let status = world.process_at_rank(0).probe();
35            let count = status.count(i32::equivalent_datatype());
36            assert_eq!(count, 5, "probe reported wrong count");
37            let (data, _s) = world.process_at_rank(0).receive_vec::<i32>();
38            assert_eq!(data, vec![10, 20, 30, 40, 50]);
39        }
40    }
41
42    // ---- send_receive ring ----
43    {
44        let next = (rank + 1) % size;
45        let prev = (rank - 1 + size) % size;
46        let (got, _status): (i32, _) = mpi::point_to_point::send_receive(
47            &rank,
48            &world.process_at_rank(next),
49            &world.process_at_rank(prev),
50        );
51        assert_eq!(got, prev, "send_receive ring mismatch");
52    }
53
54    // ---- broadcast ----
55    {
56        let root = world.process_at_rank(0);
57        let mut buf = if rank == 0 {
58            vec![2, 4, 8, 16]
59        } else {
60            vec![0; 4]
61        };
62        root.broadcast_into(&mut buf[..]);
63        assert_eq!(buf, vec![2, 4, 8, 16], "broadcast mismatch");
64    }
65
66    // ---- scatter ----
67    {
68        let root = world.process_at_rank(0);
69        let mut mine = 0i32;
70        if rank == 0 {
71            let send: Vec<i32> = (0..size).collect();
72            root.scatter_into_root(&send[..], &mut mine);
73        } else {
74            root.scatter_into(&mut mine);
75        }
76        assert_eq!(mine, rank, "scatter mismatch");
77    }
78
79    // ---- gather ----
80    {
81        let root = world.process_at_rank(0);
82        if rank == 0 {
83            let mut buf = vec![-1i32; size as usize];
84            root.gather_into_root(&rank, &mut buf[..]);
85            let expected: Vec<i32> = (0..size).collect();
86            assert_eq!(buf, expected, "gather mismatch");
87        } else {
88            root.gather_into(&rank);
89        }
90    }
91
92    // ---- all_gather ----
93    {
94        let mut buf = vec![-1i32; size as usize];
95        world.all_gather_into(&rank, &mut buf[..]);
96        let expected: Vec<i32> = (0..size).collect();
97        assert_eq!(buf, expected, "all_gather mismatch");
98    }
99
100    // ---- all_to_all ----
101    {
102        let send: Vec<i32> = (0..size).map(|j| rank * 100 + j).collect();
103        let mut recv = vec![-1i32; size as usize];
104        world.all_to_all_into(&send[..], &mut recv[..]);
105        for i in 0..size {
106            assert_eq!(recv[i as usize], i * 100 + rank, "all_to_all mismatch");
107        }
108    }
109
110    // ---- reduce to root (sum) ----
111    {
112        let root = world.process_at_rank(0);
113        if rank == 0 {
114            let mut sum = 0i32;
115            root.reduce_into_root(&rank, &mut sum, SystemOperation::sum());
116            assert_eq!(sum, (0..size).sum::<i32>(), "reduce sum mismatch");
117        } else {
118            root.reduce_into(&rank, SystemOperation::sum());
119        }
120    }
121
122    // ---- all_reduce (max) ----
123    {
124        let mut m = 0i32;
125        world.all_reduce_into(&rank, &mut m, SystemOperation::max());
126        assert_eq!(m, size - 1, "all_reduce max mismatch");
127    }
128
129    // ---- inclusive scan ----
130    {
131        let mut acc = 0i32;
132        world.scan_into(&rank, &mut acc, SystemOperation::sum());
133        let expected: i32 = (0..=rank).sum();
134        assert_eq!(acc, expected, "scan mismatch");
135    }
136
137    // ---- exclusive scan ----
138    {
139        let mut acc = -1i32;
140        world.exclusive_scan_into(&rank, &mut acc, SystemOperation::sum());
141        if rank > 0 {
142            let expected: i32 = (0..rank).sum();
143            assert_eq!(acc, expected, "exclusive_scan mismatch");
144        }
145    }
146
147    // ---- reduce_scatter_block ----
148    {
149        let send: Vec<i32> = vec![rank + 1; size as usize];
150        let mut recv = [0i32; 1];
151        world.reduce_scatter_block_into(&send[..], &mut recv[..], SystemOperation::sum());
152        let expected: i32 = (0..size).map(|k| k + 1).sum();
153        assert_eq!(recv[0], expected, "reduce_scatter_block mismatch");
154    }
155
156    // ---- user-defined operation (sum) matches built-in ----
157    {
158        let op = UserOperation::commutative(|inv: &[i32], inout: &mut [i32]| {
159            for (i, o) in inv.iter().zip(inout.iter_mut()) {
160                *o += *i;
161            }
162        });
163        let mut u = 0i32;
164        world.all_reduce_into(&rank, &mut u, op);
165        assert_eq!(u, (0..size).sum::<i32>(), "user op mismatch");
166    }
167
168    // ---- communicator split by parity ----
169    {
170        let color = mpi::topology::Color::with_value(rank % 2);
171        let sub = world.split_by_color(color).expect("split produced None");
172        let expected_size = (0..size).filter(|r| r % 2 == rank % 2).count() as i32;
173        assert_eq!(sub.size(), expected_size, "split size mismatch");
174        // Ranks in the sub-communicator sum to a known value.
175        let mut s = 0i32;
176        sub.all_reduce_into(&sub.rank(), &mut s, SystemOperation::sum());
177        let expected_sum: i32 = (0..sub.size()).sum();
178        assert_eq!(s, expected_sum, "split all_reduce mismatch");
179    }
180
181    // ---- communicator duplicate ----
182    {
183        let dup = world.duplicate();
184        assert_eq!(dup.size(), size);
185        assert_eq!(dup.rank(), rank);
186        dup.barrier();
187    }
188
189    // ---- group ----
190    {
191        let g = world.group();
192        assert_eq!(g.size(), size, "group size mismatch");
193        assert_eq!(g.rank(), Some(rank), "group rank mismatch");
194    }
195
196    // ---- group set algebra ----
197    {
198        let g = world.group();
199        let evens: Vec<i32> = (0..size).filter(|r| r % 2 == 0).collect();
200        let odds: Vec<i32> = (0..size).filter(|r| r % 2 == 1).collect();
201        let ge = g.include(&evens);
202        let go = g.include(&odds);
203        assert_eq!(ge.size() + go.size(), size, "group split size mismatch");
204        assert_eq!(ge.union(&go).size(), size, "group union mismatch");
205        assert_eq!(
206            ge.intersection(&go).size(),
207            0,
208            "group intersection mismatch"
209        );
210    }
211
212    // ---- varying-count all-gather (allgatherv) ----
213    {
214        let counts: Vec<i32> = (0..size).map(|i| i + 1).collect();
215        let mut displs = vec![0i32; size as usize];
216        for i in 1..size as usize {
217            displs[i] = displs[i - 1] + counts[i - 1];
218        }
219        let total: i32 = counts.iter().sum();
220        let send = vec![rank; (rank + 1) as usize];
221        let mut recvbuf = vec![-1i32; total as usize];
222        {
223            let mut part = PartitionMut::new(&mut recvbuf[..], counts.clone(), displs.clone());
224            world.all_gather_varcount_into(&send[..], &mut part);
225        }
226        for i in 0..size as usize {
227            let start = displs[i] as usize;
228            for k in 0..counts[i] as usize {
229                assert_eq!(recvbuf[start + k], i as i32, "allgatherv mismatch");
230            }
231        }
232    }
233
234    // ---- varying-count all-to-all (alltoallv) ----
235    {
236        let counts: Vec<i32> = vec![1; size as usize];
237        let displs: Vec<i32> = (0..size).collect();
238        let send: Vec<i32> = (0..size).map(|j| rank * 10 + j).collect();
239        let mut recv = vec![-1i32; size as usize];
240        {
241            let sp = Partition::new(&send[..], counts.clone(), displs.clone());
242            let mut rp = PartitionMut::new(&mut recv[..], counts.clone(), displs.clone());
243            world.all_to_all_varcount_into(&sp, &mut rp);
244        }
245        for i in 0..size {
246            assert_eq!(recv[i as usize], i * 10 + rank, "alltoallv mismatch");
247        }
248    }
249
250    // ---- Cartesian topology (1-D periodic ring) ----
251    {
252        let cart = world
253            .create_cartesian_communicator(&[size], &[true], false)
254            .expect("cartesian create returned None");
255        assert_eq!(cart.my_coordinates(), vec![rank], "cart coords mismatch");
256        let (src, dst) = cart.shift(0, 1);
257        assert_eq!(dst, Some((rank + 1) % size), "cart shift dest mismatch");
258        assert_eq!(
259            src,
260            Some((rank - 1 + size) % size),
261            "cart shift source mismatch"
262        );
263        assert_eq!(cart.rank_from_coordinates(&[0]), Some(0));
264        cart.barrier();
265    }
266
267    // ---- error handlers ----
268    {
269        use mpi::error::{class, error_string, ErrorHandler};
270        world.set_error_handler(ErrorHandler::Return);
271        assert_eq!(
272            world.error_handler(),
273            ErrorHandler::Return,
274            "errhandler mismatch"
275        );
276        world.set_error_handler(ErrorHandler::Fatal);
277        assert_eq!(world.error_handler(), ErrorHandler::Fatal);
278        assert!(!error_string(class::TRUNCATE).is_empty());
279    }
280
281    // ---- generalized request (completed from another thread) ----
282    {
283        use mpi::request::GeneralizedRequest;
284        let (req, completer) = GeneralizedRequest::start();
285        let handle = std::thread::spawn(move || completer.complete());
286        let _status = req.wait();
287        handle.join().unwrap();
288    }
289
290    // ---- pack / unpack ----
291    {
292        let val = vec![rank, rank * 2, rank * 3];
293        let packed = world.pack(&val[..]);
294        let mut out = vec![0i32; 3];
295        let pos = unsafe { world.unpack_into(&packed, &mut out[..], 0) };
296        assert_eq!(out, val, "pack/unpack mismatch");
297        assert_eq!(pos as usize, packed.len(), "unpack position mismatch");
298    }
299
300    // ---- communicator naming ----
301    {
302        assert_eq!(world.get_name(), "MPI_COMM_WORLD", "comm name mismatch");
303        let d = world.duplicate();
304        d.set_name("dup");
305        assert_eq!(d.get_name(), "dup", "set/get name mismatch");
306    }
307
308    // ---- non-blocking all-reduce + barrier ----
309    {
310        let send = rank;
311        let mut recv = 0i32;
312        mpi::request::scope(|s| {
313            world
314                .immediate_all_reduce_into(s, &send, &mut recv, SystemOperation::sum())
315                .wait();
316        });
317        assert_eq!(
318            recv,
319            (0..size).sum::<i32>(),
320            "immediate all_reduce mismatch"
321        );
322        world.immediate_barrier().wait();
323    }
324
325    // ---- non-blocking broadcast (Root) ----
326    {
327        let root = world.process_at_rank(0);
328        let mut buf = if rank == 0 {
329            vec![7, 7, 7]
330        } else {
331            vec![0, 0, 0]
332        };
333        mpi::request::scope(|s| {
334            root.immediate_broadcast_into(s, &mut buf[..]).wait();
335        });
336        assert_eq!(buf, vec![7, 7, 7], "immediate broadcast mismatch");
337    }
338
339    // ---- in-place all-reduce (MPI_IN_PLACE) ----
340    {
341        let mut b = vec![rank, rank + 1];
342        world.all_reduce_into_in_place(&mut b[..], SystemOperation::sum());
343        let s: i32 = (0..size).sum();
344        assert_eq!(b, vec![s, s + size], "in-place all_reduce mismatch");
345    }
346
347    // ---- persistent send/receive, reused across iterations ----
348    {
349        let next = (rank + 1) % size;
350        let prev = (rank - 1 + size) % size;
351        let sendbuf = [rank, rank * 2];
352        let mut recvbuf = vec![-1i32; 2];
353        {
354            let mut sreq = world.process_at_rank(next).send_init(&sendbuf[..]);
355            let mut rreq = world.process_at_rank(prev).receive_init(&mut recvbuf[..]);
356            for _ in 0..3 {
357                rreq.start();
358                sreq.start();
359                sreq.wait();
360                rreq.wait();
361            }
362        } // requests dropped -> buffer borrows released
363        assert_eq!(recvbuf, vec![prev, prev * 2], "persistent request mismatch");
364    }
365
366    world.barrier();
367    if rank == 0 {
368        println!("SELFTEST PASS: all checks passed on {size} ranks.");
369    }
370}

Trait Implementations§

Source§

impl Clone for CartesianCommunicator

Source§

fn clone(&self) -> CartesianCommunicator

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Communicator for CartesianCommunicator

Source§

fn size(&self) -> Rank

Number of processes in the communicator (MPI_Comm_size).
Source§

fn rank(&self) -> Rank

This process’s rank in the communicator (MPI_Comm_rank).
Source§

fn target_size(&self) -> Rank

Number of processes on the remote side (equals Communicator::size for an intra-communicator).
Source§

fn process_at_rank(&self, r: Rank) -> Process<'_>

A handle to the process with the given rank.
Source§

fn this_process(&self) -> Process<'_>

A handle to this process.
Source§

fn any_process(&self) -> AnyProcess<'_>

A handle matching any source (MPI_ANY_SOURCE), for receives.
Source§

fn group(&self) -> Group

The group underlying this communicator (MPI_Comm_group).
Source§

fn compare(&self, other: &dyn Communicator) -> CommunicatorRelation

Compare this communicator to other (MPI_Comm_compare).
Source§

fn duplicate(&self) -> SimpleCommunicator

Duplicate the communicator with a fresh context (MPI_Comm_dup). Collective over all members.
Source§

fn split_by_color(&self, color: Color) -> Option<SimpleCommunicator>

Split the communicator by colour (MPI_Comm_split). Collective.
Source§

fn split_by_color_with_key( &self, color: Color, key: Key, ) -> Option<SimpleCommunicator>

Split by colour, ordering new ranks by key then old rank (MPI_Comm_split). Collective.
Source§

fn split_by_subgroup(&self, group: &Group) -> Option<SimpleCommunicator>

Split by an explicit subgroup (MPI_Comm_create style). Collective; returns None for processes not in group.
Source§

fn abort(&self, errorcode: i32) -> !

Abort the whole job with an exit code (MPI_Abort). Notifies every peer so the entire job exits rather than leaving ranks blocked.
Source§

fn set_name(&self, name: &str)

Set the communicator’s name (MPI_Comm_set_name).
Source§

fn get_name(&self) -> String

Get the communicator’s name (MPI_Comm_get_name).
Source§

fn pack_size(&self, incount: Count, dt: DatatypeRef) -> Count

Number of bytes needed to pack incount elements of datatype dt (MPI_Pack_size).
Source§

fn pack<Buf: Buffer + ?Sized>(&self, inbuf: &Buf) -> Vec<u8>
where Self: Sized,

Pack a buffer into a freshly allocated byte vector (MPI_Pack). Since this implementation uses contiguous native layouts, packing is a copy.
Source§

fn pack_into<Buf: Buffer + ?Sized>( &self, inbuf: &Buf, outbuf: &mut [u8], position: Count, ) -> Count
where Self: Sized,

Pack a buffer into outbuf starting at byte offset position, returning the new position (MPI_Pack).
Source§

unsafe fn unpack_into<Buf: BufferMut + ?Sized>( &self, inbuf: &[u8], outbuf: &mut Buf, position: Count, ) -> Count
where Self: Sized,

Unpack from inbuf starting at byte offset position into outbuf, returning the new position (MPI_Unpack). Read more
Source§

fn create_graph_communicator( &self, index: &[Count], edges: &[Count], ) -> Option<GraphCommunicator>

Create a graph topology communicator (MPI_Graph_create). Read more
Source§

fn create_dist_graph_adjacent( &self, sources: &[Rank], destinations: &[Rank], ) -> DistGraphCommunicator

Create a distributed-graph topology where this rank receives from sources and sends to destinations (MPI_Dist_graph_create_adjacent). Collective; each rank supplies its own adjacency.
Source§

fn split_intercommunicator(&self, in_group_a: bool) -> InterCommunicator

Collectively split this communicator into an inter-communicator between two disjoint groups. Ranks passing true form one group (“A”); the rest form the other. Each rank’s InterCommunicator has the other group as its remote group (MPI_Intercomm_create-style, collective).
Source§

fn create_cartesian_communicator( &self, dims: &[Count], periods: &[bool], _reorder: bool, ) -> Option<CartesianCommunicator>

Create a Cartesian topology communicator (MPI_Cart_create). Read more
Source§

fn parent(&self) -> Option<InterCommunicator>

If this process was created by crate::collective::Root::spawn, return the inter-communicator to the parent group (MPI_Comm_get_parent). The local group is this world; the remote group is the spawner.

Auto Trait Implementations§

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<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<C> CommunicatorAttributes for C
where C: Communicator + ?Sized,

Source§

fn set_attr<T: Any + Send + Sync>(&self, key: &CommKeyval, value: T)

Cache value under key on this communicator (MPI_Comm_set_attr).
Source§

fn get_attr<T: Any + Clone>(&self, key: &CommKeyval) -> Option<T>

Retrieve a clone of the attribute cached under key (MPI_Comm_get_attr), if present and of type T.
Source§

fn has_attr(&self, key: &CommKeyval) -> bool

Whether an attribute is cached under key.
Source§

fn delete_attr(&self, key: &CommKeyval)

Remove the attribute cached under key (MPI_Comm_delete_attr).
Source§

impl<C> CommunicatorCollectives for C
where C: Communicator + ?Sized,

Source§

fn barrier(&self)

Barrier synchronization (MPI_Barrier).
Source§

fn try_barrier(&self) -> Result<(), MpiError>

Fallible barrier.
Source§

fn all_gather_into<S, R>(&self, sendbuf: &S, recvbuf: &mut R)
where S: Buffer + ?Sized, R: BufferMut + ?Sized,

Gather equal-sized contributions from all ranks to all ranks (MPI_Allgather).
Source§

fn try_all_gather_into<S, R>( &self, sendbuf: &S, recvbuf: &mut R, ) -> Result<(), MpiError>
where S: Buffer + ?Sized, R: BufferMut + ?Sized,

Fallible all_gather_into.
Source§

fn all_to_all_into<S, R>(&self, sendbuf: &S, recvbuf: &mut R)
where S: Buffer + ?Sized, R: BufferMut + ?Sized,

All-to-all scatter/gather with equal block sizes (MPI_Alltoall).
Source§

fn try_all_to_all_into<S, R>( &self, sendbuf: &S, recvbuf: &mut R, ) -> Result<(), MpiError>
where S: Buffer + ?Sized, R: BufferMut + ?Sized,

Fallible all_to_all_into.
Source§

fn all_reduce_into<S, R, O>(&self, sendbuf: &S, recvbuf: &mut R, op: O)
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Reduce contributions from all ranks and make the result available on all ranks (MPI_Allreduce).
Source§

fn try_all_reduce_into<S, R, O>( &self, sendbuf: &S, recvbuf: &mut R, op: O, ) -> Result<(), MpiError>
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Fallible all_reduce_into.
Source§

fn all_reduce_into_in_place<R, O>(&self, buf: &mut R, op: O)
where R: BufferMut + ?Sized, O: Operation,

In-place all-reduce: buf is both the input and the output (MPI_Allreduce with MPI_IN_PLACE).
Source§

fn all_gather_into_in_place<R>(&self, buf: &mut R)
where R: BufferMut + ?Sized,

In-place all-gather: buf holds this rank’s block at slot rank on entry and every rank’s block on return (MPI_Allgather with MPI_IN_PLACE).
Source§

fn reduce_scatter_block_into<S, R, O>( &self, sendbuf: &S, recvbuf: &mut R, op: O, )
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Reduce, then scatter equal-sized blocks of the result (MPI_Reduce_scatter_block).
Source§

fn scan_into<S, R, O>(&self, sendbuf: &S, recvbuf: &mut R, op: O)
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Inclusive prefix reduction (MPI_Scan).
Source§

fn try_scan_into<S, R, O>( &self, sendbuf: &S, recvbuf: &mut R, op: O, ) -> Result<(), MpiError>
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Fallible scan_into.
Source§

fn exclusive_scan_into<S, R, O>(&self, sendbuf: &S, recvbuf: &mut R, op: O)
where S: Buffer + ?Sized, R: BufferMut + ?Sized, O: Operation,

Exclusive prefix reduction (MPI_Exscan).
Source§

fn all_gather_varcount_into<S, R>(&self, sendbuf: &S, recvbuf: &mut R)

Varying-count all-gather (MPI_Allgatherv).
Source§

fn all_to_all_varcount_into<S, R>(&self, sendbuf: &S, recvbuf: &mut R)

Varying-count all-to-all (MPI_Alltoallv): rank i sends its j-th block to rank j, with per-peer counts and displacements on both sides.
Source§

fn immediate_barrier(&self) -> Request<'static, ()>

Non-blocking barrier (MPI_Ibarrier). Progresses on a background thread using a fresh context, so it genuinely overlaps subsequent work; wait joins it.
Source§

fn immediate_all_gather_into<'a, S, R, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, Sc: Scope<'a>,

Non-blocking all-gather (MPI_Iallgather).
Source§

fn immediate_all_to_all_into<'a, S, R, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, Sc: Scope<'a>,

Non-blocking all-to-all (MPI_Ialltoall).
Source§

fn immediate_all_reduce_into<'a, S, R, O, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, op: O, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, O: Operation + Send + 'static, Sc: Scope<'a>,

Non-blocking all-reduce (MPI_Iallreduce). Progresses on a background thread using a fresh context so it overlaps computation; wait joins it.
Source§

fn immediate_scan_into<'a, S, R, O, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, op: O, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, O: Operation, Sc: Scope<'a>,

Non-blocking inclusive scan (MPI_Iscan).
Source§

fn immediate_exclusive_scan_into<'a, S, R, O, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, op: O, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, O: Operation, Sc: Scope<'a>,

Non-blocking exclusive scan (MPI_Iexscan).
Source§

fn immediate_reduce_scatter_block_into<'a, S, R, O, Sc>( &self, scope: Sc, sendbuf: &'a S, recvbuf: &'a mut R, op: O, ) -> Request<'a, R, Sc>
where S: 'a + Buffer + ?Sized, R: 'a + BufferMut + ?Sized, O: Operation, Sc: Scope<'a>,

Non-blocking reduce-scatter-block (MPI_Ireduce_scatter_block).
Source§

impl<C> CommunicatorErrorHandler for C
where C: Communicator + ?Sized,

Source§

fn set_error_handler(&self, handler: ErrorHandler)

Set this communicator’s error handler (MPI_Comm_set_errhandler).
Source§

fn error_handler(&self) -> ErrorHandler

Get this communicator’s error handler (MPI_Comm_get_errhandler). Defaults to ErrorHandler::Fatal.
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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.