Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / include / mpicolltest.h
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3  * (C) 2015 by Argonne National Laboratory.
4  *     See COPYRIGHT in top-level directory.
5  */
6
7 #ifndef MPICOLLTEST_H_INCLUDED
8 #define MPICOLLTEST_H_INCLUDED
9
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. */
13
14 #include "mpi.h"
15 #include "mpitestconf.h"
16
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)
21 {
22     int mpi_errno;
23     MPI_Request req = MPI_REQUEST_NULL;
24
25     mpi_errno = MPI_Ibarrier(comm, &req);
26     if (mpi_errno != MPI_SUCCESS)
27         return mpi_errno;
28     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
29     return mpi_errno;
30 }
31
32 static inline int MTest_Bcast(void *buffer, int count, MPI_Datatype datatype, int root,
33                               MPI_Comm comm)
34 {
35     int mpi_errno;
36     MPI_Request req = MPI_REQUEST_NULL;
37
38     mpi_errno = MPI_Ibcast(buffer, count, datatype, root, comm, &req);
39     if (mpi_errno != MPI_SUCCESS)
40         return mpi_errno;
41     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
42     return mpi_errno;
43 }
44
45 static inline int MTest_Gather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
46                                void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
47                                MPI_Comm comm)
48 {
49     int mpi_errno;
50     MPI_Request req = MPI_REQUEST_NULL;
51
52     mpi_errno = MPI_Igather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype,
53                             root, comm, &req);
54     if (mpi_errno != MPI_SUCCESS)
55         return mpi_errno;
56     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
57     return mpi_errno;
58 }
59
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)
63 {
64     int mpi_errno;
65     MPI_Request req = MPI_REQUEST_NULL;
66
67     mpi_errno = MPI_Igatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs,
68                              recvtype, root, comm, &req);
69     if (mpi_errno != MPI_SUCCESS)
70         return mpi_errno;
71     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
72     return mpi_errno;
73 }
74
75 static inline int MTest_Scatter( void *sendbuf, int sendcount, MPI_Datatype sendtype,
76                                 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
77                                 MPI_Comm comm)
78 {
79     int mpi_errno;
80     MPI_Request req = MPI_REQUEST_NULL;
81
82     mpi_errno = MPI_Iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount,
83                              recvtype, root, comm, &req);
84     if (mpi_errno != MPI_SUCCESS)
85         return mpi_errno;
86     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
87     return mpi_errno;
88 }
89
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)
93 {
94     int mpi_errno;
95     MPI_Request req = MPI_REQUEST_NULL;
96
97     mpi_errno = MPI_Iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
98                               recvcount, recvtype, root, comm, &req);
99     if (mpi_errno != MPI_SUCCESS)
100         return mpi_errno;
101     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
102     return mpi_errno;
103 }
104
105 static inline int MTest_Allgather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
106                                   void *recvbuf, int recvcount, MPI_Datatype recvtype,
107                                   MPI_Comm comm)
108 {
109     int mpi_errno;
110     MPI_Request req = MPI_REQUEST_NULL;
111
112     mpi_errno = MPI_Iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount,
113                                recvtype, comm, &req);
114     if (mpi_errno != MPI_SUCCESS)
115         return mpi_errno;
116     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
117     return mpi_errno;
118 }
119
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)
123 {
124     int mpi_errno;
125     MPI_Request req = MPI_REQUEST_NULL;
126
127     mpi_errno = MPI_Iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
128                                 displs, recvtype, comm, &req);
129     if (mpi_errno != MPI_SUCCESS)
130         return mpi_errno;
131     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
132     return mpi_errno;
133 }
134
135 static inline int MTest_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype,
136                                  void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
137 {
138     int mpi_errno;
139     MPI_Request req = MPI_REQUEST_NULL;
140
141     mpi_errno = MPI_Ialltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount,
142                               recvtype, comm, &req);
143     if (mpi_errno != MPI_SUCCESS)
144         return mpi_errno;
145     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
146     return mpi_errno;
147 }
148
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)
152 {
153     int mpi_errno;
154     MPI_Request req = MPI_REQUEST_NULL;
155
156     mpi_errno = MPI_Ialltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
157                                recvcounts, rdispls, recvtype, comm, &req);
158     if (mpi_errno != MPI_SUCCESS)
159         return mpi_errno;
160     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
161     return mpi_errno;
162 }
163
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)
168 {
169     int mpi_errno;
170     MPI_Request req = MPI_REQUEST_NULL;
171
172     mpi_errno = MPI_Ialltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf,
173                                recvcounts, rdispls, recvtypes, comm, &req);
174     if (mpi_errno != MPI_SUCCESS)
175         return mpi_errno;
176     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
177     return mpi_errno;
178 }
179
180 static inline int MTest_Reduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
181                                MPI_Op op, int root, MPI_Comm comm)
182 {
183     int mpi_errno;
184     MPI_Request req = MPI_REQUEST_NULL;
185
186     mpi_errno = MPI_Ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, &req);
187     if (mpi_errno != MPI_SUCCESS)
188         return mpi_errno;
189     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
190     return mpi_errno;
191 }
192
193 static inline int MTest_Allreduce( void *sendbuf, void *recvbuf, int count,
194                                   MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
195 {
196     int mpi_errno;
197     MPI_Request req = MPI_REQUEST_NULL;
198
199     mpi_errno = MPI_Iallreduce(sendbuf, recvbuf, count, datatype, op, comm, &req);
200     if (mpi_errno != MPI_SUCCESS)
201         return mpi_errno;
202     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
203     return mpi_errno;
204 }
205
206 static inline int MTest_Reduce_scatter( void *sendbuf, void *recvbuf,  int *recvcounts,
207                                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
208 {
209     int mpi_errno;
210     MPI_Request req = MPI_REQUEST_NULL;
211
212     mpi_errno = MPI_Ireduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm, &req);
213     if (mpi_errno != MPI_SUCCESS)
214         return mpi_errno;
215     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
216     return mpi_errno;
217 }
218
219 static inline int MTest_Reduce_scatter_block( void *sendbuf, void *recvbuf, int recvcount,
220                                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
221 {
222     int mpi_errno;
223     MPI_Request req = MPI_REQUEST_NULL;
224
225     mpi_errno = MPI_Ireduce_scatter_block(sendbuf, recvbuf, recvcount, datatype, op, comm, &req);
226     if (mpi_errno != MPI_SUCCESS)
227         return mpi_errno;
228     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
229     return mpi_errno;
230 }
231
232 static inline int MTest_Scan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
233                              MPI_Op op, MPI_Comm comm)
234 {
235     int mpi_errno;
236     MPI_Request req = MPI_REQUEST_NULL;
237
238     mpi_errno = MPI_Iscan(sendbuf, recvbuf, count, datatype, op, comm, &req);
239     if (mpi_errno != MPI_SUCCESS)
240         return mpi_errno;
241     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
242     return mpi_errno;
243 }
244
245 static inline int MTest_Exscan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
246                                MPI_Op op, MPI_Comm comm)
247 {
248     int mpi_errno;
249     MPI_Request req = MPI_REQUEST_NULL;
250
251     mpi_errno = MPI_Iexscan(sendbuf, recvbuf, count, datatype, op, comm, &req);
252     if (mpi_errno != MPI_SUCCESS)
253         return mpi_errno;
254     mpi_errno = MPI_Wait(&req, MPI_STATUS_IGNORE);
255     return mpi_errno;
256 }
257 #else
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.*/
260
261 static inline int MTest_Barrier(MPI_Comm comm)
262 {
263     return MPI_Barrier(comm);
264 }
265
266 static inline int MTest_Bcast(void *buffer, int count, MPI_Datatype datatype, int root,
267                               MPI_Comm comm)
268 {
269     return MPI_Bcast(buffer, count, datatype, root, comm);
270 }
271
272 static inline int MTest_Gather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
273                                void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
274                                MPI_Comm comm)
275 {
276     return MPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
277 }
278
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)
282 {
283     return MPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs,
284                        recvtype, root, comm);
285 }
286
287 static inline int MTest_Scatter( void *sendbuf, int sendcount, MPI_Datatype sendtype,
288                                 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root,
289                                 MPI_Comm comm)
290 {
291     return MPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
292 }
293
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)
297 {
298     return MPI_Scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf,
299                         recvcount, recvtype, root, comm);
300 }
301
302 static inline int MTest_Allgather( void *sendbuf, int sendcount, MPI_Datatype sendtype,
303                                   void *recvbuf, int recvcount, MPI_Datatype recvtype,
304                                   MPI_Comm comm)
305 {
306     return MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
307 }
308
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)
312 {
313     return MPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
314                           displs, recvtype, comm);
315 }
316
317 static inline int MTest_Alltoall( void *sendbuf, int sendcount, MPI_Datatype sendtype,
318                                  void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
319 {
320     return MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
321 }
322
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)
326 {
327     return MPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf,
328                          recvcounts, rdispls, recvtype, comm);
329 }
330
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)
335 {
336     return MPI_Alltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf,
337                          recvcounts, rdispls, recvtypes, comm);
338 }
339
340 static inline int MTest_Reduce( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
341                                MPI_Op op, int root, MPI_Comm comm)
342 {
343     return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
344 }
345
346 static inline int MTest_Allreduce( void *sendbuf, void *recvbuf, int count,
347                                   MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
348 {
349     return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
350 }
351
352 static inline int MTest_Reduce_scatter( void *sendbuf, void *recvbuf,  int *recvcounts,
353                                        MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
354 {
355     return MPI_Reduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm);
356 }
357
358 static inline int MTest_Reduce_scatter_block( void *sendbuf, void *recvbuf, int recvcount,
359                                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
360 {
361     return MPI_Reduce_scatter_block(sendbuf, recvbuf, recvcount, datatype, op, comm);
362 }
363
364 static inline int MTest_Scan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
365                              MPI_Op op, MPI_Comm comm)
366 {
367     return MPI_Scan(sendbuf, recvbuf, count, datatype, op, comm);
368 }
369
370 static inline int MTest_Exscan( void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
371                                MPI_Op op, MPI_Comm comm)
372 {
373     return MPI_Exscan(sendbuf, recvbuf, count, datatype, op, comm);
374 }
375
376 #endif /* USE_MTEST_NBC */
377 #endif /* MPICOLLTEST_H_INCLUDED */