Logo AND Algorithmique Numérique Distribuée

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