Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b3cfb99f0b16c32fd23d4c0a78348735e783350d
[simgrid.git] / include / smpi / smpi.h
1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SMPI_H
8 #define SMPI_H
9
10 #include <stddef.h>
11 #include <sys/time.h>
12 #include <xbt/misc.h>
13 #include <xbt/function_types.h>
14
15
16 #ifdef _WIN32
17 #define MPI_CALL(type,name,args) \
18   type name args; \
19   type P##name args
20 #else
21 #define MPI_CALL(type,name,args) \
22   type name args __attribute__((weak)); \
23   type P##name args
24 #endif
25
26 SG_BEGIN_DECL()
27 #define MPI_THREAD_SINGLE     0
28 #define MPI_THREAD_FUNNELED   1
29 #define MPI_THREAD_SERIALIZED 2
30 #define MPI_THREAD_MULTIPLE   3
31 //FIXME: check values
32 #define MPI_MAX_PROCESSOR_NAME 100
33 #define MPI_MAX_NAME_STRING    100
34 #define MPI_MAX_ERROR_STRING   100
35 #define MPI_MAX_DATAREP_STRIN  100
36 #define MPI_MAX_INFO_KEY       100
37 #define MPI_MAX_INFO_VAL       100
38 #define MPI_MAX_OBJECT_NAME    100
39 #define MPI_MAX_PORT_NAME      100
40 #define SMPI_RAND_SEED 5
41 #define MPI_ANY_SOURCE -1
42 #define MPI_BOTTOM (void *)0
43 #define MPI_PROC_NULL -2
44 #define MPI_ANY_TAG -1
45 #define MPI_UNDEFINED -3
46 // errorcodes
47 #define MPI_SUCCESS       0
48 #define MPI_ERR_COMM      1
49 #define MPI_ERR_ARG       2
50 #define MPI_ERR_TYPE      3
51 #define MPI_ERR_REQUEST   4
52 #define MPI_ERR_INTERN    5
53 #define MPI_ERR_COUNT     6
54 #define MPI_ERR_RANK      7
55 #define MPI_ERR_TAG       8
56 #define MPI_ERR_TRUNCATE  9
57 #define MPI_ERR_GROUP    10
58 #define MPI_ERR_OP       11
59 #define MPI_ERR_OTHER    12
60 #define MPI_ERR_IN_STATUS 13
61 #define MPI_ERR_PENDING   14
62 #define MPI_IDENT     0
63 #define MPI_SIMILAR   1
64 #define MPI_UNEQUAL   2
65 #define MPI_CONGRUENT 3
66 #define MPI_WTIME_IS_GLOBAL 1
67 #define MPI_TAG_UB           1000000
68 #define MPI_HOST             0
69 #define MPI_IO               0
70 #define MPI_BSEND_OVERHEAD   0
71
72 typedef enum MPIR_Topo_type {
73   MPI_GRAPH=1,
74   MPI_CART=2,
75   MPI_DIST_GRAPH=3
76 } MPIR_Topo_type;
77
78 typedef ptrdiff_t MPI_Aint;
79 typedef long long MPI_Offset;
80
81 struct s_smpi_mpi_datatype;
82 typedef struct s_smpi_mpi_datatype *MPI_Datatype;
83
84 typedef struct {
85   int MPI_SOURCE;
86   int MPI_TAG;
87   int MPI_ERROR;
88   int count;
89 } MPI_Status;
90
91 #define MPI_STATUS_IGNORE NULL
92 #define MPI_STATUSES_IGNORE NULL
93
94 #define MPI_DATATYPE_NULL NULL
95 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_CHAR;
96 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_SHORT;
97 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT;
98 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_LONG;
99 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_LONG_LONG;
100 #define MPI_LONG_LONG_INT MPI_LONG_LONG
101 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_SIGNED_CHAR;
102 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UNSIGNED_CHAR;
103 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UNSIGNED_SHORT;
104 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UNSIGNED;
105 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UNSIGNED_LONG;
106 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UNSIGNED_LONG_LONG;
107 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_FLOAT;
108 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_DOUBLE;
109 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_LONG_DOUBLE;
110 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_WCHAR;
111 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_C_BOOL;
112 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT8_T;
113 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT16_T;
114 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT32_T;
115 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_INT64_T;
116 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT8_T;
117 #define MPI_BYTE MPI_UINT8_T
118 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT16_T;
119 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT32_T;
120 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UINT64_T;
121 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_C_FLOAT_COMPLEX;
122 #define MPI_C_COMPLEX MPI_C_FLOAT_COMPLEX
123 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_C_DOUBLE_COMPLEX;
124 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_C_LONG_DOUBLE_COMPLEX;
125 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_AINT;
126 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_OFFSET;
127 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_LB;
128 XBT_PUBLIC_DATA( MPI_Datatype ) MPI_UB;
129 //The following are datatypes for the MPI functions MPI_MAXLOC  and MPI_MINLOC.
130 XBT_PUBLIC_DATA(MPI_Datatype) MPI_FLOAT_INT;
131 XBT_PUBLIC_DATA(MPI_Datatype) MPI_LONG_INT;
132 XBT_PUBLIC_DATA(MPI_Datatype) MPI_DOUBLE_INT;
133 XBT_PUBLIC_DATA(MPI_Datatype) MPI_SHORT_INT;
134 XBT_PUBLIC_DATA(MPI_Datatype) MPI_2INT;
135 XBT_PUBLIC_DATA(MPI_Datatype) MPI_LONG_DOUBLE_INT;
136 XBT_PUBLIC_DATA(MPI_Datatype) MPI_2FLOAT;
137 XBT_PUBLIC_DATA(MPI_Datatype) MPI_2DOUBLE;
138
139 typedef void MPI_User_function(void *invec, void *inoutvec, int *len,
140                                MPI_Datatype * datatype);
141 struct s_smpi_mpi_op;
142 typedef struct s_smpi_mpi_op *MPI_Op;
143
144 #define MPI_OP_NULL NULL
145 XBT_PUBLIC_DATA( MPI_Op ) MPI_MAX;
146 XBT_PUBLIC_DATA( MPI_Op ) MPI_MIN;
147 XBT_PUBLIC_DATA( MPI_Op ) MPI_MAXLOC;
148 XBT_PUBLIC_DATA( MPI_Op ) MPI_MINLOC;
149 XBT_PUBLIC_DATA( MPI_Op ) MPI_SUM;
150 XBT_PUBLIC_DATA( MPI_Op ) MPI_PROD;
151 XBT_PUBLIC_DATA( MPI_Op ) MPI_LAND;
152 XBT_PUBLIC_DATA( MPI_Op ) MPI_LOR;
153 XBT_PUBLIC_DATA( MPI_Op ) MPI_LXOR;
154 XBT_PUBLIC_DATA( MPI_Op ) MPI_BAND;
155 XBT_PUBLIC_DATA( MPI_Op ) MPI_BOR;
156 XBT_PUBLIC_DATA( MPI_Op ) MPI_BXOR;
157
158 struct s_smpi_mpi_group;
159 typedef struct s_smpi_mpi_group *MPI_Group;
160
161 #define MPI_GROUP_NULL NULL
162
163 XBT_PUBLIC_DATA( MPI_Group ) MPI_GROUP_EMPTY;
164
165 struct s_smpi_mpi_communicator;
166 typedef struct s_smpi_mpi_communicator *MPI_Comm;
167
168 #define MPI_COMM_NULL NULL
169 XBT_PUBLIC_DATA( MPI_Comm ) MPI_COMM_WORLD;
170 #define MPI_COMM_SELF smpi_process_comm_self()
171
172 struct s_smpi_mpi_request;
173 typedef struct s_smpi_mpi_request *MPI_Request;
174
175 #define MPI_REQUEST_NULL NULL
176
177 MPI_CALL(XBT_PUBLIC(int), MPI_Init, (int *argc, char ***argv));
178 MPI_CALL(XBT_PUBLIC(int), MPI_Finalize, (void));
179 MPI_CALL(XBT_PUBLIC(int), MPI_Init_thread,
180                             (int *argc, char ***argv, int required,
181                              int *provided));
182 MPI_CALL(XBT_PUBLIC(int), MPI_Query_thread, (int *provided));
183 MPI_CALL(XBT_PUBLIC(int), MPI_Is_thread_main, (int *flag));
184 MPI_CALL(XBT_PUBLIC(int), MPI_Abort, (MPI_Comm comm, int errorcode));
185 MPI_CALL(XBT_PUBLIC(double), MPI_Wtime, (void));
186 MPI_CALL(XBT_PUBLIC(double), MPI_Wtick,(void));
187 MPI_CALL(XBT_PUBLIC(int), MPI_Address, (void *location, MPI_Aint * address));
188
189 MPI_CALL(XBT_PUBLIC(int), MPI_Type_free, (MPI_Datatype * datatype));
190 MPI_CALL(XBT_PUBLIC(int), MPI_Type_size, (MPI_Datatype datatype, int *size));
191 MPI_CALL(XBT_PUBLIC(int), MPI_Type_get_extent,
192                             (MPI_Datatype datatype, MPI_Aint * lb,
193                              MPI_Aint * extent));
194 MPI_CALL(XBT_PUBLIC(int), MPI_Type_extent, (MPI_Datatype datatype, MPI_Aint * extent));
195 MPI_CALL(XBT_PUBLIC(int), MPI_Type_lb, (MPI_Datatype datatype, MPI_Aint * disp));
196 MPI_CALL(XBT_PUBLIC(int), MPI_Type_ub, (MPI_Datatype datatype, MPI_Aint * disp));
197 MPI_CALL(XBT_PUBLIC(int), MPI_Type_commit, (MPI_Datatype* datatype));
198 MPI_CALL(XBT_PUBLIC(int), MPI_Type_hindexed,
199                             (int count, int* blocklens, MPI_Aint* indices,
200                             MPI_Datatype old_type, MPI_Datatype* newtype));
201 MPI_CALL(XBT_PUBLIC(int), MPI_Type_hvector,
202                             (int count, int blocklen, MPI_Aint stride,
203                              MPI_Datatype old_type, MPI_Datatype* newtype));
204 MPI_CALL(XBT_PUBLIC(int), MPI_Type_indexed,
205                             (int count, int* blocklens, int* indices,
206                              MPI_Datatype old_type, MPI_Datatype* newtype));
207 MPI_CALL(XBT_PUBLIC(int), MPI_Type_struct,
208                             (int count, int* blocklens, MPI_Aint* indices,
209                              MPI_Datatype* old_types, MPI_Datatype* newtype));
210 MPI_CALL(XBT_PUBLIC(int), MPI_Type_vector,
211                             (int count, int blocklen, int stride,
212                              MPI_Datatype old_type, MPI_Datatype* newtype));
213 MPI_CALL(XBT_PUBLIC(int), MPI_Type_contiguous,
214                             (int count, MPI_Datatype old_type,
215                              MPI_Datatype* newtype));
216 MPI_CALL(XBT_PUBLIC(int), MPI_Testall,
217                             (int count, MPI_Request* requests, int* flag,
218                              MPI_Status* statuses));
219 MPI_CALL(XBT_PUBLIC(int), MPI_Op_create,
220                             (MPI_User_function * function, int commute,
221                              MPI_Op * op));
222 MPI_CALL(XBT_PUBLIC(int), MPI_Op_free, (MPI_Op * op));
223
224 MPI_CALL(XBT_PUBLIC(int), MPI_Group_free, (MPI_Group * group));
225 MPI_CALL(XBT_PUBLIC(int), MPI_Group_size, (MPI_Group group, int *size));
226 MPI_CALL(XBT_PUBLIC(int), MPI_Group_rank, (MPI_Group group, int *rank));
227 MPI_CALL(XBT_PUBLIC(int), MPI_Group_translate_ranks,
228                             (MPI_Group group1, int n,
229                              int *ranks1, MPI_Group group2,
230                              int *ranks2));
231 MPI_CALL(XBT_PUBLIC(int), MPI_Group_compare,
232                             (MPI_Group group1, MPI_Group group2,
233                              int *result));
234 MPI_CALL(XBT_PUBLIC(int), MPI_Group_union,
235                             (MPI_Group group1, MPI_Group group2,
236                              MPI_Group * newgroup));
237 MPI_CALL(XBT_PUBLIC(int), MPI_Group_intersection,
238                             (MPI_Group group1, MPI_Group group2,
239                              MPI_Group * newgroup));
240 MPI_CALL(XBT_PUBLIC(int), MPI_Group_difference,
241                             (MPI_Group group1, MPI_Group group2,
242                              MPI_Group * newgroup));
243 MPI_CALL(XBT_PUBLIC(int), MPI_Group_incl,
244                             (MPI_Group group, int n, int *ranks,
245                              MPI_Group * newgroup));
246 MPI_CALL(XBT_PUBLIC(int), MPI_Group_excl,
247                             (MPI_Group group, int n, int *ranks,
248                              MPI_Group * newgroup));
249 MPI_CALL(XBT_PUBLIC(int), MPI_Group_range_incl,
250                             (MPI_Group group, int n, int ranges[][3],
251                              MPI_Group * newgroup));
252 MPI_CALL(XBT_PUBLIC(int), MPI_Group_range_excl,
253                             (MPI_Group group, int n, int ranges[][3],
254                              MPI_Group * newgroup));
255
256 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_rank, (MPI_Comm comm, int *rank));
257 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_size, (MPI_Comm comm, int *size));
258 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_name, (MPI_Comm comm, char* name, int* len));
259 MPI_CALL(XBT_PUBLIC(int), MPI_Get_processor_name, (char *name, int *resultlen));
260 MPI_CALL(XBT_PUBLIC(int), MPI_Get_count,
261                             (MPI_Status * status, MPI_Datatype datatype,
262                              int *count));
263
264 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_group, (MPI_Comm comm, MPI_Group * group));
265 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_compare,
266                             (MPI_Comm comm1, MPI_Comm comm2, int *result));
267 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_dup, (MPI_Comm comm, MPI_Comm * newcomm));
268 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_create,
269                             (MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm));
270 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_free, (MPI_Comm * comm));
271 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_disconnect, (MPI_Comm * comm));
272 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_split, (MPI_Comm comm, int color, int key, MPI_Comm* comm_out));
273
274 MPI_CALL(XBT_PUBLIC(int), MPI_Send_init,
275                             (void *buf, int count, MPI_Datatype datatype,
276                              int dst, int tag, MPI_Comm comm,
277                              MPI_Request * request));
278 MPI_CALL(XBT_PUBLIC(int), MPI_Recv_init,
279                             (void *buf, int count, MPI_Datatype datatype,
280                              int src, int tag, MPI_Comm comm,
281                              MPI_Request * request));
282 MPI_CALL(XBT_PUBLIC(int), MPI_Start, (MPI_Request * request));
283 MPI_CALL(XBT_PUBLIC(int), MPI_Startall, (int count, MPI_Request * requests));
284 MPI_CALL(XBT_PUBLIC(int), MPI_Request_free, (MPI_Request * request));
285 MPI_CALL(XBT_PUBLIC(int), MPI_Irecv,
286                             (void *buf, int count, MPI_Datatype datatype,
287                              int src, int tag, MPI_Comm comm,
288                              MPI_Request * request));
289 MPI_CALL(XBT_PUBLIC(int), MPI_Isend,
290                             (void *buf, int count, MPI_Datatype datatype,
291                              int dst, int tag, MPI_Comm comm,
292                              MPI_Request * request));
293 MPI_CALL(XBT_PUBLIC(int), MPI_Recv,
294                             (void *buf, int count, MPI_Datatype datatype,
295                              int src, int tag, MPI_Comm comm,
296                              MPI_Status * status));
297 MPI_CALL(XBT_PUBLIC(int), MPI_Send,
298                             (void *buf, int count, MPI_Datatype datatype,
299                              int dst, int tag, MPI_Comm comm));
300 MPI_CALL(XBT_PUBLIC(int), MPI_Sendrecv,
301                             (void *sendbuf, int sendcount,
302                              MPI_Datatype sendtype, int dst, int sendtag,
303                              void *recvbuf, int recvcount,
304                              MPI_Datatype recvtype, int src, int recvtag,
305                              MPI_Comm comm, MPI_Status * status));
306 MPI_CALL(XBT_PUBLIC(int), MPI_Sendrecv_replace,
307                             (void *buf, int count,
308                              MPI_Datatype datatype, int dst,
309                              int sendtag, int src, int recvtag,
310                              MPI_Comm comm, MPI_Status * status));
311
312 MPI_CALL(XBT_PUBLIC(int), MPI_Test,
313                             (MPI_Request * request, int *flag, MPI_Status* status));
314 MPI_CALL(XBT_PUBLIC(int), MPI_Testany,
315                             (int count, MPI_Request requests[], int *index,
316                              int *flag, MPI_Status * status));
317 MPI_CALL(XBT_PUBLIC(int), MPI_Wait, (MPI_Request * request, MPI_Status * status));
318 MPI_CALL(XBT_PUBLIC(int), MPI_Waitany,
319                             (int count, MPI_Request requests[], int *index,
320                              MPI_Status * status));
321 MPI_CALL(XBT_PUBLIC(int), MPI_Waitall,
322                             (int count, MPI_Request requests[],
323                              MPI_Status status[]));
324 MPI_CALL(XBT_PUBLIC(int), MPI_Waitsome,
325                             (int incount, MPI_Request requests[],
326                              int *outcount, int *indices,
327                              MPI_Status status[]));
328 MPI_CALL(XBT_PUBLIC(int), MPI_Testsome,
329                             (int incount, MPI_Request requests[],
330                              int *outcount, int *indices,
331                              MPI_Status status[]));
332 MPI_CALL(XBT_PUBLIC(int), MPI_Bcast,
333                             (void *buf, int count, MPI_Datatype datatype,
334                              int root, MPI_Comm comm));
335 MPI_CALL(XBT_PUBLIC(int), MPI_Barrier, (MPI_Comm comm));
336 MPI_CALL(XBT_PUBLIC(int), MPI_Gather,
337                             (void *sendbuf, int sendcount,
338                              MPI_Datatype sendtype, void *recvbuf,
339                              int recvcount, MPI_Datatype recvtype, int root,
340                              MPI_Comm comm));
341 MPI_CALL(XBT_PUBLIC(int), MPI_Gatherv,
342                             (void *sendbuf, int sendcount,
343                              MPI_Datatype sendtype, void *recvbuf,
344                              int *recvcounts, int *displs,
345                              MPI_Datatype recvtype, int root,
346                              MPI_Comm comm));
347 MPI_CALL(XBT_PUBLIC(int), MPI_Allgather,
348                             (void *sendbuf, int sendcount,
349                              MPI_Datatype sendtype, void *recvbuf,
350                              int recvcount, MPI_Datatype recvtype,
351                              MPI_Comm comm));
352 MPI_CALL(XBT_PUBLIC(int), MPI_Allgatherv,
353                             (void *sendbuf, int sendcount,
354                              MPI_Datatype sendtype, void *recvbuf,
355                              int *recvcounts, int *displs,
356                              MPI_Datatype recvtype, MPI_Comm comm));
357 MPI_CALL(XBT_PUBLIC(int), MPI_Scatter,
358                             (void *sendbuf, int sendcount,
359                              MPI_Datatype sendtype, void *recvbuf,
360                              int recvcount, MPI_Datatype recvtype, int root,
361                              MPI_Comm comm));
362 MPI_CALL(XBT_PUBLIC(int), MPI_Scatterv,
363                             (void *sendbuf, int *sendcounts, int *displs,
364                              MPI_Datatype sendtype, void *recvbuf,
365                              int recvcount, MPI_Datatype recvtype,
366                              int root, MPI_Comm comm));
367 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce,
368                             (void *sendbuf, void *recvbuf, int count,
369                              MPI_Datatype datatype, MPI_Op op, int root,
370                              MPI_Comm comm));
371 MPI_CALL(XBT_PUBLIC(int), MPI_Allreduce,
372                             (void *sendbuf, void *recvbuf, int count,
373                              MPI_Datatype datatype, MPI_Op op,
374                              MPI_Comm comm));
375 MPI_CALL(XBT_PUBLIC(int), MPI_Scan,
376                             (void *sendbuf, void *recvbuf, int count,
377                              MPI_Datatype datatype, MPI_Op op, MPI_Comm comm));
378 MPI_CALL(XBT_PUBLIC(int), MPI_Reduce_scatter,
379                             (void *sendbuf, void *recvbuf,
380                              int *recvcounts, MPI_Datatype datatype,
381                              MPI_Op op, MPI_Comm comm));
382 MPI_CALL(XBT_PUBLIC(int), MPI_Alltoall,
383                             (void *sendbuf, int sendcount,
384                              MPI_Datatype sendtype, void *recvbuf,
385                              int recvcount, MPI_Datatype recvtype,
386                              MPI_Comm comm));
387 MPI_CALL(XBT_PUBLIC(int), MPI_Alltoallv,
388                             (void *sendbuf, int *sendcounts,
389                              int *senddisps, MPI_Datatype sendtype,
390                              void *recvbuf, int *recvcounts,
391                              int *recvdisps, MPI_Datatype recvtype,
392                              MPI_Comm comm));
393 MPI_CALL(XBT_PUBLIC(int), MPI_Iprobe,
394                             (int source, int tag, MPI_Comm comm,
395                              int* flag, MPI_Status* status));
396 MPI_CALL(XBT_PUBLIC(int), MPI_Probe,
397                             (int source, int tag, MPI_Comm comm,
398                              MPI_Status* status));
399
400
401 //FIXME: these are not yet implemented
402
403 typedef void MPI_Handler_function(MPI_Comm*, int*, ...);
404 typedef int MPI_Win;
405 typedef int MPI_Info;
406 typedef void* MPI_Errhandler;
407 typedef int MPI_Copy_function(MPI_Comm oldcomm, int keyval, void* extra_state, void* attribute_val_in,
408                               void* attribute_val_out, int* flag);
409 typedef int MPI_Delete_function(MPI_Comm comm, int keyval, void* attribute_val, void* extra_state);
410
411 XBT_PUBLIC_DATA(MPI_Datatype)  MPI_PACKED;
412 XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRORS_RETURN;
413 XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRORS_ARE_FATAL;
414 XBT_PUBLIC_DATA(MPI_Errhandler*)  MPI_ERRHANDLER_NULL;
415
416
417 MPI_CALL(XBT_PUBLIC(int), MPI_Pack_size, (int incount, MPI_Datatype datatype, MPI_Comm comm, int* size));
418 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_coords, (MPI_Comm comm, int rank, int maxdims, int* coords));
419 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_create, (MPI_Comm comm_old, int ndims, int* dims, int* periods, int reorder, MPI_Comm* comm_cart));
420 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_get, (MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords));
421 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_map, (MPI_Comm comm_old, int ndims, int* dims, int* periods, int* newrank));
422 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_rank, (MPI_Comm comm, int* coords, int* rank));
423 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_shift, (MPI_Comm comm, int direction, int displ, int* source, int* dest));
424 MPI_CALL(XBT_PUBLIC(int), MPI_Cart_sub, (MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new));
425 MPI_CALL(XBT_PUBLIC(int), MPI_Cartdim_get, (MPI_Comm comm, int* ndims));
426 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_create, (MPI_Comm comm_old, int nnodes, int* index, int* edges, int reorder, MPI_Comm* comm_graph));
427 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_get, (MPI_Comm comm, int maxindex, int maxedges, int* index, int* edges));
428 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_map, (MPI_Comm comm_old, int nnodes, int* index, int* edges, int* newrank));
429 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_neighbors, (MPI_Comm comm, int rank, int maxneighbors, int* neighbors));
430 MPI_CALL(XBT_PUBLIC(int), MPI_Graph_neighbors_count, (MPI_Comm comm, int rank, int* nneighbors));
431 MPI_CALL(XBT_PUBLIC(int), MPI_Graphdims_get, (MPI_Comm comm, int* nnodes, int* nedges));
432 MPI_CALL(XBT_PUBLIC(int), MPI_Topo_test, (MPI_Comm comm, int* top_type));
433 MPI_CALL(XBT_PUBLIC(int), MPI_Error_class, (int errorcode, int* errorclass));
434 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_create, (MPI_Handler_function* function, MPI_Errhandler* errhandler));
435 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_free, (MPI_Errhandler* errhandler));
436 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_get, (MPI_Comm comm, MPI_Errhandler* errhandler));
437 MPI_CALL(XBT_PUBLIC(int), MPI_Error_string, (int errorcode, char* string, int* resultlen));
438 MPI_CALL(XBT_PUBLIC(int), MPI_Errhandler_set, (MPI_Comm comm, MPI_Errhandler errhandler));
439 MPI_CALL(XBT_PUBLIC(int), MPI_Cancel, (MPI_Request* request));
440 MPI_CALL(XBT_PUBLIC(int), MPI_Buffer_attach, (void* buffer, int size));
441 MPI_CALL(XBT_PUBLIC(int), MPI_Buffer_detach, (void* buffer, int* size));
442 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_test_inter, (MPI_Comm comm, int* flag));
443 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_get_attr, (MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag));
444 MPI_CALL(XBT_PUBLIC(int), MPI_Unpack, (void* inbuf, int insize, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm));
445 MPI_CALL(XBT_PUBLIC(int), MPI_Ssend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
446 MPI_CALL(XBT_PUBLIC(int), MPI_Ssend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
447 MPI_CALL(XBT_PUBLIC(int), MPI_Intercomm_create, (MPI_Comm local_comm, int local_leader, MPI_Comm peer_comm, int remote_leader, int tag, MPI_Comm* comm_out));
448 MPI_CALL(XBT_PUBLIC(int), MPI_Intercomm_merge, (MPI_Comm comm, int high, MPI_Comm* comm_out));
449 MPI_CALL(XBT_PUBLIC(int), MPI_Bsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
450 MPI_CALL(XBT_PUBLIC(int), MPI_Bsend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
451 MPI_CALL(XBT_PUBLIC(int), MPI_Ibsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
452 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_remote_group, (MPI_Comm comm, MPI_Group* group));
453 MPI_CALL(XBT_PUBLIC(int), MPI_Comm_remote_size, (MPI_Comm comm, int* size));
454 MPI_CALL(XBT_PUBLIC(int), MPI_Issend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
455 MPI_CALL(XBT_PUBLIC(int), MPI_Attr_delete, (MPI_Comm comm, int keyval));
456 MPI_CALL(XBT_PUBLIC(int), MPI_Attr_get, (MPI_Comm comm, int keyval, void* attr_value, int* flag));
457 MPI_CALL(XBT_PUBLIC(int), MPI_Attr_put, (MPI_Comm comm, int keyval, void* attr_value));
458 MPI_CALL(XBT_PUBLIC(int), MPI_Rsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm));
459 MPI_CALL(XBT_PUBLIC(int), MPI_Rsend_init, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
460 MPI_CALL(XBT_PUBLIC(int), MPI_Irsend, (void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request* request));
461 MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_create, (MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state));
462 MPI_CALL(XBT_PUBLIC(int), MPI_Keyval_free, (int* keyval));
463 MPI_CALL(XBT_PUBLIC(int), MPI_Test_cancelled, (MPI_Status* status, int* flag));
464 MPI_CALL(XBT_PUBLIC(int), MPI_Pack, (void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm));
465 MPI_CALL(XBT_PUBLIC(int), MPI_Get_elements, (MPI_Status* status, MPI_Datatype datatype, int* elements));
466 MPI_CALL(XBT_PUBLIC(int), MPI_Dims_create, (int nnodes, int ndims, int* dims));
467 MPI_CALL(XBT_PUBLIC(int), MPI_Initialized, (int* flag));
468 MPI_CALL(XBT_PUBLIC(int), MPI_Pcontrol, (const int level ));
469 MPI_CALL(XBT_PUBLIC(int), MPI_Win_fence,( int assert,  MPI_Win win));
470 MPI_CALL(XBT_PUBLIC(int), MPI_Win_free,( MPI_Win* win));
471 MPI_CALL(XBT_PUBLIC(int), MPI_Win_create,( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, MPI_Win *win));
472 MPI_CALL(XBT_PUBLIC(int), MPI_Info_create,( MPI_Info *info));
473 MPI_CALL(XBT_PUBLIC(int), MPI_Info_set,( MPI_Info *info, char *key, char *value));
474 MPI_CALL(XBT_PUBLIC(int), MPI_Info_free,( MPI_Info *info));
475 MPI_CALL(XBT_PUBLIC(int), MPI_Get,( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, int target_rank,
476     MPI_Aint target_disp, int target_count, MPI_Datatype target_datatype, MPI_Win win));
477
478 //FIXME: End of all the not yet implemented stuff
479
480 // smpi functions
481 XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
482 /*
483 XBT_PUBLIC(void) smpi_exit(int);
484 */
485
486 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
487 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv);
488 XBT_PUBLIC(unsigned long long) smpi_rastro_resolution (void);
489 XBT_PUBLIC(unsigned long long) smpi_rastro_timestamp (void);
490 XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line,
491                               int iters, double threshold);
492 XBT_PUBLIC(int) smpi_sample_2(int global, const char *file, int line);
493 XBT_PUBLIC(void) smpi_sample_3(int global, const char *file, int line);
494
495 #define SMPI_SAMPLE_LOCAL(iters,thres) for(smpi_sample_1(0, __FILE__, __LINE__, iters, thres); \
496                                            smpi_sample_2(0, __FILE__, __LINE__);      \
497                                            smpi_sample_3(0, __FILE__, __LINE__))
498
499 #define SMPI_SAMPLE_GLOBAL(iters,thres) for(smpi_sample_1(1, __FILE__, __LINE__, iters, thres); \
500                                             smpi_sample_2(1, __FILE__, __LINE__);      \
501                                             smpi_sample_3(1, __FILE__, __LINE__))
502
503 #define SMPI_SAMPLE_DELAY(duration) for(smpi_execute(duration); 0; )
504 #define SMPI_SAMPLE_FLOPS(flops) for(smpi_execute_flops(flops); 0; )
505
506 XBT_PUBLIC(void *) smpi_shared_malloc(size_t size, const char *file,
507                                       int line);
508 #define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
509
510 XBT_PUBLIC(void) smpi_shared_free(void *data);
511 #define SMPI_SHARED_FREE(data) smpi_shared_free(data)
512
513 XBT_PUBLIC(int) smpi_shared_known_call(const char* func, const char* input);
514 XBT_PUBLIC(void*) smpi_shared_get_call(const char* func, const char* input);
515 XBT_PUBLIC(void*) smpi_shared_set_call(const char* func, const char* input, void* data);
516 #define SMPI_SHARED_CALL(func, input, ...) \
517    (smpi_shared_known_call(#func, input) ? smpi_shared_get_call(#func, input) \
518                                          : smpi_shared_set_call(#func, input, func(__VA_ARGS__)))
519
520 /* Fortran specific stuff */
521 XBT_PUBLIC(int) __attribute__((weak)) smpi_simulated_main_(int argc, char** argv);
522 XBT_PUBLIC(int) __attribute__((weak)) MAIN__(void);
523 XBT_PUBLIC(int) smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[]);
524 XBT_PUBLIC(void) __attribute__((weak)) user_main_(void);
525
526 XBT_PUBLIC(int) smpi_process_index(void);
527
528 /* Trace replay specific stuff */
529 XBT_PUBLIC(void) smpi_replay_init(int *argc, char***argv);
530 XBT_PUBLIC(void) smpi_action_trace_run(char *);
531 XBT_PUBLIC(int) smpi_replay_finalize(void);
532
533 SG_END_DECL()
534 #endif