Logo AND Algorithmique Numérique Distribuée

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