1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
3 * (C) 2015 by Argonne National Laboratory.
4 * See COPYRIGHT in top-level directory.
7 #ifndef MPICOLLTEST_H_INCLUDED
8 #define MPICOLLTEST_H_INCLUDED
10 /* This file defines MTest wrapper functions for MPI collectives.
11 * Test uses MTest_Collective calls that are defined as blocking collective by
12 * default, or as non-blocking version by compiling with -DUSE_MTEST_NBC. */
15 #include "mpitestconf.h"
17 /* Wrap up MTest_Collective calls by non-blocking collectives.
18 * It requires MPI_VERSION >= 3. */
19 #if defined(USE_MTEST_NBC) && MPI_VERSION >= 3
20 static inline int MTest_Barrier(MPI_Comm comm)
23 MPI_Request req = MPI_REQUEST_NULL;
25 mpi_errno = MPI_Ibarrier(comm, &req);
26 if (mpi_errno != MPI_SUCCESS)
28 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
32 static inline int MTest_Bcast(void *buffer, int count, MPI_Datatype datatype, int root,
36 MPI_Request req = MPI_REQUEST_NULL;
38 mpi_errno = MPI_Ibcast(buffer, count, datatype, root, comm, &req);
39 if (mpi_errno != MPI_SUCCESS)
41 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
45 static inline int MTest_Gather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
46 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
50 MPI_Request req = MPI_REQUEST_NULL;
52 mpi_errno = MPI_Igather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
54 if (mpi_errno != MPI_SUCCESS)
56 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
60 static inline int MTest_Gatherv( void *sendbuf, int sendcount, MPI_Datatype sendtype,
61 void *recvbuf, int *recvcounts, int *displs,
62 MPI_Datatype recvtype, int root, MPI_Comm comm)
65 MPI_Request req = MPI_REQUEST_NULL;
67 mpi_errno = MPI_Igatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs,
68 recvtype, root, comm, &req);
69 if (mpi_errno != MPI_SUCCESS)
71 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
75 static inline int MTest_Scatter( void *sendbuf, int sendcount, MPI_Datatype sendtype,
76 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
80 MPI_Request req = MPI_REQUEST_NULL;
82 mpi_errno = MPI_Iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
83 recvtype, root, comm, &req);
84 if (mpi_errno != MPI_SUCCESS)
86 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
90 static inline int MTest_Scatterv( void *sendbuf, int *sendcounts, int *displs,
91 MPI_Datatype sendtype, void *recvbuf, int recvcount,
92 MPI_Datatype recvtype, int root, MPI_Comm comm)
95 MPI_Request req = MPI_REQUEST_NULL;
97 mpi_errno = MPI_Iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
98 recvcount, recvtype, root, comm, &req);
99 if (mpi_errno != MPI_SUCCESS)
101 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
105 static inline int MTest_Allgather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
106 void *recvbuf, int recvcount, MPI_Datatype recvtype,
110 MPI_Request req = MPI_REQUEST_NULL;
112 mpi_errno = MPI_Iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
113 recvtype, comm, &req);
114 if (mpi_errno != MPI_SUCCESS)
116 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
120 static inline int MTest_Allgatherv( void *sendbuf, int sendcount, MPI_Datatype sendtype,
121 void *recvbuf, int *recvcounts, int *displs,
122 MPI_Datatype recvtype, MPI_Comm comm)
125 MPI_Request req = MPI_REQUEST_NULL;
127 mpi_errno = MPI_Iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
128 displs, recvtype, comm, &req);
129 if (mpi_errno != MPI_SUCCESS)
131 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
135 static inline int MTest_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype,
136 void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
139 MPI_Request req = MPI_REQUEST_NULL;
141 mpi_errno = MPI_Ialltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount,
142 recvtype, comm, &req);
143 if (mpi_errno != MPI_SUCCESS)
145 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
149 static inline int MTest_Alltoallv( void *sendbuf, int *sendcounts, int *sdispls,
150 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
151 int *rdispls, MPI_Datatype recvtype, MPI_Comm comm)
154 MPI_Request req = MPI_REQUEST_NULL;
156 mpi_errno = MPI_Ialltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
157 recvcounts, rdispls, recvtype, comm, &req);
158 if (mpi_errno != MPI_SUCCESS)
160 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
164 static inline int MTest_Alltoallw( void *sendbuf, int *sendcounts, int *sdispls,
165 MPI_Datatype * sendtypes, void *recvbuf,
166 int *recvcounts, int *rdispls,
167 MPI_Datatype * recvtypes, MPI_Comm comm)
170 MPI_Request req = MPI_REQUEST_NULL;
172 mpi_errno = MPI_Ialltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf,
173 recvcounts, rdispls, recvtypes, comm, &req);
174 if (mpi_errno != MPI_SUCCESS)
176 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
180 static inline int MTest_Reduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
181 MPI_Op op, int root, MPI_Comm comm)
184 MPI_Request req = MPI_REQUEST_NULL;
186 mpi_errno = MPI_Ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, &req);
187 if (mpi_errno != MPI_SUCCESS)
189 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
193 static inline int MTest_Allreduce( void *sendbuf, void *recvbuf, int count,
194 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
197 MPI_Request req = MPI_REQUEST_NULL;
199 mpi_errno = MPI_Iallreduce(sendbuf, recvbuf, count, datatype, op, comm, &req);
200 if (mpi_errno != MPI_SUCCESS)
202 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
206 static inline int MTest_Reduce_scatter( void *sendbuf, void *recvbuf, int *recvcounts,
207 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
210 MPI_Request req = MPI_REQUEST_NULL;
212 mpi_errno = MPI_Ireduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm, &req);
213 if (mpi_errno != MPI_SUCCESS)
215 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
219 static inline int MTest_Reduce_scatter_block( void *sendbuf, void *recvbuf, int recvcount,
220 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
223 MPI_Request req = MPI_REQUEST_NULL;
225 mpi_errno = MPI_Ireduce_scatter_block(sendbuf, recvbuf, recvcount, datatype, op, comm, &req);
226 if (mpi_errno != MPI_SUCCESS)
228 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
232 static inline int MTest_Scan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
233 MPI_Op op, MPI_Comm comm)
236 MPI_Request req = MPI_REQUEST_NULL;
238 mpi_errno = MPI_Iscan(sendbuf, recvbuf, count, datatype, op, comm, &req);
239 if (mpi_errno != MPI_SUCCESS)
241 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
245 static inline int MTest_Exscan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
246 MPI_Op op, MPI_Comm comm)
249 MPI_Request req = MPI_REQUEST_NULL;
251 mpi_errno = MPI_Iexscan(sendbuf, recvbuf, count, datatype, op, comm, &req);
252 if (mpi_errno != MPI_SUCCESS)
254 mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
258 /* If USE_MTEST_NBC is not specified, or MPI_VERSION is less than 3,
259 * wrap up MTest_Collective calls by traditional blocking collectives.*/
261 static inline int MTest_Barrier(MPI_Comm comm)
263 return MPI_Barrier(comm);
266 static inline int MTest_Bcast(void *buffer, int count, MPI_Datatype datatype, int root,
269 return MPI_Bcast(buffer, count, datatype, root, comm);
272 static inline int MTest_Gather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
273 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
276 return MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
279 static inline int MTest_Gatherv( void *sendbuf, int sendcount, MPI_Datatype sendtype,
280 void *recvbuf, int *recvcounts, int *displs,
281 MPI_Datatype recvtype, int root, MPI_Comm comm)
283 return MPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs,
284 recvtype, root, comm);
287 static inline int MTest_Scatter( void *sendbuf, int sendcount, MPI_Datatype sendtype,
288 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
291 return MPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
294 static inline int MTest_Scatterv( void *sendbuf, int *sendcounts, int *displs,
295 MPI_Datatype sendtype, void *recvbuf, int recvcount,
296 MPI_Datatype recvtype, int root, MPI_Comm comm)
298 return MPI_Scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
299 recvcount, recvtype, root, comm);
302 static inline int MTest_Allgather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
303 void *recvbuf, int recvcount, MPI_Datatype recvtype,
306 return MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
309 static inline int MTest_Allgatherv( void *sendbuf, int sendcount, MPI_Datatype sendtype,
310 void *recvbuf, int *recvcounts, int *displs,
311 MPI_Datatype recvtype, MPI_Comm comm)
313 return MPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
314 displs, recvtype, comm);
317 static inline int MTest_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype,
318 void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
320 return MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
323 static inline int MTest_Alltoallv( void *sendbuf, int *sendcounts, int *sdispls,
324 MPI_Datatype sendtype, void *recvbuf, int *recvcounts,
325 int *rdispls, MPI_Datatype recvtype, MPI_Comm comm)
327 return MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
328 recvcounts, rdispls, recvtype, comm);
331 static inline int MTest_Alltoallw( void *sendbuf, int *sendcounts, int *sdispls,
332 MPI_Datatype * sendtypes, void *recvbuf,
333 int *recvcounts, int *rdispls,
334 MPI_Datatype * recvtypes, MPI_Comm comm)
336 return MPI_Alltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf,
337 recvcounts, rdispls, recvtypes, comm);
340 static inline int MTest_Reduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
341 MPI_Op op, int root, MPI_Comm comm)
343 return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
346 static inline int MTest_Allreduce( void *sendbuf, void *recvbuf, int count,
347 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
349 return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
352 static inline int MTest_Reduce_scatter( void *sendbuf, void *recvbuf, int *recvcounts,
353 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
355 return MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm);
358 static inline int MTest_Reduce_scatter_block( void *sendbuf, void *recvbuf, int recvcount,
359 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
361 return MPI_Reduce_scatter_block(sendbuf, recvbuf, recvcount, datatype, op, comm);
364 static inline int MTest_Scan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
365 MPI_Op op, MPI_Comm comm)
367 return MPI_Scan(sendbuf, recvbuf, count, datatype, op, comm);
370 static inline int MTest_Exscan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
371 MPI_Op op, MPI_Comm comm)
373 return MPI_Exscan(sendbuf, recvbuf, count, datatype, op, comm);
376 #endif /* USE_MTEST_NBC */
377 #endif /* MPICOLLTEST_H_INCLUDED */