source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/lib/mct/mpi-serial/mpi.h @ 6331

Last change on this file since 6331 was 6331, checked in by aclsce, 17 months ago

Moved oasis-mct_5.0 in oasis3-mct/branches directory.

File size: 15.7 KB
Line 
1#ifndef _MPI_H_
2#define _MPI_H_
3
4#define MPI_MAX_LIBRARY_VERSION_STRING (80)
5
6typedef int MPI_Comm;
7typedef int MPI_Request;
8
9
10#define MPI_COMM_WORLD (1)
11#define MPI_COMM_NULL (0)      /* handle 0 maps to NULL */
12
13
14typedef int MPI_Group;
15
16/* MPI_GROUP_EMPTY and MPI_GROUP_NULL must not conflict with MPI_GROUP_ONE */
17#define MPI_GROUP_EMPTY (-1)
18#define MPI_GROUP_NULL  (0)
19
20
21/*
22 * Return codes
23 *   On error, mpi-serial aborts so the values don't really matter
24 *   as long as they are different than MPI_SUCCESS
25 *
26 */
27
28#define MPI_SUCCESS        (0)
29#define MPI_ERR_BUFFER     (-1)
30#define MPI_ERR_COUNT      (-1)
31#define MPI_ERR_TYPE       (-1)
32#define MPI_ERR_TAG        (-1)
33#define MPI_ERR_COMM       (-1)
34#define MPI_ERR_RANK       (-1)
35#define MPI_ERR_REQUEST    (-1)
36#define MPI_ERR_ROOT       (-1)
37#define MPI_ERR_GROUP      (-1)
38#define MPI_ERR_OP         (-1)
39#define MPI_ERR_TOPOLOGY   (-1)
40#define MPI_ERR_DIMS       (-1)
41#define MPI_ERR_ARG        (-1)
42#define MPI_ERR_UNKNOWN    (-1)
43#define MPI_ERR_TRUNCATE   (-1)
44#define MPI_ERR_OTHER      (-1)
45#define MPI_ERR_INTERN     (-1)
46#define MPI_PENDING        (-1)
47#define MPI_ERR_IN_STATUS  (-1)
48#define MPI_ERR_LASTCODE   (-1)
49
50/*
51 * MPI_UNDEFINED
52 *
53 * Uses:
54 *   value for "color" in e.g. comm_split
55 *   value for rank in Group_translate_ranks
56 *
57 */
58
59
60#define MPI_UNDEFINED (-1)
61
62
63/*
64 * Data types etc.
65 */
66
67typedef unsigned long int MPI_Aint;
68#define MPI_BOTTOM (0)
69#define MPI_IN_PLACE (void *)(-1)
70typedef int MPI_Datatype;
71
72
73/* The type's value is now a handle */
74
75#define MPI_DATATYPE_NULL   (0)
76
77//C types
78#define MPI_CHAR            (-1)
79#define MPI_SHORT           (-2)
80#define MPI_INT             (-3)
81#define MPI_LONG            (-4)
82#define MPI_UNSIGNED_CHAR   (-5)
83#define MPI_UNSIGNED_SHORT  (-6)
84#define MPI_UNSIGNED        (-7)
85#define MPI_UNSIGNED_LONG   (-8)
86#define MPI_FLOAT           (-9)
87#define MPI_DOUBLE          (-10)
88#define MPI_LONG_DOUBLE     (-11)
89
90//Cross-language
91#define MPI_BYTE            (-12)
92#define MPI_PACKED          (-13)
93#define MPI_LB              (-14)
94#define MPI_UB              (-15)
95
96// Fortran types
97#define MPI_INTEGER           (-16)     // RML: why not (MPI_INT)
98#define MPI_REAL              (-17)     // RML: why not (MPI_FLOAT)
99#define MPI_DOUBLE_PRECISION  (-18)     // RML: why not (MPI_DOUBLE)
100
101#define MPI_COMPLEX           (-19)
102#define MPI_DOUBLE_COMPLEX    (-20)
103#define MPI_LOGICAL           (-21)
104#define MPI_CHARACTER         (-22)
105#define MPI_2REAL             (-23)
106#define MPI_2DOUBLE_PRECISION (-24)
107#define MPI_2INTEGER          (-25)
108
109//Reduction function types
110
111#define MPI_FLOAT_INT       (-26)
112#define MPI_DOUBLE_INT      (-27)
113#define MPI_LONG_INT        (-28)
114#define MPI_2INT            (-29)
115#define MPI_SHORT_INT       (-30)
116#define MPI_LONG_DOUBLE_INT (-31)
117
118
119/* Fortran size-specific types */
120
121#define MPI_INTEGER1       (-32)
122#define MPI_INTEGER2       (-33)
123#define MPI_INTEGER4       (-34)
124#define MPI_INTEGER8       (-35)
125#define MPI_INTEGER16      (-36)
126
127#define MPI_REAL4          (-37)
128#define MPI_REAL8          (-38)
129#define MPI_REAL16         (-39)
130
131#define MPI_COMPLEX8       (-40)
132#define MPI_COMPLEX16      (-41)
133#define MPI_COMPLEX32      (-42)
134
135/* Some more types */
136
137#define MPI_LONG_LONG_INT       (-43)
138#define MPI_LONG_LONG           MPI_LONG_LONG_INT
139#define MPI_UNSIGNED_LONG_LONG  (-44)
140
141#define MPI_OFFSET              (-45)
142
143
144/*
145 * Fortran int size
146 *
147 */
148
149typedef int MPI_Fint;
150
151
152
153#define MPI_ANY_TAG (-1)
154
155#define MPI_ANY_SOURCE (-1)
156#define MPI_PROC_NULL (-2)
157#define MPI_ROOT (-3)
158
159#define MPI_REQUEST_NULL (0)
160
161#define MPI_MAX_ERROR_STRING (128)
162#define MPI_MAX_PROCESSOR_NAME (128)
163
164#define MPI_THREAD_SINGLE (0)
165#define MPI_THREAD_FUNNELED (1)
166#define MPI_THREAD_SERIALIZED (2)
167#define MPI_THREAD_MULTIPLE (3)
168
169/*
170 * MPI_Status
171 *
172 * definition must be compatible with the mpif.h values for
173 * MPI_STATUS_SIZE, MPI_SOURCE, MPI_TAG, and MPI_ERROR.
174 *
175 * Note: The type used for MPI_Status_int must be chosen to match
176 * Fortran INTEGER.
177 *
178 */
179
180typedef int MPI_Status_int;
181
182typedef struct                  /* Fortran: INTEGER status(MPI_STATUS_SIZE) */
183{
184  MPI_Status_int MPI_SOURCE;    /* Fortran: status(MPI_SOURCE) */
185  MPI_Status_int MPI_TAG;       /* Fortran: status(MPI_TAG) */
186  MPI_Status_int MPI_ERROR;     /* Fortran: status(MPI_ERROR) */
187  int            get_count;     /* Number specified for send */
188
189} MPI_Status;
190
191
192#define MPI_STATUS_IGNORE    ((MPI_Status *)0)
193#define MPI_STATUSES_IGNORE  ((MPI_Status *)0)
194
195
196/*
197 * MPI Errhandling stubs (Not functional currently)
198 */
199typedef int MPI_Errhandler;
200
201#define MPI_ERRORS_ARE_FATAL ((MPI_Errhandler)0)
202#define MPI_ERRORS_RETURN    ((MPI_Errhandler)-1)
203
204
205/*
206 * Collective operations
207 */
208
209
210typedef int MPI_Op;
211
212typedef void MPI_User_function( void *invec, void *inoutvec, int *len,
213                                MPI_Datatype *datatype);
214
215#define MPI_OP_NULL (0)
216
217#define MPI_MAX     (0)
218#define MPI_MIN     (0)
219#define MPI_SUM     (0)
220#define MPI_PROD    (0)
221#define MPI_LAND    (0)
222#define MPI_BAND    (0)
223#define MPI_LOR     (0)
224#define MPI_BOR     (0)
225#define MPI_LXOR    (0)
226#define MPI_BXOR    (0)
227#define MPI_MAXLOC  (0)
228#define MPI_MINLOC  (0)
229
230
231
232#define MPI_STATUS_SIZE       (sizeof(MPI_Status) / sizeof(int))
233
234
235/* NOTE: the C type MPI_Offset is NOT the same as MPI datatype MPI_OFFSET */
236typedef long long int MPI_Offset;
237
238
239/* info
240 */
241
242typedef int MPI_Info;         /* handle */
243
244#define MPI_INFO_NULL (0)
245
246
247
248/**********************************************************
249 *
250 * Note: if you need to regenerate the prototypes below,
251 * you can use 'protify.awk' and paste the output here.
252 *
253 */
254
255
256extern int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader,
257                          MPI_Comm peer_comm, int remote_leader,
258                          int tag, MPI_Comm *newintercomm);
259extern int MPI_Intercomm_merge(MPI_Comm intercomm, int high,
260                               MPI_Comm *newintercomm);
261extern int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims,
262                        int *periods, int reorder, MPI_Comm *comm_cart);
263extern int MPI_Cart_get(MPI_Comm comm, int maxdims, int *dims,
264                        int *periods, int *coords);
265extern int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims,
266                        int *coords);
267extern int MPI_Dims_create(int nnodes, int ndims, int *dims);
268
269extern int MPI_Barrier(MPI_Comm comm );
270extern int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype,
271                     int root, MPI_Comm comm );
272extern int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
273                      void* recvbuf, int recvcount, MPI_Datatype recvtype,
274                      int root, MPI_Comm comm);
275extern int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
276                       void* recvbuf, int *recvcounts, int *displs,
277                       MPI_Datatype recvtype, int root, MPI_Comm comm);
278extern int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
279                         void* recvbuf, int recvcount, MPI_Datatype recvtype,
280                         MPI_Comm comm);
281extern int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
282                          void* recvbuf, int *recvcounts, int *displs,
283                          MPI_Datatype recvtype, MPI_Comm comm);
284extern int MPI_Scatter( void* sendbuf, int sendcount, MPI_Datatype sendtype,
285                        void* recvbuf, int recvcount, MPI_Datatype recvtype,
286                        int root, MPI_Comm comm);
287extern int MPI_Scatterv(void* sendbuf, int *sendcounts, int *displs,
288                        MPI_Datatype sendtype, void* recvbuf, int recvcount,
289                        MPI_Datatype recvtype, int root, MPI_Comm comm);
290extern int MPI_Reduce(void* sendbuf, void* recvbuf, int count,
291                      MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
292extern int MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int *recvcounts,
293                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
294extern int MPI_Allreduce(void* sendbuf, void* recvbuf, int count,
295                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
296extern int MPI_Scan( void* sendbuf, void* recvbuf, int count,
297                    MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
298extern int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype,
299                        void *recvbuf, int recvcount, MPI_Datatype recvtype,
300                        MPI_Comm comm);
301extern int MPI_Alltoallv(void *sendbuf, int *sendcounts,
302                         int *sdispls, MPI_Datatype sendtype,
303                         void *recvbuf, int *recvcounts,
304                         int *rdispls, MPI_Datatype recvtype,
305                         MPI_Comm comm) ;
306extern int MPI_Alltoallw(void *sendbuf, int *sendcounts,
307                         int *sdispls, MPI_Datatype *sendtypes,
308                         void *recvbuf, int *recvcounts,
309                         int *rdispls, MPI_Datatype *recvtypes,
310                         MPI_Comm comm) ;
311
312
313extern int MPI_Op_create(MPI_User_function *function, int commute,
314                         MPI_Op *op);
315extern MPI_Op MPI_Op_f2c(MPI_Fint op);
316extern MPI_Fint MPI_Op_c2f(MPI_Op op);
317extern MPI_Comm mpi_comm_new(void);
318extern int MPI_Op_free(MPI_Op *op);
319extern int MPI_Comm_free(MPI_Comm *comm);
320extern int MPI_Comm_size(MPI_Comm comm, int *size);
321extern int MPI_Comm_rank(MPI_Comm comm, int *rank);
322extern int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm);
323extern int MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *newcomm);
324extern int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm);
325extern int MPI_Comm_group(MPI_Comm comm, MPI_Group *group);
326extern MPI_Comm MPI_Comm_f2c(MPI_Fint comm);
327extern MPI_Fint MPI_Comm_c2f(MPI_Comm comm);
328extern int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup);
329extern int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
330                         MPI_Group *newgroup);
331extern int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup);
332extern int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
333                                  MPI_Group *newgroup);
334extern int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
335                         MPI_Group *newgroup);
336extern int MPI_Group_free(MPI_Group *group);
337extern int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
338                                     MPI_Group group2, int *ranks2);
339extern MPI_Group MPI_Group_f2c(MPI_Fint group);
340extern MPI_Fint MPI_Group_c2f(MPI_Group group);
341
342extern int MPI_Init(int *argc, char **argv[]) ;
343extern int MPI_Finalize(void);
344extern int MPI_Abort(MPI_Comm comm, int errorcode);
345extern int MPI_Error_string(int errorcode, char *string, int *resultlen);
346extern int MPI_Get_processor_name(char *name, int *resultlen);
347
348extern int MPI_Info_create(MPI_Info *info);
349extern int MPI_Info_set(MPI_Info info, char *key, char *value);
350
351extern int MPI_Initialized(int *flag);
352extern int MPI_Pack( void *inbuf, int incount, MPI_Datatype datatype,
353                     void *outbuf, int outsize, int *position, MPI_Comm comm);
354extern int MPI_Unpack( void *inbuf, int insize, int *position,
355                       void *outbuf, int outcount, MPI_Datatype datatype,
356                       MPI_Comm comm );
357extern int MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
358                     int source, int tag, MPI_Comm comm, MPI_Request *request);
359extern int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source,
360                    int tag, MPI_Comm comm, MPI_Status *status);
361
362extern int MPI_Test(MPI_Request *request, int *flag, MPI_Status *status);
363extern int MPI_Wait(MPI_Request *request, MPI_Status *status);
364extern int MPI_Testany(int count,  MPI_Request *array_of_requests,
365                       int *index, int *flag, MPI_Status *status);
366extern int MPI_Waitany(int count, MPI_Request *array_of_requests,
367                       int *index, MPI_Status *status);
368extern int MPI_Testall(int count, MPI_Request *array_of_requests,
369                       int *flag, MPI_Status *array_of_statuses);
370extern int MPI_Waitall(int count, MPI_Request *array_of_requests,
371                       MPI_Status *array_of_statuses);
372extern MPI_Request MPI_Request_f2c(MPI_Fint request);
373extern MPI_Fint MPI_Request_c2f(MPI_Request request);
374extern int MPI_Testsome(int incount, MPI_Request *array_of_requests,
375                        int *outcount, int *array_of_indices,
376                        MPI_Status *array_of_statuses);
377extern int MPI_Waitsome(int incount, MPI_Request *array_of_requests,
378                        int *outcount, int *array_of_indices,
379                        MPI_Status *array_of_statuses);
380extern int MPI_Request_free(MPI_Request * req);
381extern int MPI_Isend(void *buf, int count, MPI_Datatype datatype,
382                     int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
383extern int MPI_Send(void* buf, int count, MPI_Datatype datatype,
384                    int dest, int tag, MPI_Comm comm);
385extern int MPI_Ssend(void* buf, int count, MPI_Datatype datatype,
386                     int dest, int tag, MPI_Comm comm);
387extern int MPI_Rsend(void* buf, int count, MPI_Datatype datatype,
388                     int dest, int tag, MPI_Comm comm);
389extern int MPI_Irsend(void *buf, int count, MPI_Datatype datatype,
390                     int dest, int tag, MPI_Comm comm, MPI_Request *request) ;
391extern int MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
392                        int dest, int sendtag,
393                        void *recvbuf, int recvcount, MPI_Datatype recvtype,
394                        int source, int recvtag,
395                        MPI_Comm comm, MPI_Status *status);
396
397extern int MPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status *status);
398extern int MPI_Iprobe(int source, int tag, MPI_Comm comm,
399                      int *flag, MPI_Status *status);
400
401extern int MPI_Pack_size(int incount, MPI_Datatype type, MPI_Comm comm, MPI_Aint * size);
402
403/* Error handling stub, not currently functional */
404extern int MPI_Errhandler_set(MPI_Comm comm, MPI_Errhandler handle);
405
406/* new type functions */
407extern int MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count);
408extern int MPI_Get_elements(MPI_Status *status, MPI_Datatype datatype, int *count);
409extern int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype);
410
411extern int MPI_Type_vector(int count, int blocklen, int stride, MPI_Datatype oldtype,
412                           MPI_Datatype *newtype);
413
414extern int MPI_Type_hvector(int count, int blocklen, MPI_Aint stride,
415                            MPI_Datatype oldtype, MPI_Datatype *newtype);
416
417extern int MPI_Type_create_hvector(int count, int blocklen, MPI_Aint stride,
418                            MPI_Datatype oldtype, MPI_Datatype *newtype);
419
420extern int MPI_Type_indexed(int count, int *blocklens, int *displacements,
421                            MPI_Datatype oldtype, MPI_Datatype *newtype);
422
423extern int MPI_Type_create_indexed_block(int count, int blocklen, int *displacements,
424                                  MPI_Datatype oldtype, MPI_Datatype *newtype);
425extern int MPI_Type_hindexed(int count, int *blocklens, MPI_Aint *displacements,
426                             MPI_Datatype oldtype, MPI_Datatype *newtype);
427extern int MPI_Type_size(MPI_Datatype type, int * size);
428extern int MPI_Type_struct(int count, int *blocklens, MPI_Aint *displacements,
429                           MPI_Datatype *oldtypes, MPI_Datatype *newtype);
430extern int MPI_Type_dup(MPI_Datatype oldtype, MPI_Datatype *newtype);
431
432extern int MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent);
433extern int MPI_Type_commit(MPI_Datatype * datatype);
434extern int MPI_Type_free(MPI_Datatype * datatype);
435extern int MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * lb);
436extern int MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * ub);
437
438extern double MPI_Wtime(void);
439
440#endif
Note: See TracBrowser for help on using the repository browser.