QUDA  v1.1.0
A library for QCD on GPUs
nvtx_pmpi.c
Go to the documentation of this file.
1 
2 #include <mpi.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #ifndef _EXTERN_C_
6 #ifdef __cplusplus
7 #define _EXTERN_C_ extern "C"
8 #else /* __cplusplus */
9 #define _EXTERN_C_
10 #endif /* __cplusplus */
11 #endif /* _EXTERN_C_ */
12 #ifdef MPICH_HAS_C2F
13 _EXTERN_C_ void *MPIR_ToPointer(int);
14 #endif // MPICH_HAS_C2F
15 #ifdef PIC
16 /* For shared libraries, declare these weak and figure out which one was linked
17  based on which init wrapper was called. See mpi_init wrappers. */
18 #pragma weak pmpi_init
19 #pragma weak PMPI_INIT
20 #pragma weak pmpi_init_
21 #pragma weak pmpi_init__
22 #endif /* PIC */
23 _EXTERN_C_ void pmpi_init(MPI_Fint *ierr);
24 _EXTERN_C_ void PMPI_INIT(MPI_Fint *ierr);
25 _EXTERN_C_ void pmpi_init_(MPI_Fint *ierr);
26 _EXTERN_C_ void pmpi_init__(MPI_Fint *ierr);
27 static int in_wrapper = 0;
28 #include <pthread.h>
29 
30 #if QUDA_NVTX_VERSION == 3
31 #include <nvtx3/nvToolsExt.h>
32 #include <nvtx3/nvToolsExtCudaRt.h>
33 #else
34 #include <nvToolsExt.h>
35 #include <nvToolsExtCudaRt.h>
36 #endif
37 
38 #include <mpi_comm_handle.h>
39 // Setup event category name
40 /* ================== C Wrappers for MPI_Init ================== */
41 _EXTERN_C_ int PMPI_Init(int *argc, char ***argv);
42 _EXTERN_C_ int MPI_Init(int *argc, char ***argv) {
43  int _wrap_py_return_val = 0;
44  if (in_wrapper) return PMPI_Init(argc, argv);
45  in_wrapper = 1;
46 
47  nvtxNameCategoryA(999, "MPI");
48  _wrap_py_return_val = PMPI_Init(argc, argv);
49  int rank;
50  PMPI_Comm_rank(MPI_COMM_HANDLE, &rank);
51  char name[256];
52  sprintf( name, "MPI Rank %d", rank );
53 
54  nvtxNameOsThread(pthread_self(), name);
55  nvtxNameCudaDeviceA(rank, name);
56  in_wrapper = 0;
57  return _wrap_py_return_val;
58 }
59 
60 
61 // Wrap select MPI functions with NVTX ranges
62 /* ================== C Wrappers for MPI_Send ================== */
63 _EXTERN_C_ int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm);
64 _EXTERN_C_ int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) {
65  int _wrap_py_return_val = 0;
66  if (in_wrapper) return PMPI_Send(buf, count, datatype, dest, tag, comm);
67  in_wrapper = 1;
68 
69  nvtxEventAttributes_t eventAttrib = {0};
70  eventAttrib.version = NVTX_VERSION;
71  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
72  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
73  eventAttrib.message.ascii = "MPI_Send";
74  eventAttrib.category = 999;
75  eventAttrib.colorType = NVTX_COLOR_ARGB; \
76  eventAttrib.color = 0xffffaa00; \
77 
78  nvtxRangePushEx(&eventAttrib);
79  _wrap_py_return_val = PMPI_Send(buf, count, datatype, dest, tag, comm);
80  nvtxRangePop();
81  in_wrapper = 0;
82  return _wrap_py_return_val;
83 }
84 
85 /* ================== C Wrappers for MPI_Recv ================== */
86 _EXTERN_C_ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status);
87 _EXTERN_C_ int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) {
88  int _wrap_py_return_val = 0;
89  if (in_wrapper) return PMPI_Recv(buf, count, datatype, source, tag, comm, status);
90  in_wrapper = 1;
91 
92  nvtxEventAttributes_t eventAttrib = {0};
93  eventAttrib.version = NVTX_VERSION;
94  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
95  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
96  eventAttrib.message.ascii = "MPI_Recv";
97  eventAttrib.category = 999;
98  eventAttrib.colorType = NVTX_COLOR_ARGB; \
99  eventAttrib.color = 0xffffaa00; \
100 
101  nvtxRangePushEx(&eventAttrib);
102  _wrap_py_return_val = PMPI_Recv(buf, count, datatype, source, tag, comm, status);
103  nvtxRangePop();
104  in_wrapper = 0;
105  return _wrap_py_return_val;
106 }
107 
108 /* ================== C Wrappers for MPI_Allreduce ================== */
109 _EXTERN_C_ int PMPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
110 _EXTERN_C_ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) {
111  int _wrap_py_return_val = 0;
112  if (in_wrapper) return PMPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
113  in_wrapper = 1;
114 
115  nvtxEventAttributes_t eventAttrib = {0};
116  eventAttrib.version = NVTX_VERSION;
117  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
118  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
119  eventAttrib.message.ascii = "MPI_Allreduce";
120  eventAttrib.category = 999;
121  eventAttrib.colorType = NVTX_COLOR_ARGB; \
122  eventAttrib.color = 0xffffaa00; \
123 
124  nvtxRangePushEx(&eventAttrib);
125  _wrap_py_return_val = PMPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm);
126  nvtxRangePop();
127  in_wrapper = 0;
128  return _wrap_py_return_val;
129 }
130 
131 /* ================== C Wrappers for MPI_Reduce ================== */
132 _EXTERN_C_ int PMPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
133 _EXTERN_C_ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) {
134  int _wrap_py_return_val = 0;
135  if (in_wrapper) return PMPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
136  in_wrapper = 1;
137 
138  nvtxEventAttributes_t eventAttrib = {0};
139  eventAttrib.version = NVTX_VERSION;
140  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
141  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
142  eventAttrib.message.ascii = "MPI_Reduce";
143  eventAttrib.category = 999;
144  eventAttrib.colorType = NVTX_COLOR_ARGB; \
145  eventAttrib.color = 0xffffaa00; \
146 
147  nvtxRangePushEx(&eventAttrib);
148  _wrap_py_return_val = PMPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
149  nvtxRangePop();
150  in_wrapper = 0;
151  return _wrap_py_return_val;
152 }
153 
154 /* ================== C Wrappers for MPI_Wait ================== */
155 _EXTERN_C_ int PMPI_Wait(MPI_Request *request, MPI_Status *status);
156 _EXTERN_C_ int MPI_Wait(MPI_Request *request, MPI_Status *status) {
157  int _wrap_py_return_val = 0;
158  if (in_wrapper) return PMPI_Wait(request, status);
159  in_wrapper = 1;
160 
161  nvtxEventAttributes_t eventAttrib = {0};
162  eventAttrib.version = NVTX_VERSION;
163  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
164  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
165  eventAttrib.message.ascii = "MPI_Wait";
166  eventAttrib.category = 999;
167  eventAttrib.colorType = NVTX_COLOR_ARGB; \
168  eventAttrib.color = 0xffffaa00; \
169 
170  nvtxRangePushEx(&eventAttrib);
171  _wrap_py_return_val = PMPI_Wait(request, status);
172  nvtxRangePop();
173  in_wrapper = 0;
174  return _wrap_py_return_val;
175 }
176 
177 /* ================== C Wrappers for MPI_Waitany ================== */
178 _EXTERN_C_ int PMPI_Waitany(int count, MPI_Request array_of_requests[], int *index, MPI_Status *status);
179 _EXTERN_C_ int MPI_Waitany(int count, MPI_Request array_of_requests[], int *index, MPI_Status *status) {
180  int _wrap_py_return_val = 0;
181  if (in_wrapper) return PMPI_Waitany(count, array_of_requests, index, status);
182  in_wrapper = 1;
183 
184  nvtxEventAttributes_t eventAttrib = {0};
185  eventAttrib.version = NVTX_VERSION;
186  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
187  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
188  eventAttrib.message.ascii = "MPI_Waitany";
189  eventAttrib.category = 999;
190  eventAttrib.colorType = NVTX_COLOR_ARGB; \
191  eventAttrib.color = 0xffffaa00; \
192 
193  nvtxRangePushEx(&eventAttrib);
194  _wrap_py_return_val = PMPI_Waitany(count, array_of_requests, index, status);
195  nvtxRangePop();
196  in_wrapper = 0;
197  return _wrap_py_return_val;
198 }
199 
200 /* ================== C Wrappers for MPI_Waitall ================== */
201 _EXTERN_C_ int PMPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status *array_of_statuses);
202 _EXTERN_C_ int MPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status *array_of_statuses) {
203  int _wrap_py_return_val = 0;
204  if (in_wrapper) return PMPI_Waitall(count, array_of_requests, array_of_statuses);
205  in_wrapper = 1;
206 
207  nvtxEventAttributes_t eventAttrib = {0};
208  eventAttrib.version = NVTX_VERSION;
209  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
210  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
211  eventAttrib.message.ascii = "MPI_Waitall";
212  eventAttrib.category = 999;
213  eventAttrib.colorType = NVTX_COLOR_ARGB; \
214  eventAttrib.color = 0xffffaa00; \
215 
216  nvtxRangePushEx(&eventAttrib);
217  _wrap_py_return_val = PMPI_Waitall(count, array_of_requests, array_of_statuses);
218  nvtxRangePop();
219  in_wrapper = 0;
220  return _wrap_py_return_val;
221 }
222 
223 /* ================== C Wrappers for MPI_Waitsome ================== */
224 _EXTERN_C_ int PMPI_Waitsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[]);
225 _EXTERN_C_ int MPI_Waitsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[]) {
226  int _wrap_py_return_val = 0;
227  if (in_wrapper) return PMPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses);
228  in_wrapper = 1;
229 
230  nvtxEventAttributes_t eventAttrib = {0};
231  eventAttrib.version = NVTX_VERSION;
232  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
233  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
234  eventAttrib.message.ascii = "MPI_Waitsome";
235  eventAttrib.category = 999;
236  eventAttrib.colorType = NVTX_COLOR_ARGB; \
237  eventAttrib.color = 0xffffaa00; \
238 
239  nvtxRangePushEx(&eventAttrib);
240  _wrap_py_return_val = PMPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses);
241  nvtxRangePop();
242  in_wrapper = 0;
243  return _wrap_py_return_val;
244 }
245 
246 /* ================== C Wrappers for MPI_Gather ================== */
247 _EXTERN_C_ int PMPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
248 _EXTERN_C_ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
249  int _wrap_py_return_val = 0;
250  if (in_wrapper) return PMPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
251  in_wrapper = 1;
252 
253  nvtxEventAttributes_t eventAttrib = {0};
254  eventAttrib.version = NVTX_VERSION;
255  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
256  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
257  eventAttrib.message.ascii = "MPI_Gather";
258  eventAttrib.category = 999;
259  eventAttrib.colorType = NVTX_COLOR_ARGB; \
260  eventAttrib.color = 0xffffaa00; \
261 
262  nvtxRangePushEx(&eventAttrib);
263  _wrap_py_return_val = PMPI_Gather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
264  nvtxRangePop();
265  in_wrapper = 0;
266  return _wrap_py_return_val;
267 }
268 
269 /* ================== C Wrappers for MPI_Gatherv ================== */
270 _EXTERN_C_ int PMPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm);
271 _EXTERN_C_ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm) {
272  int _wrap_py_return_val = 0;
273  if (in_wrapper) return PMPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm);
274  in_wrapper = 1;
275 
276  nvtxEventAttributes_t eventAttrib = {0};
277  eventAttrib.version = NVTX_VERSION;
278  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
279  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
280  eventAttrib.message.ascii = "MPI_Gatherv";
281  eventAttrib.category = 999;
282  eventAttrib.colorType = NVTX_COLOR_ARGB; \
283  eventAttrib.color = 0xffffaa00; \
284 
285  nvtxRangePushEx(&eventAttrib);
286  _wrap_py_return_val = PMPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm);
287  nvtxRangePop();
288  in_wrapper = 0;
289  return _wrap_py_return_val;
290 }
291 
292 /* ================== C Wrappers for MPI_Scatter ================== */
293 _EXTERN_C_ int PMPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
294 _EXTERN_C_ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
295  int _wrap_py_return_val = 0;
296  if (in_wrapper) return PMPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
297  in_wrapper = 1;
298 
299  nvtxEventAttributes_t eventAttrib = {0};
300  eventAttrib.version = NVTX_VERSION;
301  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
302  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
303  eventAttrib.message.ascii = "MPI_Scatter";
304  eventAttrib.category = 999;
305  eventAttrib.colorType = NVTX_COLOR_ARGB; \
306  eventAttrib.color = 0xffffaa00; \
307 
308  nvtxRangePushEx(&eventAttrib);
309  _wrap_py_return_val = PMPI_Scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
310  nvtxRangePop();
311  in_wrapper = 0;
312  return _wrap_py_return_val;
313 }
314 
315 /* ================== C Wrappers for MPI_Scatterv ================== */
316 _EXTERN_C_ int PMPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
317 _EXTERN_C_ int MPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm) {
318  int _wrap_py_return_val = 0;
319  if (in_wrapper) return PMPI_Scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm);
320  in_wrapper = 1;
321 
322  nvtxEventAttributes_t eventAttrib = {0};
323  eventAttrib.version = NVTX_VERSION;
324  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
325  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
326  eventAttrib.message.ascii = "MPI_Scatterv";
327  eventAttrib.category = 999;
328  eventAttrib.colorType = NVTX_COLOR_ARGB; \
329  eventAttrib.color = 0xffffaa00; \
330 
331  nvtxRangePushEx(&eventAttrib);
332  _wrap_py_return_val = PMPI_Scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm);
333  nvtxRangePop();
334  in_wrapper = 0;
335  return _wrap_py_return_val;
336 }
337 
338 /* ================== C Wrappers for MPI_Allgather ================== */
339 _EXTERN_C_ int PMPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
340 _EXTERN_C_ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
341  int _wrap_py_return_val = 0;
342  if (in_wrapper) return PMPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
343  in_wrapper = 1;
344 
345  nvtxEventAttributes_t eventAttrib = {0};
346  eventAttrib.version = NVTX_VERSION;
347  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
348  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
349  eventAttrib.message.ascii = "MPI_Allgather";
350  eventAttrib.category = 999;
351  eventAttrib.colorType = NVTX_COLOR_ARGB; \
352  eventAttrib.color = 0xffffaa00; \
353 
354  nvtxRangePushEx(&eventAttrib);
355  _wrap_py_return_val = PMPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
356  nvtxRangePop();
357  in_wrapper = 0;
358  return _wrap_py_return_val;
359 }
360 
361 /* ================== C Wrappers for MPI_Allgatherv ================== */
362 _EXTERN_C_ int PMPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm);
363 _EXTERN_C_ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm) {
364  int _wrap_py_return_val = 0;
365  if (in_wrapper) return PMPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
366  in_wrapper = 1;
367 
368  nvtxEventAttributes_t eventAttrib = {0};
369  eventAttrib.version = NVTX_VERSION;
370  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
371  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
372  eventAttrib.message.ascii = "MPI_Allgatherv";
373  eventAttrib.category = 999;
374  eventAttrib.colorType = NVTX_COLOR_ARGB; \
375  eventAttrib.color = 0xffffaa00; \
376 
377  nvtxRangePushEx(&eventAttrib);
378  _wrap_py_return_val = PMPI_Allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
379  nvtxRangePop();
380  in_wrapper = 0;
381  return _wrap_py_return_val;
382 }
383 
384 /* ================== C Wrappers for MPI_Alltoall ================== */
385 _EXTERN_C_ int PMPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
386 _EXTERN_C_ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm) {
387  int _wrap_py_return_val = 0;
388  if (in_wrapper) return PMPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
389  in_wrapper = 1;
390 
391  nvtxEventAttributes_t eventAttrib = {0};
392  eventAttrib.version = NVTX_VERSION;
393  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
394  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
395  eventAttrib.message.ascii = "MPI_Alltoall";
396  eventAttrib.category = 999;
397  eventAttrib.colorType = NVTX_COLOR_ARGB; \
398  eventAttrib.color = 0xffffaa00; \
399 
400  nvtxRangePushEx(&eventAttrib);
401  _wrap_py_return_val = PMPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
402  nvtxRangePop();
403  in_wrapper = 0;
404  return _wrap_py_return_val;
405 }
406 
407 /* ================== C Wrappers for MPI_Alltoallv ================== */
408 _EXTERN_C_ int PMPI_Alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm);
409 _EXTERN_C_ int MPI_Alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm) {
410  int _wrap_py_return_val = 0;
411  if (in_wrapper) return PMPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispls, recvtype, comm);
412  in_wrapper = 1;
413 
414  nvtxEventAttributes_t eventAttrib = {0};
415  eventAttrib.version = NVTX_VERSION;
416  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
417  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
418  eventAttrib.message.ascii = "MPI_Alltoallv";
419  eventAttrib.category = 999;
420  eventAttrib.colorType = NVTX_COLOR_ARGB; \
421  eventAttrib.color = 0xffffaa00; \
422 
423  nvtxRangePushEx(&eventAttrib);
424  _wrap_py_return_val = PMPI_Alltoallv(sendbuf, sendcounts, sdispls, sendtype, recvbuf, recvcounts, rdispls, recvtype, comm);
425  nvtxRangePop();
426  in_wrapper = 0;
427  return _wrap_py_return_val;
428 }
429 
430 /* ================== C Wrappers for MPI_Alltoallw ================== */
431 _EXTERN_C_ int PMPI_Alltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm);
432 _EXTERN_C_ int MPI_Alltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm) {
433  int _wrap_py_return_val = 0;
434  if (in_wrapper) return PMPI_Alltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm);
435  in_wrapper = 1;
436 
437  nvtxEventAttributes_t eventAttrib = {0};
438  eventAttrib.version = NVTX_VERSION;
439  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
440  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
441  eventAttrib.message.ascii = "MPI_Alltoallw";
442  eventAttrib.category = 999;
443  eventAttrib.colorType = NVTX_COLOR_ARGB; \
444  eventAttrib.color = 0xffffaa00; \
445 
446  nvtxRangePushEx(&eventAttrib);
447  _wrap_py_return_val = PMPI_Alltoallw(sendbuf, sendcounts, sdispls, sendtypes, recvbuf, recvcounts, rdispls, recvtypes, comm);
448  nvtxRangePop();
449  in_wrapper = 0;
450  return _wrap_py_return_val;
451 }
452 
453 /* ================== C Wrappers for MPI_Bcast ================== */
454 _EXTERN_C_ int PMPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
455 _EXTERN_C_ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) {
456  int _wrap_py_return_val = 0;
457  if (in_wrapper) return PMPI_Bcast(buffer, count, datatype, root, comm);
458  in_wrapper = 1;
459 
460  nvtxEventAttributes_t eventAttrib = {0};
461  eventAttrib.version = NVTX_VERSION;
462  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
463  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
464  eventAttrib.message.ascii = "MPI_Bcast";
465  eventAttrib.category = 999;
466  eventAttrib.colorType = NVTX_COLOR_ARGB; \
467  eventAttrib.color = 0xffffaa00; \
468 
469  nvtxRangePushEx(&eventAttrib);
470  _wrap_py_return_val = PMPI_Bcast(buffer, count, datatype, root, comm);
471  nvtxRangePop();
472  in_wrapper = 0;
473  return _wrap_py_return_val;
474 }
475 
476 /* ================== C Wrappers for MPI_Sendrecv ================== */
477 _EXTERN_C_ int PMPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status);
478 _EXTERN_C_ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status) {
479  int _wrap_py_return_val = 0;
480  if (in_wrapper) return PMPI_Sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status);
481  in_wrapper = 1;
482 
483  nvtxEventAttributes_t eventAttrib = {0};
484  eventAttrib.version = NVTX_VERSION;
485  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
486  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
487  eventAttrib.message.ascii = "MPI_Sendrecv";
488  eventAttrib.category = 999;
489  eventAttrib.colorType = NVTX_COLOR_ARGB; \
490  eventAttrib.color = 0xffffaa00; \
491 
492  nvtxRangePushEx(&eventAttrib);
493  _wrap_py_return_val = PMPI_Sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status);
494  nvtxRangePop();
495  in_wrapper = 0;
496  return _wrap_py_return_val;
497 }
498 
499 /* ================== C Wrappers for MPI_Barrier ================== */
500 _EXTERN_C_ int PMPI_Barrier(MPI_Comm comm);
501 _EXTERN_C_ int MPI_Barrier(MPI_Comm comm) {
502  int _wrap_py_return_val = 0;
503  if (in_wrapper) return PMPI_Barrier(comm);
504  in_wrapper = 1;
505 
506  nvtxEventAttributes_t eventAttrib = {0};
507  eventAttrib.version = NVTX_VERSION;
508  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
509  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
510  eventAttrib.message.ascii = "MPI_Barrier";
511  eventAttrib.category = 999;
512  eventAttrib.colorType = NVTX_COLOR_ARGB; \
513  eventAttrib.color = 0xffffaa00; \
514 
515  nvtxRangePushEx(&eventAttrib);
516  _wrap_py_return_val = PMPI_Barrier(comm);
517  nvtxRangePop();
518  in_wrapper = 0;
519  return _wrap_py_return_val;
520 }
521 
522 /* ================== C Wrappers for MPI_Start ================== */
523 _EXTERN_C_ int PMPI_Start(MPI_Request *request);
524 _EXTERN_C_ int MPI_Start(MPI_Request *request) {
525  int _wrap_py_return_val = 0;
526  if (in_wrapper) return PMPI_Start(request);
527  in_wrapper = 1;
528 
529  nvtxEventAttributes_t eventAttrib = {0};
530  eventAttrib.version = NVTX_VERSION;
531  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
532  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
533  eventAttrib.message.ascii = "MPI_Start";
534  eventAttrib.category = 999;
535  eventAttrib.colorType = NVTX_COLOR_ARGB; \
536  eventAttrib.color = 0xffffaa00; \
537 
538  nvtxRangePushEx(&eventAttrib);
539  _wrap_py_return_val = PMPI_Start(request);
540  nvtxRangePop();
541  in_wrapper = 0;
542  return _wrap_py_return_val;
543 }
544 
545 /* ================== C Wrappers for MPI_Test ================== */
546 _EXTERN_C_ int PMPI_Test(MPI_Request *request, int *flag, MPI_Status *status);
547 _EXTERN_C_ int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status) {
548  int _wrap_py_return_val = 0;
549  if (in_wrapper) return PMPI_Test(request, flag, status);
550  in_wrapper = 1;
551 
552  nvtxEventAttributes_t eventAttrib = {0};
553  eventAttrib.version = NVTX_VERSION;
554  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
555  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
556  eventAttrib.message.ascii = "MPI_Test";
557  eventAttrib.category = 999;
558  eventAttrib.colorType = NVTX_COLOR_ARGB; \
559  eventAttrib.color = 0xffffaa00; \
560 
561  nvtxRangePushEx(&eventAttrib);
562  _wrap_py_return_val = PMPI_Test(request, flag, status);
563  nvtxRangePop();
564  in_wrapper = 0;
565  return _wrap_py_return_val;
566 }
567 
568 /* ================== C Wrappers for MPI_Send_init ================== */
569 _EXTERN_C_ int PMPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request);
570 _EXTERN_C_ int MPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request) {
571  int _wrap_py_return_val = 0;
572  if (in_wrapper) return PMPI_Send_init(buf, count, datatype, dest, tag, comm, request);
573  in_wrapper = 1;
574 
575  nvtxEventAttributes_t eventAttrib = {0};
576  eventAttrib.version = NVTX_VERSION;
577  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
578  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
579  eventAttrib.message.ascii = "MPI_Send_init";
580  eventAttrib.category = 999;
581  eventAttrib.colorType = NVTX_COLOR_ARGB; \
582  eventAttrib.color = 0xffffaa00; \
583 
584  nvtxRangePushEx(&eventAttrib);
585  _wrap_py_return_val = PMPI_Send_init(buf, count, datatype, dest, tag, comm, request);
586  nvtxRangePop();
587  in_wrapper = 0;
588  return _wrap_py_return_val;
589 }
590 
591 /* ================== C Wrappers for MPI_Recv_init ================== */
592 _EXTERN_C_ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request);
593 _EXTERN_C_ int MPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request) {
594  int _wrap_py_return_val = 0;
595  if (in_wrapper) return PMPI_Recv_init(buf, count, datatype, source, tag, comm, request);
596  in_wrapper = 1;
597 
598  nvtxEventAttributes_t eventAttrib = {0};
599  eventAttrib.version = NVTX_VERSION;
600  eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
601  eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
602  eventAttrib.message.ascii = "MPI_Recv_init";
603  eventAttrib.category = 999;
604  eventAttrib.colorType = NVTX_COLOR_ARGB; \
605  eventAttrib.color = 0xffffaa00; \
606 
607  nvtxRangePushEx(&eventAttrib);
608  _wrap_py_return_val = PMPI_Recv_init(buf, count, datatype, source, tag, comm, request);
609  nvtxRangePop();
610  in_wrapper = 0;
611  return _wrap_py_return_val;
612 }
613 
614 
_EXTERN_C_ void pmpi_init(MPI_Fint *ierr)
_EXTERN_C_ int MPI_Start(MPI_Request *request)
Definition: nvtx_pmpi.c:524
_EXTERN_C_ int PMPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
_EXTERN_C_ int MPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:248
_EXTERN_C_ int PMPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
_EXTERN_C_ int MPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request)
Definition: nvtx_pmpi.c:593
_EXTERN_C_ int MPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:294
_EXTERN_C_ int MPI_Init(int *argc, char ***argv)
Definition: nvtx_pmpi.c:42
_EXTERN_C_ int PMPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
_EXTERN_C_ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
Definition: nvtx_pmpi.c:386
_EXTERN_C_ int PMPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
_EXTERN_C_ int MPI_Waitany(int count, MPI_Request array_of_requests[], int *index, MPI_Status *status)
Definition: nvtx_pmpi.c:179
_EXTERN_C_ int MPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:271
_EXTERN_C_ int PMPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm)
_EXTERN_C_ int PMPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
_EXTERN_C_ int MPI_Alltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm)
Definition: nvtx_pmpi.c:432
_EXTERN_C_ int MPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)
Definition: nvtx_pmpi.c:570
_EXTERN_C_ int PMPI_Waitsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[])
_EXTERN_C_ int PMPI_Alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm)
_EXTERN_C_ int MPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
Definition: nvtx_pmpi.c:340
_EXTERN_C_ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request)
_EXTERN_C_ void PMPI_INIT(MPI_Fint *ierr)
_EXTERN_C_ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:455
_EXTERN_C_ int PMPI_Alltoallw(const void *sendbuf, const int sendcounts[], const int sdispls[], const MPI_Datatype sendtypes[], void *recvbuf, const int recvcounts[], const int rdispls[], const MPI_Datatype recvtypes[], MPI_Comm comm)
_EXTERN_C_ int PMPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
_EXTERN_C_ int PMPI_Test(MPI_Request *request, int *flag, MPI_Status *status)
_EXTERN_C_ int MPI_Wait(MPI_Request *request, MPI_Status *status)
Definition: nvtx_pmpi.c:156
_EXTERN_C_ int PMPI_Init(int *argc, char ***argv)
_EXTERN_C_ int MPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status *array_of_statuses)
Definition: nvtx_pmpi.c:202
_EXTERN_C_ int PMPI_Waitany(int count, MPI_Request array_of_requests[], int *index, MPI_Status *status)
_EXTERN_C_ int PMPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm)
_EXTERN_C_ int PMPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
_EXTERN_C_ int MPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:133
_EXTERN_C_ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)
Definition: nvtx_pmpi.c:478
_EXTERN_C_ int PMPI_Start(MPI_Request *request)
_EXTERN_C_ int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Definition: nvtx_pmpi.c:87
_EXTERN_C_ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
_EXTERN_C_ int PMPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, int root, MPI_Comm comm)
#define _EXTERN_C_
Definition: nvtx_pmpi.c:9
_EXTERN_C_ int MPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int displs[], MPI_Datatype recvtype, MPI_Comm comm)
Definition: nvtx_pmpi.c:363
_EXTERN_C_ int PMPI_Wait(MPI_Request *request, MPI_Status *status)
_EXTERN_C_ int MPI_Waitsome(int incount, MPI_Request array_of_requests[], int *outcount, int array_of_indices[], MPI_Status array_of_statuses[])
Definition: nvtx_pmpi.c:225
_EXTERN_C_ int PMPI_Barrier(MPI_Comm comm)
_EXTERN_C_ int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Definition: nvtx_pmpi.c:64
_EXTERN_C_ int PMPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
_EXTERN_C_ void pmpi_init_(MPI_Fint *ierr)
_EXTERN_C_ int PMPI_Send_init(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)
_EXTERN_C_ void pmpi_init__(MPI_Fint *ierr)
_EXTERN_C_ int MPI_Alltoallv(const void *sendbuf, const int sendcounts[], const int sdispls[], MPI_Datatype sendtype, void *recvbuf, const int recvcounts[], const int rdispls[], MPI_Datatype recvtype, MPI_Comm comm)
Definition: nvtx_pmpi.c:409
_EXTERN_C_ int PMPI_Waitall(int count, MPI_Request array_of_requests[], MPI_Status *array_of_statuses)
_EXTERN_C_ int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
Definition: nvtx_pmpi.c:110
_EXTERN_C_ int MPI_Barrier(MPI_Comm comm)
Definition: nvtx_pmpi.c:501
_EXTERN_C_ int PMPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
_EXTERN_C_ int MPI_Scatterv(const void *sendbuf, const int sendcounts[], const int displs[], MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)
Definition: nvtx_pmpi.c:317
_EXTERN_C_ int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status)
Definition: nvtx_pmpi.c:547