-
Notifications
You must be signed in to change notification settings - Fork 10
/
mpi.h
441 lines (351 loc) · 15.8 KB
/
mpi.h
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
#ifndef _MPI_H_
#define _MPI_H_
#define MPI_MAX_LIBRARY_VERSION_STRING (80)
typedef int MPI_Comm;
typedef int MPI_Request;
#define MPI_COMM_WORLD (1)
#define MPI_COMM_NULL (0) /* handle 0 maps to NULL */
typedef int MPI_Group;
/* MPI_GROUP_EMPTY and MPI_GROUP_NULL must not conflict with MPI_GROUP_ONE */
#define MPI_GROUP_EMPTY (-1)
#define MPI_GROUP_NULL (0)
/*
* Return codes
* On error, mpi-serial aborts so the values don't really matter
* as long as they are different than MPI_SUCCESS
*
*/
#define MPI_SUCCESS (0)
#define MPI_ERR_BUFFER (-1)
#define MPI_ERR_COUNT (-1)
#define MPI_ERR_TYPE (-1)
#define MPI_ERR_TAG (-1)
#define MPI_ERR_COMM (-1)
#define MPI_ERR_RANK (-1)
#define MPI_ERR_REQUEST (-1)
#define MPI_ERR_ROOT (-1)
#define MPI_ERR_GROUP (-1)
#define MPI_ERR_OP (-1)
#define MPI_ERR_TOPOLOGY (-1)
#define MPI_ERR_DIMS (-1)
#define MPI_ERR_ARG (-1)
#define MPI_ERR_UNKNOWN (-1)
#define MPI_ERR_TRUNCATE (-1)
#define MPI_ERR_OTHER (-1)
#define MPI_ERR_INTERN (-1)
#define MPI_PENDING (-1)
#define MPI_ERR_IN_STATUS (-1)
#define MPI_ERR_LASTCODE (-1)
/*
* MPI_UNDEFINED
*
* Uses:
* value for "color" in e.g. comm_split
* value for rank in Group_translate_ranks
*
*/
#define MPI_UNDEFINED (-1)
/*
* Data types etc.
*/
typedef unsigned long int MPI_Aint;
#define MPI_BOTTOM (0)
#define MPI_IN_PLACE (void *)(-1)
typedef int MPI_Datatype;
/* The type's value is now a handle */
#define MPI_DATATYPE_NULL (0)
//C types
#define MPI_CHAR (-1)
#define MPI_SIGNED_CHAR (-46)
#define MPI_WCHAR (-47)
#define MPI_SHORT (-2)
#define MPI_INT (-3)
#define MPI_LONG (-4)
#define MPI_UNSIGNED_CHAR (-5)
#define MPI_UNSIGNED_SHORT (-6)
#define MPI_UNSIGNED (-7)
#define MPI_UNSIGNED_LONG (-8)
#define MPI_FLOAT (-9)
#define MPI_DOUBLE (-10)
#define MPI_LONG_DOUBLE (-11)
//Cross-language
#define MPI_BYTE (-12)
#define MPI_PACKED (-13)
#define MPI_LB (-14)
#define MPI_UB (-15)
// Fortran types
#define MPI_INTEGER (-16) // RML: why not (MPI_INT)
#define MPI_REAL (-17) // RML: why not (MPI_FLOAT)
#define MPI_DOUBLE_PRECISION (-18) // RML: why not (MPI_DOUBLE)
#define MPI_COMPLEX (-19)
#define MPI_DOUBLE_COMPLEX (-20)
#define MPI_LOGICAL (-21)
#define MPI_CHARACTER (-22)
#define MPI_2REAL (-23)
#define MPI_2DOUBLE_PRECISION (-24)
#define MPI_2INTEGER (-25)
//Reduction function types
#define MPI_FLOAT_INT (-26)
#define MPI_DOUBLE_INT (-27)
#define MPI_LONG_INT (-28)
#define MPI_2INT (-29)
#define MPI_SHORT_INT (-30)
#define MPI_LONG_DOUBLE_INT (-31)
/* Fortran size-specific types */
#define MPI_INTEGER1 (-32)
#define MPI_INTEGER2 (-33)
#define MPI_INTEGER4 (-34)
#define MPI_INTEGER8 (-35)
#define MPI_INTEGER16 (-36)
#define MPI_REAL4 (-37)
#define MPI_REAL8 (-38)
#define MPI_REAL16 (-39)
#define MPI_COMPLEX8 (-40)
#define MPI_COMPLEX16 (-41)
#define MPI_COMPLEX32 (-42)
/* Some more types */
#define MPI_LONG_LONG_INT (-43)
#define MPI_LONG_LONG MPI_LONG_LONG_INT
#define MPI_UNSIGNED_LONG_LONG (-44)
#define MPI_OFFSET (-45)
/*
* Fortran int size
*
*/
typedef int MPI_Fint;
#define MPI_ANY_TAG (-1)
#define MPI_ANY_SOURCE (-1)
#define MPI_PROC_NULL (-2)
#define MPI_ROOT (-3)
#define MPI_REQUEST_NULL (0)
#define MPI_MAX_ERROR_STRING (128)
#define MPI_MAX_PROCESSOR_NAME (128)
#define MPI_THREAD_SINGLE (0)
#define MPI_THREAD_FUNNELED (1)
#define MPI_THREAD_SERIALIZED (2)
#define MPI_THREAD_MULTIPLE (3)
/*
* MPI_Status
*
* definition must be compatible with the mpif.h values for
* MPI_STATUS_SIZE, MPI_SOURCE, MPI_TAG, and MPI_ERROR.
*
* Note: The type used for MPI_Status_int must be chosen to match
* Fortran INTEGER.
*
*/
typedef int MPI_Status_int;
typedef struct /* Fortran: INTEGER status(MPI_STATUS_SIZE) */
{
MPI_Status_int MPI_SOURCE; /* Fortran: status(MPI_SOURCE) */
MPI_Status_int MPI_TAG; /* Fortran: status(MPI_TAG) */
MPI_Status_int MPI_ERROR; /* Fortran: status(MPI_ERROR) */
int get_count; /* Number specified for send */
} MPI_Status;
#define MPI_STATUS_IGNORE ((MPI_Status *)0)
#define MPI_STATUSES_IGNORE ((MPI_Status *)0)
/*
* MPI Errhandling stubs (Not functional currently)
*/
typedef int MPI_Errhandler;
#define MPI_ERRORS_ARE_FATAL ((MPI_Errhandler)0)
#define MPI_ERRORS_RETURN ((MPI_Errhandler)-1)
/*
* Collective operations
*/
typedef int MPI_Op;
typedef void MPI_User_function( void *invec, void *inoutvec, int *len,
MPI_Datatype *datatype);
#define MPI_OP_NULL (0)
#define MPI_MAX (0)
#define MPI_MIN (0)
#define MPI_SUM (0)
#define MPI_PROD (0)
#define MPI_LAND (0)
#define MPI_BAND (0)
#define MPI_LOR (0)
#define MPI_BOR (0)
#define MPI_LXOR (0)
#define MPI_BXOR (0)
#define MPI_MAXLOC (0)
#define MPI_MINLOC (0)
#define MPI_STATUS_SIZE (sizeof(MPI_Status) / sizeof(int))
/* NOTE: the C type MPI_Offset is NOT the same as MPI datatype MPI_OFFSET */
typedef long long int MPI_Offset;
/* info
*/
typedef int MPI_Info; /* handle */
#define MPI_INFO_NULL (0)
/**********************************************************
*
* Note: if you need to regenerate the prototypes below,
* you can use 'protify.awk' and paste the output here.
*
*/
extern int MPI_Get_library_version(char *version, int *resultlen);
extern int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader,
MPI_Comm peer_comm, int remote_leader,
int tag, MPI_Comm *newintercomm);
extern int MPI_Intercomm_merge(MPI_Comm intercomm, int high,
MPI_Comm *newintercomm);
extern int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims,
int *periods, int reorder, MPI_Comm *comm_cart);
extern int MPI_Cart_get(MPI_Comm comm, int maxdims, int *dims,
int *periods, int *coords);
extern int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims,
int *coords);
extern int MPI_Dims_create(int nnodes, int ndims, int *dims);
extern int MPI_Barrier(MPI_Comm comm );
extern int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype,
int root, MPI_Comm comm );
extern int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
void* recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm);
extern int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
void* recvbuf, int *recvcounts, int *displs,
MPI_Datatype recvtype, int root, MPI_Comm comm);
extern int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
void* recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
extern int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
void* recvbuf, int *recvcounts, int *displs,
MPI_Datatype recvtype, MPI_Comm comm);
extern int MPI_Scatter( void* sendbuf, int sendcount, MPI_Datatype sendtype,
void* recvbuf, int recvcount, MPI_Datatype recvtype,
int root, MPI_Comm comm);
extern int MPI_Scatterv(void* sendbuf, int *sendcounts, int *displs,
MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, int root, MPI_Comm comm);
extern int MPI_Reduce(void* sendbuf, void* recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
extern int MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int *recvcounts,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
extern int MPI_Allreduce(void* sendbuf, void* recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
extern int MPI_Scan( void* sendbuf, void* recvbuf, int count,
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
extern int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
void *recvbuf, int recvcount, MPI_Datatype recvtype,
MPI_Comm comm);
extern int MPI_Alltoallv(void *sendbuf, int *sendcounts,
int *sdispls, MPI_Datatype sendtype,
void *recvbuf, int *recvcounts,
int *rdispls, MPI_Datatype recvtype,
MPI_Comm comm) ;
extern int MPI_Alltoallw(void *sendbuf, int *sendcounts,
int *sdispls, MPI_Datatype *sendtypes,
void *recvbuf, int *recvcounts,
int *rdispls, MPI_Datatype *recvtypes,
MPI_Comm comm) ;
extern int MPI_Op_create(MPI_User_function *function, int commute,
MPI_Op *op);
extern MPI_Op MPI_Op_f2c(MPI_Fint op);
extern MPI_Fint MPI_Op_c2f(MPI_Op op);
extern MPI_Comm mpi_comm_new(void);
extern int MPI_Op_free(MPI_Op *op);
extern int MPI_Comm_free(MPI_Comm *comm);
extern int MPI_Comm_size(MPI_Comm comm, int *size);
extern int MPI_Comm_rank(MPI_Comm comm, int *rank);
extern int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
extern int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm);
extern int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm);
extern int MPI_Comm_group(MPI_Comm comm, MPI_Group *group);
extern MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
extern MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
extern int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup);
extern int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
MPI_Group *newgroup);
extern int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup);
extern int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
MPI_Group *newgroup);
extern int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
MPI_Group *newgroup);
extern int MPI_Group_free(MPI_Group *group);
extern int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
MPI_Group group2, int *ranks2);
extern MPI_Group MPI_Group_f2c(MPI_Fint group);
extern MPI_Fint MPI_Group_c2f(MPI_Group group);
extern int MPI_Init(int *argc, char **argv[]) ;
extern int MPI_Finalize(void);
extern int MPI_Abort(MPI_Comm comm, int errorcode);
extern int MPI_Error_string(int errorcode, char *string, int *resultlen);
extern int MPI_Get_processor_name(char *name, int *resultlen);
extern int MPI_Info_create(MPI_Info *info);
extern int MPI_Info_set(MPI_Info info, char *key, char *value);
extern int MPI_Initialized(int *flag);
extern int MPI_Pack( void *inbuf, int incount, MPI_Datatype datatype,
void *outbuf, int outsize, int *position, MPI_Comm comm);
extern int MPI_Unpack( void *inbuf, int insize, int *position,
void *outbuf, int outcount, MPI_Datatype datatype,
MPI_Comm comm );
extern int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
int source, int tag, MPI_Comm comm, MPI_Request *request);
extern int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
int tag, MPI_Comm comm, MPI_Status *status);
extern int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status);
extern int MPI_Wait(MPI_Request *request, MPI_Status *status);
extern int MPI_Testany(int count, MPI_Request *array_of_requests,
int *index, int *flag, MPI_Status *status);
extern int MPI_Waitany(int count, MPI_Request *array_of_requests,
int *index, MPI_Status *status);
extern int MPI_Testall(int count, MPI_Request *array_of_requests,
int *flag, MPI_Status *array_of_statuses);
extern int MPI_Waitall(int count, MPI_Request *array_of_requests,
MPI_Status *array_of_statuses);
extern MPI_Request MPI_Request_f2c(MPI_Fint request);
extern MPI_Fint MPI_Request_c2f(MPI_Request request);
extern int MPI_Testsome(int incount, MPI_Request *array_of_requests,
int *outcount, int *array_of_indices,
MPI_Status *array_of_statuses);
extern int MPI_Waitsome(int incount, MPI_Request *array_of_requests,
int *outcount, int *array_of_indices,
MPI_Status *array_of_statuses);
extern int MPI_Request_free(MPI_Request * req);
extern int MPI_Isend(void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
extern int MPI_Send(void* buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm);
extern int MPI_Ssend(void* buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm);
extern int MPI_Rsend(void* buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm);
extern int MPI_Irsend(void *buf, int count, MPI_Datatype datatype,
int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
extern int MPI_Sendrecv(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 int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status);
extern int MPI_Iprobe(int source, int tag, MPI_Comm comm,
int *flag, MPI_Status *status);
extern int MPI_Pack_size(int incount, MPI_Datatype type, MPI_Comm comm, MPI_Aint * size);
/* Error handling stub, not currently functional */
extern int MPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler handle);
/* new type functions */
extern int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count);
extern int MPI_Get_elements(MPI_Status *status, MPI_Datatype datatype, int *count);
extern int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype oldtype,
MPI_Datatype *newtype);
extern int MPI_Type_hvector(int count, int blocklen, MPI_Aint stride,
MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride,
MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_indexed(int count, int *blocklens, int *displacements,
MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_create_indexed_block(int count, int blocklen, int *displacements,
MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_hindexed(int count, int *blocklens, MPI_Aint *displacements,
MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_size(MPI_Datatype type, int * size);
extern int MPI_Type_struct(int count, int *blocklens, MPI_Aint *displacements,
MPI_Datatype *oldtypes, MPI_Datatype *newtype);
extern int MPI_Type_dup(MPI_Datatype oldtype, MPI_Datatype *newtype);
extern int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent);
extern int MPI_Type_commit(MPI_Datatype * datatype);
extern int MPI_Type_free(MPI_Datatype * datatype);
extern int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * lb);
extern int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * ub);
extern double MPI_Wtime(void);
#endif