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