1 /* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
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. */
13 #include <xbt/function_types.h>
16 #define MPI_THREAD_SINGLE 0
17 #define MPI_THREAD_FUNNELED 1
18 #define MPI_THREAD_SERIALIZED 2
19 #define MPI_THREAD_MULTIPLE 3
21 #define MPI_MAX_PROCESSOR_NAME 100
22 #define MPI_MAX_ERROR_STRING 100
23 #define MPI_MAX_DATAREP_STRIN 100
24 #define MPI_MAX_INFO_KEY 100
25 #define MPI_MAX_INFO_VAL 100
26 #define MPI_MAX_OBJECT_NAME 100
27 #define MPI_MAX_PORT_NAME 100
28 #define SMPI_RAND_SEED 5
29 #define MPI_ANY_SOURCE -1
30 #define MPI_PROC_NULL -2
31 #define MPI_ANY_TAG -1
32 #define MPI_UNDEFINED -1
35 #define MPI_ERR_COMM 1
37 #define MPI_ERR_TYPE 3
38 #define MPI_ERR_REQUEST 4
39 #define MPI_ERR_INTERN 5
40 #define MPI_ERR_COUNT 6
41 #define MPI_ERR_RANK 7
43 #define MPI_ERR_TRUNCATE 9
44 #define MPI_ERR_GROUP 10
49 #define MPI_CONGRUENT 3
50 #define MPI_WTIME_IS_GLOBAL 1
51 typedef ptrdiff_t MPI_Aint;
52 typedef long long MPI_Offset;
54 struct s_smpi_mpi_datatype;
55 typedef struct s_smpi_mpi_datatype *MPI_Datatype;
64 #define MPI_STATUS_IGNORE NULL
66 #define MPI_DATATYPE_NULL NULL
67 extern MPI_Datatype MPI_CHAR;
68 extern MPI_Datatype MPI_SHORT;
69 extern MPI_Datatype MPI_INT;
70 extern MPI_Datatype MPI_LONG;
71 extern MPI_Datatype MPI_LONG_LONG;
72 #define MPI_LONG_LONG_INT MPI_LONG_LONG
73 extern MPI_Datatype MPI_SIGNED_CHAR;
74 extern MPI_Datatype MPI_UNSIGNED_CHAR;
75 extern MPI_Datatype MPI_UNSIGNED_SHORT;
76 extern MPI_Datatype MPI_UNSIGNED;
77 extern MPI_Datatype MPI_UNSIGNED_LONG;
78 extern MPI_Datatype MPI_UNSIGNED_LONG_LONG;
79 extern MPI_Datatype MPI_FLOAT;
80 extern MPI_Datatype MPI_DOUBLE;
81 extern MPI_Datatype MPI_LONG_DOUBLE;
82 extern MPI_Datatype MPI_WCHAR;
83 extern MPI_Datatype MPI_C_BOOL;
84 extern MPI_Datatype MPI_INT8_T;
85 extern MPI_Datatype MPI_INT16_T;
86 extern MPI_Datatype MPI_INT32_T;
87 extern MPI_Datatype MPI_INT64_T;
88 extern MPI_Datatype MPI_UINT8_T;
89 #define MPI_BYTE MPI_UINT8_T
90 extern MPI_Datatype MPI_UINT16_T;
91 extern MPI_Datatype MPI_UINT32_T;
92 extern MPI_Datatype MPI_UINT64_T;
93 extern MPI_Datatype MPI_C_FLOAT_COMPLEX;
94 #define MPI_C_COMPLEX MPI_C_FLOAT_COMPLEX
95 extern MPI_Datatype MPI_C_DOUBLE_COMPLEX;
96 extern MPI_Datatype MPI_C_LONG_DOUBLE_COMPLEX;
97 extern MPI_Datatype MPI_AINT;
98 extern MPI_Datatype MPI_OFFSET;
100 //The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
101 extern MPI_Datatype MPI_FLOAT_INT;
102 extern MPI_Datatype MPI_LONG_INT;
103 extern MPI_Datatype MPI_DOUBLE_INT;
104 extern MPI_Datatype MPI_SHORT_INT;
105 extern MPI_Datatype MPI_2INT;
106 extern MPI_Datatype MPI_LONG_DOUBLE_INT;
109 typedef void MPI_User_function(void *invec, void *inoutvec, int *len,
110 MPI_Datatype * datatype);
111 struct s_smpi_mpi_op;
112 typedef struct s_smpi_mpi_op *MPI_Op;
114 #define MPI_OP_NULL NULL
115 extern MPI_Op MPI_MAX;
116 extern MPI_Op MPI_MIN;
117 extern MPI_Op MPI_MAXLOC;
118 extern MPI_Op MPI_MINLOC;
119 extern MPI_Op MPI_SUM;
120 extern MPI_Op MPI_PROD;
121 extern MPI_Op MPI_LAND;
122 extern MPI_Op MPI_LOR;
123 extern MPI_Op MPI_LXOR;
124 extern MPI_Op MPI_BAND;
125 extern MPI_Op MPI_BOR;
126 extern MPI_Op MPI_BXOR;
128 struct s_smpi_mpi_group;
129 typedef struct s_smpi_mpi_group *MPI_Group;
131 #define MPI_GROUP_NULL NULL
133 extern MPI_Group MPI_GROUP_EMPTY;
135 struct s_smpi_mpi_communicator;
136 typedef struct s_smpi_mpi_communicator *MPI_Comm;
138 #define MPI_COMM_NULL NULL
139 extern MPI_Comm MPI_COMM_WORLD;
140 #define MPI_COMM_SELF smpi_process_comm_self()
142 struct s_smpi_mpi_request;
143 typedef struct s_smpi_mpi_request *MPI_Request;
145 #define MPI_REQUEST_NULL NULL
147 XBT_PUBLIC(int) MPI_Init(int *argc, char ***argv);
148 XBT_PUBLIC(int) MPI_Finalize(void);
149 XBT_PUBLIC(int) MPI_Init_thread(int *argc, char ***argv, int required,
151 XBT_PUBLIC(int) MPI_Query_thread(int *provided);
152 XBT_PUBLIC(int) MPI_Is_thread_main(int *flag);
153 XBT_PUBLIC(int) MPI_Abort(MPI_Comm comm, int errorcode);
154 XBT_PUBLIC(double) MPI_Wtime(void);
156 XBT_PUBLIC(int) MPI_Address(void *location, MPI_Aint * address);
158 XBT_PUBLIC(int) MPI_Type_free(MPI_Datatype * datatype);
159 XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, int *size);
160 XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb,
162 XBT_PUBLIC(int) MPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent);
163 XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp);
164 XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp);
166 XBT_PUBLIC(int) MPI_Op_create(MPI_User_function * function, int commute,
168 XBT_PUBLIC(int) MPI_Op_free(MPI_Op * op);
170 XBT_PUBLIC(int) MPI_Group_free(MPI_Group * group);
171 XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int *size);
172 XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int *rank);
173 XBT_PUBLIC(int) MPI_Group_translate_ranks(MPI_Group group1, int n,
174 int *ranks1, MPI_Group group2,
176 XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2,
178 XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2,
179 MPI_Group * newgroup);
180 XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
181 MPI_Group * newgroup);
182 XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2,
183 MPI_Group * newgroup);
184 XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int *ranks,
185 MPI_Group * newgroup);
186 XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int *ranks,
187 MPI_Group * newgroup);
188 XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n,
190 MPI_Group * newgroup);
191 XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n,
193 MPI_Group * newgroup);
195 XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int *rank);
196 XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int *size);
197 XBT_PUBLIC(int) MPI_Get_processor_name(char *name, int *resultlen);
198 XBT_PUBLIC(int) MPI_Get_count(MPI_Status * status, MPI_Datatype datatype,
201 XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group * group);
202 XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2,
204 XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm);
205 XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group,
207 XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm * comm);
208 XBT_PUBLIC(int) MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out);
210 XBT_PUBLIC(int) MPI_Send_init(void *buf, int count, MPI_Datatype datatype,
211 int dst, int tag, MPI_Comm comm,
212 MPI_Request * request);
213 XBT_PUBLIC(int) MPI_Recv_init(void *buf, int count, MPI_Datatype datatype,
214 int src, int tag, MPI_Comm comm,
215 MPI_Request * request);
216 XBT_PUBLIC(int) MPI_Start(MPI_Request * request);
217 XBT_PUBLIC(int) MPI_Startall(int count, MPI_Request * requests);
218 XBT_PUBLIC(int) MPI_Request_free(MPI_Request * request);
219 XBT_PUBLIC(int) MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
220 int src, int tag, MPI_Comm comm,
221 MPI_Request * request);
222 XBT_PUBLIC(int) MPI_Isend(void *buf, int count, MPI_Datatype datatype,
223 int dst, int tag, MPI_Comm comm,
224 MPI_Request * request);
225 XBT_PUBLIC(int) MPI_Recv(void *buf, int count, MPI_Datatype datatype,
226 int src, int tag, MPI_Comm comm,
227 MPI_Status * status);
228 XBT_PUBLIC(int) MPI_Send(void *buf, int count, MPI_Datatype datatype,
229 int dst, int tag, MPI_Comm comm);
230 XBT_PUBLIC(int) MPI_Sendrecv(void *sendbuf, int sendcount,
231 MPI_Datatype sendtype, int dst, int sendtag,
232 void *recvbuf, int recvcount,
233 MPI_Datatype recvtype, int src, int recvtag,
234 MPI_Comm comm, MPI_Status * status);
235 XBT_PUBLIC(int) MPI_Sendrecv_replace(void *buf, int count,
236 MPI_Datatype datatype, int dst,
237 int sendtag, int src, int recvtag,
238 MPI_Comm comm, MPI_Status * status);
241 XBT_PUBLIC(int) MPI_Test(MPI_Request * request, int *flag,
242 MPI_Status * status);
243 XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int *index,
244 int *flag, MPI_Status * status);
245 XBT_PUBLIC(int) MPI_Wait(MPI_Request * request, MPI_Status * status);
246 XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int *index,
247 MPI_Status * status);
248 XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[],
249 MPI_Status status[]);
250 XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[],
251 int *outcount, int *indices,
252 MPI_Status status[]);
254 XBT_PUBLIC(int) MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
255 int root, MPI_Comm comm);
256 XBT_PUBLIC(int) MPI_Barrier(MPI_Comm comm);
257 XBT_PUBLIC(int) MPI_Gather(void *sendbuf, int sendcount,
258 MPI_Datatype sendtype, void *recvbuf,
259 int recvcount, MPI_Datatype recvtype, int root,
261 XBT_PUBLIC(int) MPI_Gatherv(void *sendbuf, int sendcount,
262 MPI_Datatype sendtype, void *recvbuf,
263 int *recvcounts, int *displs,
264 MPI_Datatype recvtype, int root,
266 XBT_PUBLIC(int) MPI_Allgather(void *sendbuf, int sendcount,
267 MPI_Datatype sendtype, void *recvbuf,
268 int recvcount, MPI_Datatype recvtype,
270 XBT_PUBLIC(int) MPI_Allgatherv(void *sendbuf, int sendcount,
271 MPI_Datatype sendtype, void *recvbuf,
272 int *recvcounts, int *displs,
273 MPI_Datatype recvtype, MPI_Comm comm);
274 XBT_PUBLIC(int) MPI_Scatter(void *sendbuf, int sendcount,
275 MPI_Datatype sendtype, void *recvbuf,
276 int recvcount, MPI_Datatype recvtype, int root,
278 XBT_PUBLIC(int) MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs,
279 MPI_Datatype sendtype, void *recvbuf,
280 int recvcount, MPI_Datatype recvtype,
281 int root, MPI_Comm comm);
282 XBT_PUBLIC(int) MPI_Reduce(void *sendbuf, void *recvbuf, int count,
283 MPI_Datatype datatype, MPI_Op op, int root,
285 XBT_PUBLIC(int) MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
286 MPI_Datatype datatype, MPI_Op op,
288 XBT_PUBLIC(int) MPI_Scan(void *sendbuf, void *recvbuf, int count,
289 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
290 XBT_PUBLIC(int) MPI_Reduce_scatter(void *sendbuf, void *recvbuf,
291 int *recvcounts, MPI_Datatype datatype,
292 MPI_Op op, MPI_Comm comm);
293 XBT_PUBLIC(int) MPI_Alltoall(void *sendbuf, int sendcount,
294 MPI_Datatype sendtype, void *recvbuf,
295 int recvcount, MPI_Datatype recvtype,
297 XBT_PUBLIC(int) MPI_Alltoallv(void *sendbuf, int *sendcounts,
298 int *senddisps, MPI_Datatype sendtype,
299 void *recvbuf, int *recvcounts,
300 int *recvdisps, MPI_Datatype recvtype,
304 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
305 XBT_PUBLIC(MPI_Comm) smpi_process_comm_self(void);
307 XBT_PUBLIC(void) smpi_exit(int);
310 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs);
311 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
312 XBT_PUBLIC(void) smpi_sample_1(int global, const char *file, int line,
314 XBT_PUBLIC(int) smpi_sample_2(int global, const char *file, int line);
315 XBT_PUBLIC(void) smpi_sample_3(int global, const char *file, int line);
316 XBT_PUBLIC(void) smpi_sample_flops(double flops);
318 #define SMPI_SAMPLE_LOCAL(num) for(smpi_sample_1(0, __FILE__, __LINE__, num); \
319 smpi_sample_2(0, __FILE__, __LINE__); \
320 smpi_sample_3(0, __FILE__, __LINE__))
322 #define SMPI_SAMPLE_GLOBAL(num) for(smpi_sample_1(1, __FILE__, __LINE__, num); \
323 smpi_sample_2(1, __FILE__, __LINE__); \
324 smpi_sample_3(1, __FILE__, __LINE__))
326 #define SMPI_SAMPLE_DELAY(flops) for(smpi_sample_flops(flops); 0; )
328 XBT_PUBLIC(void *) smpi_shared_malloc(size_t size, const char *file,
330 #define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
332 XBT_PUBLIC(void) smpi_shared_free(void *data);
333 #define SMPI_SHARED_FREE(data) smpi_shared_free(data)
335 /* Fortran specific stuff */
336 XBT_PUBLIC(int) MAIN__(void);