1 | // -*- c++ -*- |
---|
2 | // |
---|
3 | // Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
---|
4 | // University Research and Technology |
---|
5 | // Corporation. All rights reserved. |
---|
6 | // Copyright (c) 2004-2005 The University of Tennessee and The University |
---|
7 | // of Tennessee Research Foundation. All rights |
---|
8 | // reserved. |
---|
9 | // Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
---|
10 | // University of Stuttgart. All rights reserved. |
---|
11 | // Copyright (c) 2004-2005 The Regents of the University of California. |
---|
12 | // All rights reserved. |
---|
13 | // Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved. |
---|
14 | // $COPYRIGHT$ |
---|
15 | // |
---|
16 | // Additional copyrights may follow |
---|
17 | // |
---|
18 | // $HEADER$ |
---|
19 | // |
---|
20 | |
---|
21 | // |
---|
22 | // Point-to-Point |
---|
23 | // |
---|
24 | |
---|
25 | inline void |
---|
26 | MPI::Comm::Send(const void *buf, int count, |
---|
27 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
28 | { |
---|
29 | (void)MPI_Send(const_cast<void *>(buf), count, datatype, dest, tag, mpi_comm); |
---|
30 | } |
---|
31 | |
---|
32 | inline void |
---|
33 | MPI::Comm::Recv(void *buf, int count, const MPI::Datatype & datatype, |
---|
34 | int source, int tag, MPI::Status & status) const |
---|
35 | { |
---|
36 | (void)MPI_Recv(buf, count, datatype, source, tag, mpi_comm, &status.mpi_status); |
---|
37 | } |
---|
38 | |
---|
39 | inline void |
---|
40 | MPI::Comm::Recv(void *buf, int count, const MPI::Datatype & datatype, |
---|
41 | int source, int tag) const |
---|
42 | { |
---|
43 | (void)MPI_Recv(buf, count, datatype, source, |
---|
44 | tag, mpi_comm, MPI_STATUS_IGNORE); |
---|
45 | } |
---|
46 | |
---|
47 | inline void |
---|
48 | MPI::Comm::Bsend(const void *buf, int count, |
---|
49 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
50 | { |
---|
51 | (void)MPI_Bsend(const_cast<void *>(buf), count, datatype, |
---|
52 | dest, tag, mpi_comm); |
---|
53 | } |
---|
54 | |
---|
55 | inline void |
---|
56 | MPI::Comm::Ssend(const void *buf, int count, |
---|
57 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
58 | { |
---|
59 | (void)MPI_Ssend(const_cast<void *>(buf), count, datatype, dest, |
---|
60 | tag, mpi_comm); |
---|
61 | } |
---|
62 | |
---|
63 | inline void |
---|
64 | MPI::Comm::Rsend(const void *buf, int count, |
---|
65 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
66 | { |
---|
67 | (void)MPI_Rsend(const_cast<void *>(buf), count, datatype, |
---|
68 | dest, tag, mpi_comm); |
---|
69 | } |
---|
70 | |
---|
71 | inline MPI::Request |
---|
72 | MPI::Comm::Isend(const void *buf, int count, |
---|
73 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
74 | { |
---|
75 | MPI_Request request; |
---|
76 | (void)MPI_Isend(const_cast<void *>(buf), count, datatype, |
---|
77 | dest, tag, mpi_comm, &request); |
---|
78 | return request; |
---|
79 | } |
---|
80 | |
---|
81 | inline MPI::Request |
---|
82 | MPI::Comm::Ibsend(const void *buf, int count, |
---|
83 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
84 | { |
---|
85 | MPI_Request request; |
---|
86 | (void)MPI_Ibsend(const_cast<void *>(buf), count, datatype, |
---|
87 | dest, tag, mpi_comm, &request); |
---|
88 | return request; |
---|
89 | } |
---|
90 | |
---|
91 | inline MPI::Request |
---|
92 | MPI::Comm::Issend(const void *buf, int count, |
---|
93 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
94 | { |
---|
95 | MPI_Request request; |
---|
96 | (void)MPI_Issend(const_cast<void *>(buf), count, datatype, |
---|
97 | dest, tag, mpi_comm, &request); |
---|
98 | return request; |
---|
99 | } |
---|
100 | |
---|
101 | inline MPI::Request |
---|
102 | MPI::Comm::Irsend(const void *buf, int count, |
---|
103 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
104 | { |
---|
105 | MPI_Request request; |
---|
106 | (void)MPI_Irsend(const_cast<void *>(buf), count, datatype, |
---|
107 | dest, tag, mpi_comm, &request); |
---|
108 | return request; |
---|
109 | } |
---|
110 | |
---|
111 | inline MPI::Request |
---|
112 | MPI::Comm::Irecv(void *buf, int count, |
---|
113 | const MPI::Datatype & datatype, int source, int tag) const |
---|
114 | { |
---|
115 | MPI_Request request; |
---|
116 | (void)MPI_Irecv(buf, count, datatype, source, |
---|
117 | tag, mpi_comm, &request); |
---|
118 | return request; |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | inline bool |
---|
123 | MPI::Comm::Iprobe(int source, int tag, MPI::Status & status) const |
---|
124 | { |
---|
125 | int t; |
---|
126 | (void)MPI_Iprobe(source, tag, mpi_comm, &t, &status.mpi_status); |
---|
127 | return OPAL_INT_TO_BOOL(t); |
---|
128 | } |
---|
129 | |
---|
130 | inline bool |
---|
131 | MPI::Comm::Iprobe(int source, int tag) const |
---|
132 | { |
---|
133 | int t; |
---|
134 | (void)MPI_Iprobe(source, tag, mpi_comm, &t, MPI_STATUS_IGNORE); |
---|
135 | return OPAL_INT_TO_BOOL(t); |
---|
136 | } |
---|
137 | |
---|
138 | inline void |
---|
139 | MPI::Comm::Probe(int source, int tag, MPI::Status & status) const |
---|
140 | { |
---|
141 | (void)MPI_Probe(source, tag, mpi_comm, &status.mpi_status); |
---|
142 | } |
---|
143 | |
---|
144 | inline void |
---|
145 | MPI::Comm::Probe(int source, int tag) const |
---|
146 | { |
---|
147 | (void)MPI_Probe(source, tag, mpi_comm, MPI_STATUS_IGNORE); |
---|
148 | } |
---|
149 | |
---|
150 | inline MPI::Prequest |
---|
151 | MPI::Comm::Send_init(const void *buf, int count, |
---|
152 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
153 | { |
---|
154 | MPI_Request request; |
---|
155 | (void)MPI_Send_init(const_cast<void *>(buf), count, datatype, |
---|
156 | dest, tag, mpi_comm, &request); |
---|
157 | return request; |
---|
158 | } |
---|
159 | |
---|
160 | inline MPI::Prequest |
---|
161 | MPI::Comm::Bsend_init(const void *buf, int count, |
---|
162 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
163 | { |
---|
164 | MPI_Request request; |
---|
165 | (void)MPI_Bsend_init(const_cast<void *>(buf), count, datatype, |
---|
166 | dest, tag, mpi_comm, &request); |
---|
167 | return request; |
---|
168 | } |
---|
169 | |
---|
170 | inline MPI::Prequest |
---|
171 | MPI::Comm::Ssend_init(const void *buf, int count, |
---|
172 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
173 | { |
---|
174 | MPI_Request request; |
---|
175 | (void)MPI_Ssend_init(const_cast<void *>(buf), count, datatype, |
---|
176 | dest, tag, mpi_comm, &request); |
---|
177 | return request; |
---|
178 | } |
---|
179 | |
---|
180 | inline MPI::Prequest |
---|
181 | MPI::Comm::Rsend_init(const void *buf, int count, |
---|
182 | const MPI::Datatype & datatype, int dest, int tag) const |
---|
183 | { |
---|
184 | MPI_Request request; |
---|
185 | (void)MPI_Rsend_init(const_cast<void *>(buf), count, datatype, |
---|
186 | dest, tag, mpi_comm, &request); |
---|
187 | return request; |
---|
188 | } |
---|
189 | |
---|
190 | inline MPI::Prequest |
---|
191 | MPI::Comm::Recv_init(void *buf, int count, |
---|
192 | const MPI::Datatype & datatype, int source, int tag) const |
---|
193 | { |
---|
194 | MPI_Request request; |
---|
195 | (void)MPI_Recv_init(buf, count, datatype, source, |
---|
196 | tag, mpi_comm, &request); |
---|
197 | return request; |
---|
198 | } |
---|
199 | |
---|
200 | inline void |
---|
201 | MPI::Comm::Sendrecv(const void *sendbuf, int sendcount, |
---|
202 | const MPI::Datatype & sendtype, int dest, int sendtag, |
---|
203 | void *recvbuf, int recvcount, |
---|
204 | const MPI::Datatype & recvtype, int source, |
---|
205 | int recvtag, MPI::Status & status) const |
---|
206 | { |
---|
207 | (void)MPI_Sendrecv(const_cast<void *>(sendbuf), sendcount, |
---|
208 | sendtype, |
---|
209 | dest, sendtag, recvbuf, recvcount, |
---|
210 | recvtype, |
---|
211 | source, recvtag, mpi_comm, &status.mpi_status); |
---|
212 | } |
---|
213 | |
---|
214 | inline void |
---|
215 | MPI::Comm::Sendrecv(const void *sendbuf, int sendcount, |
---|
216 | const MPI::Datatype & sendtype, int dest, int sendtag, |
---|
217 | void *recvbuf, int recvcount, |
---|
218 | const MPI::Datatype & recvtype, int source, |
---|
219 | int recvtag) const |
---|
220 | { |
---|
221 | (void)MPI_Sendrecv(const_cast<void *>(sendbuf), sendcount, |
---|
222 | sendtype, |
---|
223 | dest, sendtag, recvbuf, recvcount, |
---|
224 | recvtype, |
---|
225 | source, recvtag, mpi_comm, MPI_STATUS_IGNORE); |
---|
226 | } |
---|
227 | |
---|
228 | inline void |
---|
229 | MPI::Comm::Sendrecv_replace(void *buf, int count, |
---|
230 | const MPI::Datatype & datatype, int dest, |
---|
231 | int sendtag, int source, |
---|
232 | int recvtag, MPI::Status & status) const |
---|
233 | { |
---|
234 | (void)MPI_Sendrecv_replace(buf, count, datatype, dest, |
---|
235 | sendtag, source, recvtag, mpi_comm, |
---|
236 | &status.mpi_status); |
---|
237 | } |
---|
238 | |
---|
239 | inline void |
---|
240 | MPI::Comm::Sendrecv_replace(void *buf, int count, |
---|
241 | const MPI::Datatype & datatype, int dest, |
---|
242 | int sendtag, int source, |
---|
243 | int recvtag) const |
---|
244 | { |
---|
245 | (void)MPI_Sendrecv_replace(buf, count, datatype, dest, |
---|
246 | sendtag, source, recvtag, mpi_comm, |
---|
247 | MPI_STATUS_IGNORE); |
---|
248 | } |
---|
249 | |
---|
250 | // |
---|
251 | // Groups, Contexts, and Communicators |
---|
252 | // |
---|
253 | |
---|
254 | inline MPI::Group |
---|
255 | MPI::Comm::Get_group() const |
---|
256 | { |
---|
257 | MPI_Group group; |
---|
258 | (void)MPI_Comm_group(mpi_comm, &group); |
---|
259 | return group; |
---|
260 | } |
---|
261 | |
---|
262 | inline int |
---|
263 | MPI::Comm::Get_size() const |
---|
264 | { |
---|
265 | int size; |
---|
266 | (void)MPI_Comm_size (mpi_comm, &size); |
---|
267 | return size; |
---|
268 | } |
---|
269 | |
---|
270 | inline int |
---|
271 | MPI::Comm::Get_rank() const |
---|
272 | { |
---|
273 | int rank; |
---|
274 | (void)MPI_Comm_rank (mpi_comm, &rank); |
---|
275 | return rank; |
---|
276 | } |
---|
277 | |
---|
278 | inline int |
---|
279 | MPI::Comm::Compare(const MPI::Comm & comm1, |
---|
280 | const MPI::Comm & comm2) |
---|
281 | { |
---|
282 | int result; |
---|
283 | (void)MPI_Comm_compare(comm1, comm2, &result); |
---|
284 | return result; |
---|
285 | } |
---|
286 | |
---|
287 | inline void |
---|
288 | MPI::Comm::Free(void) |
---|
289 | { |
---|
290 | (void)MPI_Comm_free(&mpi_comm); |
---|
291 | } |
---|
292 | |
---|
293 | inline bool |
---|
294 | MPI::Comm::Is_inter() const |
---|
295 | { |
---|
296 | int t; |
---|
297 | (void)MPI_Comm_test_inter(mpi_comm, &t); |
---|
298 | return OPAL_INT_TO_BOOL(t); |
---|
299 | } |
---|
300 | |
---|
301 | |
---|
302 | // |
---|
303 | // Collective Communication |
---|
304 | // |
---|
305 | |
---|
306 | inline void |
---|
307 | MPI::Comm::Barrier() const |
---|
308 | { |
---|
309 | (void)MPI_Barrier(mpi_comm); |
---|
310 | } |
---|
311 | |
---|
312 | inline void |
---|
313 | MPI::Comm::Bcast(void *buffer, int count, |
---|
314 | const MPI::Datatype& datatype, int root) const |
---|
315 | { |
---|
316 | (void)MPI_Bcast(buffer, count, datatype, root, mpi_comm); |
---|
317 | } |
---|
318 | |
---|
319 | inline void |
---|
320 | MPI::Comm::Gather(const void *sendbuf, int sendcount, |
---|
321 | const MPI::Datatype & sendtype, |
---|
322 | void *recvbuf, int recvcount, |
---|
323 | const MPI::Datatype & recvtype, int root) const |
---|
324 | { |
---|
325 | (void)MPI_Gather(const_cast<void *>(sendbuf), sendcount, sendtype, |
---|
326 | recvbuf, recvcount, recvtype, root, mpi_comm); |
---|
327 | } |
---|
328 | |
---|
329 | inline void |
---|
330 | MPI::Comm::Gatherv(const void *sendbuf, int sendcount, |
---|
331 | const MPI::Datatype & sendtype, void *recvbuf, |
---|
332 | const int recvcounts[], const int displs[], |
---|
333 | const MPI::Datatype & recvtype, int root) const |
---|
334 | { |
---|
335 | (void)MPI_Gatherv(const_cast<void *>(sendbuf), sendcount, sendtype, |
---|
336 | recvbuf, const_cast<int *>(recvcounts), |
---|
337 | const_cast<int *>(displs), |
---|
338 | recvtype, root, mpi_comm); |
---|
339 | } |
---|
340 | |
---|
341 | inline void |
---|
342 | MPI::Comm::Scatter(const void *sendbuf, int sendcount, |
---|
343 | const MPI::Datatype & sendtype, |
---|
344 | void *recvbuf, int recvcount, |
---|
345 | const MPI::Datatype & recvtype, int root) const |
---|
346 | { |
---|
347 | (void)MPI_Scatter(const_cast<void *>(sendbuf), sendcount, sendtype, |
---|
348 | recvbuf, recvcount, recvtype, root, mpi_comm); |
---|
349 | } |
---|
350 | |
---|
351 | inline void |
---|
352 | MPI::Comm::Scatterv(const void *sendbuf, const int sendcounts[], |
---|
353 | const int displs[], const MPI::Datatype & sendtype, |
---|
354 | void *recvbuf, int recvcount, |
---|
355 | const MPI::Datatype & recvtype, int root) const |
---|
356 | { |
---|
357 | (void)MPI_Scatterv(const_cast<void *>(sendbuf), |
---|
358 | const_cast<int *>(sendcounts), |
---|
359 | const_cast<int *>(displs), sendtype, |
---|
360 | recvbuf, recvcount, recvtype, |
---|
361 | root, mpi_comm); |
---|
362 | } |
---|
363 | |
---|
364 | inline void |
---|
365 | MPI::Comm::Allgather(const void *sendbuf, int sendcount, |
---|
366 | const MPI::Datatype & sendtype, void *recvbuf, |
---|
367 | int recvcount, const MPI::Datatype & recvtype) const |
---|
368 | { |
---|
369 | (void)MPI_Allgather(const_cast<void *>(sendbuf), sendcount, |
---|
370 | sendtype, recvbuf, recvcount, |
---|
371 | recvtype, mpi_comm); |
---|
372 | } |
---|
373 | |
---|
374 | inline void |
---|
375 | MPI::Comm::Allgatherv(const void *sendbuf, int sendcount, |
---|
376 | const MPI::Datatype & sendtype, void *recvbuf, |
---|
377 | const int recvcounts[], const int displs[], |
---|
378 | const MPI::Datatype & recvtype) const |
---|
379 | { |
---|
380 | (void)MPI_Allgatherv(const_cast<void *>(sendbuf), sendcount, |
---|
381 | sendtype, recvbuf, |
---|
382 | const_cast<int *>(recvcounts), |
---|
383 | const_cast<int *>(displs), |
---|
384 | recvtype, mpi_comm); |
---|
385 | } |
---|
386 | |
---|
387 | inline void |
---|
388 | MPI::Comm::Alltoall(const void *sendbuf, int sendcount, |
---|
389 | const MPI::Datatype & sendtype, void *recvbuf, |
---|
390 | int recvcount, const MPI::Datatype & recvtype) const |
---|
391 | { |
---|
392 | (void)MPI_Alltoall(const_cast<void *>(sendbuf), sendcount, |
---|
393 | sendtype, recvbuf, recvcount, |
---|
394 | recvtype, mpi_comm); |
---|
395 | } |
---|
396 | |
---|
397 | inline void |
---|
398 | MPI::Comm::Alltoallv(const void *sendbuf, const int sendcounts[], |
---|
399 | const int sdispls[], const MPI::Datatype & sendtype, |
---|
400 | void *recvbuf, const int recvcounts[], |
---|
401 | const int rdispls[], |
---|
402 | const MPI::Datatype & recvtype) const |
---|
403 | { |
---|
404 | (void)MPI_Alltoallv(const_cast<void *>(sendbuf), |
---|
405 | const_cast<int *>(sendcounts), |
---|
406 | const_cast<int *>(sdispls), sendtype, recvbuf, |
---|
407 | const_cast<int *>(recvcounts), |
---|
408 | const_cast<int *>(rdispls), |
---|
409 | recvtype,mpi_comm); |
---|
410 | } |
---|
411 | |
---|
412 | inline void |
---|
413 | MPI::Comm::Alltoallw(const void *sendbuf, const int sendcounts[], |
---|
414 | const int sdispls[], const MPI::Datatype sendtypes[], |
---|
415 | void *recvbuf, const int recvcounts[], |
---|
416 | const int rdispls[], |
---|
417 | const MPI::Datatype recvtypes[]) const |
---|
418 | { |
---|
419 | const int comm_size = Get_size(); |
---|
420 | MPI_Datatype *const data_type_tbl = new MPI_Datatype [2*comm_size]; |
---|
421 | |
---|
422 | // This must be done because MPI::Datatype arrays cannot be |
---|
423 | // converted directly into MPI_Datatype arrays. |
---|
424 | for (int i_rank=0; i_rank < comm_size; i_rank++) { |
---|
425 | data_type_tbl[i_rank] = sendtypes[i_rank]; |
---|
426 | data_type_tbl[i_rank + comm_size] = recvtypes[i_rank]; |
---|
427 | } |
---|
428 | |
---|
429 | (void)MPI_Alltoallw(const_cast<void *>(sendbuf), |
---|
430 | const_cast<int *>(sendcounts), |
---|
431 | const_cast<int *>(sdispls), |
---|
432 | data_type_tbl, recvbuf, |
---|
433 | const_cast<int *>(recvcounts), |
---|
434 | const_cast<int *>(rdispls), |
---|
435 | &data_type_tbl[comm_size], mpi_comm); |
---|
436 | |
---|
437 | delete[] data_type_tbl; |
---|
438 | } |
---|
439 | |
---|
440 | inline void |
---|
441 | MPI::Comm::Reduce(const void *sendbuf, void *recvbuf, int count, |
---|
442 | const MPI::Datatype & datatype, const MPI::Op& op, |
---|
443 | int root) const |
---|
444 | { |
---|
445 | (void)MPI_Reduce(const_cast<void *>(sendbuf), recvbuf, count, datatype, op, root, mpi_comm); |
---|
446 | } |
---|
447 | |
---|
448 | inline void |
---|
449 | MPI::Comm::Allreduce(const void *sendbuf, void *recvbuf, int count, |
---|
450 | const MPI::Datatype & datatype, const MPI::Op& op) const |
---|
451 | { |
---|
452 | (void)MPI_Allreduce (const_cast<void *>(sendbuf), recvbuf, count, datatype, op, mpi_comm); |
---|
453 | } |
---|
454 | |
---|
455 | inline void |
---|
456 | MPI::Comm::Reduce_scatter(const void *sendbuf, void *recvbuf, |
---|
457 | int recvcounts[], |
---|
458 | const MPI::Datatype & datatype, |
---|
459 | const MPI::Op& op) const |
---|
460 | { |
---|
461 | (void)MPI_Reduce_scatter(const_cast<void *>(sendbuf), recvbuf, recvcounts, |
---|
462 | datatype, op, mpi_comm); |
---|
463 | } |
---|
464 | |
---|
465 | // |
---|
466 | // Process Creation and Managemnt |
---|
467 | // |
---|
468 | |
---|
469 | inline void |
---|
470 | MPI::Comm::Disconnect() |
---|
471 | { |
---|
472 | (void) MPI_Comm_disconnect(&mpi_comm); |
---|
473 | } |
---|
474 | |
---|
475 | |
---|
476 | inline MPI::Intercomm |
---|
477 | MPI::Comm::Get_parent() |
---|
478 | { |
---|
479 | MPI_Comm parent; |
---|
480 | MPI_Comm_get_parent(&parent); |
---|
481 | return parent; |
---|
482 | } |
---|
483 | |
---|
484 | |
---|
485 | inline MPI::Intercomm |
---|
486 | MPI::Comm::Join(const int fd) |
---|
487 | { |
---|
488 | MPI_Comm newcomm; |
---|
489 | (void) MPI_Comm_join((int) fd, &newcomm); |
---|
490 | return newcomm; |
---|
491 | } |
---|
492 | |
---|
493 | // |
---|
494 | // External Interfaces |
---|
495 | // |
---|
496 | |
---|
497 | inline void |
---|
498 | MPI::Comm::Get_name(char* comm_name, int& resultlen) const |
---|
499 | { |
---|
500 | (void) MPI_Comm_get_name(mpi_comm, comm_name, &resultlen); |
---|
501 | } |
---|
502 | |
---|
503 | inline void |
---|
504 | MPI::Comm::Set_name(const char* comm_name) |
---|
505 | { |
---|
506 | (void) MPI_Comm_set_name(mpi_comm, const_cast<char *>(comm_name)); |
---|
507 | } |
---|
508 | |
---|
509 | // |
---|
510 | //Process Topologies |
---|
511 | // |
---|
512 | |
---|
513 | inline int |
---|
514 | MPI::Comm::Get_topology() const |
---|
515 | { |
---|
516 | int status; |
---|
517 | (void)MPI_Topo_test(mpi_comm, &status); |
---|
518 | return status; |
---|
519 | } |
---|
520 | |
---|
521 | // |
---|
522 | // Environmental Inquiry |
---|
523 | // |
---|
524 | |
---|
525 | inline void |
---|
526 | MPI::Comm::Abort(int errorcode) |
---|
527 | { |
---|
528 | (void)MPI_Abort(mpi_comm, errorcode); |
---|
529 | } |
---|
530 | |
---|
531 | // |
---|
532 | // These C++ bindings are for MPI-2. |
---|
533 | // The MPI-1.2 functions called below are all |
---|
534 | // going to be deprecated and replaced in MPI-2. |
---|
535 | // |
---|
536 | |
---|
537 | inline MPI::Errhandler |
---|
538 | MPI::Comm::Get_errhandler() const |
---|
539 | { |
---|
540 | MPI_Errhandler errhandler; |
---|
541 | MPI_Comm_get_errhandler(mpi_comm, &errhandler); |
---|
542 | return errhandler; |
---|
543 | } |
---|
544 | |
---|
545 | inline void |
---|
546 | MPI::Comm::Set_errhandler(const MPI::Errhandler& errhandler) const |
---|
547 | { |
---|
548 | (void)MPI_Comm_set_errhandler(mpi_comm, errhandler); |
---|
549 | } |
---|
550 | |
---|
551 | inline void |
---|
552 | MPI::Comm::Call_errhandler(int errorcode) const |
---|
553 | { |
---|
554 | (void) MPI_Comm_call_errhandler(mpi_comm, errorcode); |
---|
555 | } |
---|
556 | |
---|
557 | // 1) original Create_keyval that takes the first 2 arguments as C++ |
---|
558 | // functions |
---|
559 | inline int |
---|
560 | MPI::Comm::Create_keyval(MPI::Comm::Copy_attr_function* comm_copy_attr_fn, |
---|
561 | MPI::Comm::Delete_attr_function* comm_delete_attr_fn, |
---|
562 | void* extra_state) |
---|
563 | { |
---|
564 | // Back-end function does the heavy lifting |
---|
565 | int ret, keyval; |
---|
566 | ret = do_create_keyval(NULL, NULL, |
---|
567 | comm_copy_attr_fn, comm_delete_attr_fn, |
---|
568 | extra_state, keyval); |
---|
569 | return (MPI_SUCCESS == ret) ? keyval : ret; |
---|
570 | } |
---|
571 | |
---|
572 | // 2) overload Create_keyval to take the first 2 arguments as C |
---|
573 | // functions |
---|
574 | inline int |
---|
575 | MPI::Comm::Create_keyval(MPI_Comm_copy_attr_function* comm_copy_attr_fn, |
---|
576 | MPI_Comm_delete_attr_function* comm_delete_attr_fn, |
---|
577 | void* extra_state) |
---|
578 | { |
---|
579 | // Back-end function does the heavy lifting |
---|
580 | int ret, keyval; |
---|
581 | ret = do_create_keyval(comm_copy_attr_fn, comm_delete_attr_fn, |
---|
582 | NULL, NULL, |
---|
583 | extra_state, keyval); |
---|
584 | return (MPI_SUCCESS == ret) ? keyval : ret; |
---|
585 | } |
---|
586 | |
---|
587 | // 3) overload Create_keyval to take the first 2 arguments as C++ & C |
---|
588 | // functions |
---|
589 | inline int |
---|
590 | MPI::Comm::Create_keyval(MPI::Comm::Copy_attr_function* comm_copy_attr_fn, |
---|
591 | MPI_Comm_delete_attr_function* comm_delete_attr_fn, |
---|
592 | void* extra_state) |
---|
593 | { |
---|
594 | // Back-end function does the heavy lifting |
---|
595 | int ret, keyval; |
---|
596 | ret = do_create_keyval(NULL, comm_delete_attr_fn, |
---|
597 | comm_copy_attr_fn, NULL, |
---|
598 | extra_state, keyval); |
---|
599 | return (MPI_SUCCESS == ret) ? keyval : ret; |
---|
600 | } |
---|
601 | |
---|
602 | // 4) overload Create_keyval to take the first 2 arguments as C & C++ |
---|
603 | // functions |
---|
604 | inline int |
---|
605 | MPI::Comm::Create_keyval(MPI_Comm_copy_attr_function* comm_copy_attr_fn, |
---|
606 | MPI::Comm::Delete_attr_function* comm_delete_attr_fn, |
---|
607 | void* extra_state) |
---|
608 | { |
---|
609 | // Back-end function does the heavy lifting |
---|
610 | int ret, keyval; |
---|
611 | ret = do_create_keyval(comm_copy_attr_fn, NULL, |
---|
612 | NULL, comm_delete_attr_fn, |
---|
613 | extra_state, keyval); |
---|
614 | return (MPI_SUCCESS == ret) ? keyval : ret; |
---|
615 | } |
---|
616 | |
---|
617 | inline void |
---|
618 | MPI::Comm::Free_keyval(int& comm_keyval) |
---|
619 | { |
---|
620 | (void) MPI_Keyval_free(&comm_keyval); |
---|
621 | } |
---|
622 | |
---|
623 | inline void |
---|
624 | MPI::Comm::Set_attr(int comm_keyval, const void* attribute_val) const |
---|
625 | { |
---|
626 | (void)MPI_Attr_put(mpi_comm, comm_keyval, const_cast<void*>(attribute_val)); |
---|
627 | } |
---|
628 | |
---|
629 | inline bool |
---|
630 | MPI::Comm::Get_attr(int comm_keyval, void* attribute_val) const |
---|
631 | { |
---|
632 | int flag; |
---|
633 | (void)MPI_Attr_get(mpi_comm, comm_keyval, attribute_val, &flag); |
---|
634 | return OPAL_INT_TO_BOOL(flag); |
---|
635 | } |
---|
636 | |
---|
637 | inline void |
---|
638 | MPI::Comm::Delete_attr(int comm_keyval) |
---|
639 | { |
---|
640 | (void)MPI_Attr_delete(mpi_comm, comm_keyval); |
---|
641 | } |
---|
642 | |
---|
643 | inline int |
---|
644 | MPI::Comm::NULL_COPY_FN(const MPI::Comm& oldcomm, int comm_keyval, |
---|
645 | void* extra_state, void* attribute_val_in, |
---|
646 | void* attribute_val_out, bool& flag) |
---|
647 | { |
---|
648 | flag = false; |
---|
649 | return MPI_SUCCESS; |
---|
650 | } |
---|
651 | |
---|
652 | inline int |
---|
653 | MPI::Comm::DUP_FN(const MPI::Comm& oldcomm, int comm_keyval, |
---|
654 | void* extra_state, void* attribute_val_in, |
---|
655 | void* attribute_val_out, bool& flag) |
---|
656 | { |
---|
657 | #if OMPI_SIZEOF_BOOL != OMPI_SIZEOF_INT |
---|
658 | int f = (int)flag; |
---|
659 | int ret; |
---|
660 | ret = MPI_DUP_FN(oldcomm, comm_keyval, extra_state, attribute_val_in, |
---|
661 | attribute_val_out, &f); |
---|
662 | flag = OPAL_INT_TO_BOOL(f); |
---|
663 | return ret; |
---|
664 | #else |
---|
665 | return MPI_DUP_FN(oldcomm, comm_keyval, extra_state, attribute_val_in, |
---|
666 | attribute_val_out, (int*)&flag); |
---|
667 | #endif |
---|
668 | } |
---|
669 | |
---|
670 | inline int |
---|
671 | MPI::Comm::NULL_DELETE_FN(MPI::Comm& comm, int comm_keyval, void* attribute_val, |
---|
672 | void* extra_state) |
---|
673 | { |
---|
674 | return MPI_SUCCESS; |
---|
675 | } |
---|
676 | |
---|