forked from RWTH-HPC/OTF-CPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathman-wrappers.cpp
310 lines (265 loc) · 9.55 KB
/
man-wrappers.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#ifndef NOTOOL
#include <assert.h>
#include <mpi.h>
#include <stdio.h>
#include "mpi-critical.h"
#include "tracking.h"
/* ================== C Wrappers for MPI_Type_create_struct ==================
*/
int PMPI_Type_create_struct(int count, const int array_of_blocklengths[],
const MPI_Aint array_of_displacements[],
const MPI_Datatype array_of_types[],
MPI_Datatype *newtype);
int MPI_Type_create_struct(int count, const int array_of_blocklengths[],
const MPI_Aint array_of_displacements[],
const MPI_Datatype array_of_types[],
MPI_Datatype *newtype) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_TYPE
MPI_Datatype myTypes[count];
for (int i = 0; i < count; i++) {
myTypes[i] = tf.getHandle(array_of_types[i]);
}
#else
const MPI_Datatype *myTypes = array_of_types;
#endif
_wrap_py_return_val = PMPI_Type_create_struct(
count, array_of_blocklengths, array_of_displacements, myTypes, newtype);
postType(newtype);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Type_get_contents ================== */
int PMPI_Type_get_contents(MPI_Datatype datatype, int max_integers,
int max_addresses, int max_datatypes,
int array_of_integers[],
MPI_Aint array_of_addresses[],
MPI_Datatype array_of_datatypes[]);
int MPI_Type_get_contents(MPI_Datatype datatype, int max_integers,
int max_addresses, int max_datatypes,
int array_of_integers[],
MPI_Aint array_of_addresses[],
MPI_Datatype array_of_datatypes[]) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
preType(datatype);
#ifdef HANDLE_TYPE
MPI_Datatype myTypes[max_datatypes] = {MPI_DATATYPE_NULL};
#else
MPI_Datatype *myTypes = array_of_datatypes;
#endif
_wrap_py_return_val = PMPI_Type_get_contents(
datatype, max_integers, max_addresses, max_datatypes, array_of_integers,
array_of_addresses, myTypes);
#ifdef HANDLE_TYPE
for (int i = 0; i < max_datatypes; i++) {
array_of_datatypes[i] = tf.newHandle(myTypes[i]);
}
#endif
return _wrap_py_return_val;
}
#ifdef HAVE_COUNT
/* ================== C Wrappers for MPI_Type_struct ================== */
int PMPI_Type_struct(int count, int array_of_blocklengths[],
MPI_Aint array_of_displacements[],
MPI_Datatype array_of_types[], MPI_Datatype *newtype);
int MPI_Type_struct(int count, int array_of_blocklengths[],
MPI_Aint array_of_displacements[],
MPI_Datatype array_of_types[], MPI_Datatype *newtype) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_TYPE
MPI_Datatype myTypes[count];
for (int i = 0; i < count; i++) {
myTypes[i] = tf.getHandle(array_of_types[i]);
}
#else
MPI_Datatype *myTypes = array_of_types;
#endif
_wrap_py_return_val = PMPI_Type_struct(
count, array_of_blocklengths, array_of_displacements, myTypes, newtype);
postType(newtype);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Type_create_struct_c ==================
*/
int PMPI_Type_create_struct_c(MPI_Count count,
const MPI_Count array_of_blocklengths[],
const MPI_Count array_of_displacements[],
const MPI_Datatype array_of_types[],
MPI_Datatype *newtype);
int MPI_Type_create_struct_c(MPI_Count count,
const MPI_Count array_of_blocklengths[],
const MPI_Count array_of_displacements[],
const MPI_Datatype array_of_types[],
MPI_Datatype *newtype) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_TYPE
MPI_Datatype myTypes[count];
for (int i = 0; i < count; i++) {
myTypes[i] = tf.getHandle(array_of_types[i]);
}
#else
const MPI_Datatype *myTypes = array_of_types;
#endif
_wrap_py_return_val = PMPI_Type_create_struct_c(
count, array_of_blocklengths, array_of_displacements, myTypes, newtype);
postType(newtype);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Type_get_contents_c ==================
*/
int PMPI_Type_get_contents_c(MPI_Datatype datatype, MPI_Count max_integers,
MPI_Count max_addresses,
MPI_Count max_large_counts,
MPI_Count max_datatypes, int array_of_integers[],
MPI_Aint array_of_addresses[],
MPI_Count array_of_large_counts[],
MPI_Datatype array_of_datatypes[]);
int MPI_Type_get_contents_c(MPI_Datatype datatype, MPI_Count max_integers,
MPI_Count max_addresses, MPI_Count max_large_counts,
MPI_Count max_datatypes, int array_of_integers[],
MPI_Aint array_of_addresses[],
MPI_Count array_of_large_counts[],
MPI_Datatype array_of_datatypes[]) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
preType(datatype);
#ifdef HANDLE_TYPE
MPI_Datatype myTypes[max_datatypes] = {MPI_DATATYPE_NULL};
#else
MPI_Datatype *myTypes = array_of_datatypes;
#endif
_wrap_py_return_val = PMPI_Type_get_contents_c(
datatype, max_integers, max_addresses, max_large_counts, max_datatypes,
array_of_integers, array_of_addresses, array_of_large_counts, myTypes);
#ifdef HANDLE_TYPE
for (int i = 0; i < max_datatypes; i++) {
array_of_datatypes[i] = tf.newHandle(myTypes[i]);
}
#endif
return _wrap_py_return_val;
}
#endif
////////////////////
// FREE functions
////////////////////
/* ================== C Wrappers for MPI_Group_free ================== */
int PMPI_Group_free(MPI_Group *group);
int MPI_Group_free(MPI_Group *group) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_GROUP
MPI_Group myGrp = gf.getHandle(*group);
*group = gf.freeHandle(*group);
MPI_Group *myGrpP = &myGrp;
#else
MPI_Group *myGrpP = group;
#endif
_wrap_py_return_val = PMPI_Group_free(myGrpP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Op_free ================== */
int PMPI_Op_free(MPI_Op *op);
int MPI_Op_free(MPI_Op *op) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_OP
MPI_Op myOp = of.getHandle(*op);
*op = of.freeHandle(*op);
MPI_Op *myOpP = &myOp;
#else
MPI_Op *myOpP = op;
#endif
_wrap_py_return_val = PMPI_Op_free(myOpP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Win_free ================== */
int PMPI_Win_free(MPI_Win *win);
int MPI_Win_free(MPI_Win *win) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_WIN
MPI_Win myWin = wf.getHandle(*win);
*win = wf.freeHandle(*win);
MPI_Win *myWinP = &myWin;
#else
MPI_Win *myWinP = win;
#endif
_wrap_py_return_val = PMPI_Win_free(myWinP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Comm_free ================== */
int PMPI_Comm_free(MPI_Comm *comm);
int MPI_Comm_free(MPI_Comm *comm) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_COMM
MPI_Comm myComm = cf.getHandle(*comm);
*comm = cf.freeHandle(*comm);
MPI_Comm *myCommP = &myComm;
#else
MPI_Comm *myCommP = comm;
#endif
_wrap_py_return_val = PMPI_Comm_free(myCommP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Comm_disconnect ================== */
int PMPI_Comm_disconnect(MPI_Comm *comm);
int MPI_Comm_disconnect(MPI_Comm *comm) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_COMM
MPI_Comm myComm = cf.getHandle(*comm);
*comm = cf.freeHandle(*comm);
MPI_Comm *myCommP = &myComm;
#else
MPI_Comm *myCommP = comm;
#endif
_wrap_py_return_val = PMPI_Comm_disconnect(myCommP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Type_free ================== */
int PMPI_Type_free(MPI_Datatype *datatype);
int MPI_Type_free(MPI_Datatype *datatype) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_TYPE
MPI_Datatype myType = tf.getHandle(*datatype);
*datatype = tf.freeHandle(*datatype);
MPI_Datatype *myTypeP = &myType;
#else
MPI_Datatype *myTypeP = datatype;
#endif
_wrap_py_return_val = PMPI_Type_free(myTypeP);
return _wrap_py_return_val;
}
/* ================== C Wrappers for MPI_Type_commit ================== */
int PMPI_Type_commit(MPI_Datatype *datatype);
int MPI_Type_commit(MPI_Datatype *datatype) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
preType(*datatype);
_wrap_py_return_val = PMPI_Type_commit(datatype);
postType(datatype);
return _wrap_py_return_val;
}
#ifdef HAVE_SESSION
/* ================== C Wrappers for MPI_Session_finalize ================== */
int PMPI_Session_finalize(MPI_Session *session);
int MPI_Session_finalize(MPI_Session *session) {
mpiTimer mt{false, __func__};
int _wrap_py_return_val = 0;
#ifdef HANDLE_SESSION
MPI_Session mySession = sf.getHandle(*session);
*session = sf.freeHandle(*session);
MPI_Session *mySessionP = &mySession;
#else
MPI_Session *mySessionP = session;
#endif
_wrap_py_return_val = PMPI_Session_finalize(mySessionP);
return _wrap_py_return_val;
}
#endif
#endif