Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7ce19779e84c4d8c6ab635267fb0bac05d8ccaba
[simgrid.git] / include / smpi / smpi.h
1 #ifndef SMPI_H
2 #define SMPI_H
3
4 #include <stddef.h>
5 #include <sys/time.h>
6 #include <xbt/misc.h>
7 #include <xbt/function_types.h>
8
9 SG_BEGIN_DECL()
10 #define MPI_THREAD_SINGLE     0
11 #define MPI_THREAD_FUNNELED   1
12 #define MPI_THREAD_SERIALIZED 2
13 #define MPI_THREAD_MULTIPLE   3
14
15 //FIXME: check values
16 #define MPI_MAX_PROCESSOR_NAME 100
17 #define MPI_MAX_ERROR_STRING   100
18 #define MPI_MAX_DATAREP_STRIN  100
19 #define MPI_MAX_INFO_KEY       100
20 #define MPI_MAX_INFO_VAL       100
21 #define MPI_MAX_OBJECT_NAME    100
22 #define MPI_MAX_PORT_NAME      100
23
24 #define SMPI_RAND_SEED 5
25 #define MPI_ANY_SOURCE -1
26 #define MPI_ANY_TAG -1
27 #define MPI_UNDEFINED -1
28
29 // errorcodes
30 #define MPI_SUCCESS       0
31 #define MPI_ERR_COMM      1
32 #define MPI_ERR_ARG       2
33 #define MPI_ERR_TYPE      3
34 #define MPI_ERR_REQUEST   4
35 #define MPI_ERR_INTERN    5
36 #define MPI_ERR_COUNT     6
37 #define MPI_ERR_RANK      7
38 #define MPI_ERR_TAG       8
39 #define MPI_ERR_TRUNCATE  9
40 #define MPI_ERR_GROUP    10
41 #define MPI_ERR_OP       11
42
43 #define MPI_IDENT     0
44 #define MPI_SIMILAR   1
45 #define MPI_UNEQUAL   2
46 #define MPI_CONGRUENT 3
47
48 typedef ptrdiff_t MPI_Aint;
49 typedef long long MPI_Offset;
50
51 struct s_smpi_mpi_datatype;
52 typedef struct s_smpi_mpi_datatype* MPI_Datatype;
53
54 typedef struct {
55   int MPI_SOURCE;
56   int MPI_TAG;
57   int MPI_ERROR;
58   int _count;
59   int _cancelled;
60 } MPI_Status;
61
62 #define MPI_STATUS_IGNORE NULL
63
64 #define MPI_DATATYPE_NULL NULL
65 extern MPI_Datatype MPI_CHAR;
66 extern MPI_Datatype MPI_SHORT;
67 extern MPI_Datatype MPI_INT;
68 extern MPI_Datatype MPI_LONG;
69 extern MPI_Datatype MPI_LONG_LONG;
70 #define MPI_LONG_LONG_INT MPI_LONG_LONG
71 extern MPI_Datatype MPI_SIGNED_CHAR;
72 extern MPI_Datatype MPI_UNSIGNED_CHAR;
73 extern MPI_Datatype MPI_UNSIGNED_SHORT;
74 extern MPI_Datatype MPI_UNSIGNED;
75 extern MPI_Datatype MPI_UNSIGNED_LONG;
76 extern MPI_Datatype MPI_UNSIGNED_LONG_LONG;
77 extern MPI_Datatype MPI_FLOAT;
78 extern MPI_Datatype MPI_DOUBLE;
79 extern MPI_Datatype MPI_LONG_DOUBLE;
80 extern MPI_Datatype MPI_WCHAR;
81 extern MPI_Datatype MPI_C_BOOL;
82 extern MPI_Datatype MPI_INT8_T;
83 extern MPI_Datatype MPI_INT16_T;
84 extern MPI_Datatype MPI_INT32_T;
85 extern MPI_Datatype MPI_INT64_T;
86 extern MPI_Datatype MPI_UINT8_T;
87 #define MPI_BYTE MPI_UINT8_T
88 extern MPI_Datatype MPI_UINT16_T;
89 extern MPI_Datatype MPI_UINT32_T;
90 extern MPI_Datatype MPI_UINT64_T;
91 extern MPI_Datatype MPI_C_FLOAT_COMPLEX;
92 #define MPI_C_COMPLEX MPI_C_FLOAT_COMPLEX
93 extern MPI_Datatype MPI_C_DOUBLE_COMPLEX;
94 extern MPI_Datatype MPI_C_LONG_DOUBLE_COMPLEX;
95 extern MPI_Datatype MPI_AINT;
96 extern MPI_Datatype MPI_OFFSET;
97
98 //The following are datatypes for the MPI functions MPI_MAXLOC  and MPI_MINLOC.
99 extern MPI_Datatype MPI_FLOAT_INT;
100 extern MPI_Datatype MPI_LONG_INT;
101 extern MPI_Datatype MPI_DOUBLE_INT;
102 extern MPI_Datatype MPI_SHORT_INT;
103 extern MPI_Datatype MPI_2INT;
104 extern MPI_Datatype MPI_LONG_DOUBLE_INT;
105
106
107 typedef void MPI_User_function(void* invec, void* inoutvec, int* len, MPI_Datatype* datatype);
108 struct s_smpi_mpi_op;
109 typedef struct s_smpi_mpi_op* MPI_Op;
110
111 #define MPI_OP_NULL NULL
112 extern MPI_Op MPI_MAX;
113 extern MPI_Op MPI_MIN;
114 extern MPI_Op MPI_MAXLOC;
115 extern MPI_Op MPI_MINLOC;
116 extern MPI_Op MPI_SUM;
117 extern MPI_Op MPI_PROD;
118 extern MPI_Op MPI_LAND;
119 extern MPI_Op MPI_LOR;
120 extern MPI_Op MPI_LXOR;
121 extern MPI_Op MPI_BAND;
122 extern MPI_Op MPI_BOR;
123 extern MPI_Op MPI_BXOR;
124
125 struct s_smpi_mpi_group;
126 typedef struct s_smpi_mpi_group* MPI_Group;
127
128 #define MPI_GROUP_NULL NULL
129
130 extern MPI_Group MPI_GROUP_EMPTY;
131
132 struct s_smpi_mpi_communicator;
133 typedef struct s_smpi_mpi_communicator* MPI_Comm;
134
135 #define MPI_COMM_NULL NULL
136 extern MPI_Comm MPI_COMM_WORLD;
137
138 struct s_smpi_mpi_request;
139 typedef struct s_smpi_mpi_request* MPI_Request;
140
141 #define MPI_REQUEST_NULL NULL
142
143 XBT_PUBLIC(int) MPI_Init(int* argc, char*** argv);
144 XBT_PUBLIC(int) MPI_Finalize(void);
145 XBT_PUBLIC(int) MPI_Init_thread(int* argc, char*** argv, int required, int* provided);
146 XBT_PUBLIC(int) MPI_Query_thread(int* provided);
147 XBT_PUBLIC(int) MPI_Is_thread_main(int* flag);
148 XBT_PUBLIC(int) MPI_Abort(MPI_Comm comm, int errorcode);
149 XBT_PUBLIC(double) MPI_Wtime(void);
150
151 XBT_PUBLIC(int) MPI_Type_size(MPI_Datatype datatype, size_t* size);
152 XBT_PUBLIC(int) MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint* extent);
153 XBT_PUBLIC(int) MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp);
154 XBT_PUBLIC(int) MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp);
155
156 XBT_PUBLIC(int) MPI_Op_create(MPI_User_function* function, int commute, MPI_Op* op);
157 XBT_PUBLIC(int) MPI_Op_free(MPI_Op* op);
158
159 XBT_PUBLIC(int) MPI_Group_free(MPI_Group *group);
160 XBT_PUBLIC(int) MPI_Group_size(MPI_Group group, int* size);
161 XBT_PUBLIC(int) MPI_Group_rank(MPI_Group group, int* rank);
162 XBT_PUBLIC(int) MPI_Group_translate_ranks (MPI_Group group1, int n, int* ranks1, MPI_Group group2, int* ranks2);
163 XBT_PUBLIC(int) MPI_Group_compare(MPI_Group group1, MPI_Group group2, int* result);
164 XBT_PUBLIC(int) MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
165 XBT_PUBLIC(int) MPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
166 XBT_PUBLIC(int) MPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group* newgroup);
167 XBT_PUBLIC(int) MPI_Group_incl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
168 XBT_PUBLIC(int) MPI_Group_excl(MPI_Group group, int n, int* ranks, MPI_Group* newgroup);
169 XBT_PUBLIC(int) MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
170 XBT_PUBLIC(int) MPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group* newgroup);
171
172 XBT_PUBLIC(int) MPI_Comm_rank(MPI_Comm comm, int* rank);
173 XBT_PUBLIC(int) MPI_Comm_size(MPI_Comm comm, int* size);
174 XBT_PUBLIC(int) MPI_Get_processor_name(char *name, int *resultlen);
175            
176 XBT_PUBLIC(int) MPI_Comm_group(MPI_Comm comm, MPI_Group* group);
177 XBT_PUBLIC(int) MPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int* result);
178 XBT_PUBLIC(int) MPI_Comm_dup(MPI_Comm comm, MPI_Comm* newcomm);
179 XBT_PUBLIC(int) MPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm* newcomm);
180 XBT_PUBLIC(int) MPI_Comm_free(MPI_Comm* comm);
181
182 XBT_PUBLIC(int) MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Request* request);
183 XBT_PUBLIC(int) MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm, MPI_Request* request);
184 XBT_PUBLIC(int) MPI_Recv(void* buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status* status);
185 XBT_PUBLIC(int) MPI_Send(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm);
186 XBT_PUBLIC(int) MPI_Sendrecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf, int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
187 XBT_PUBLIC(int) MPI_Sendrecv_replace(void* buf, int count, MPI_Datatype datatype, int dst, int sendtag, int src, int recvtag, MPI_Comm comm, MPI_Status* status);
188
189
190 XBT_PUBLIC(int) MPI_Get_count(MPI_Status *status, MPI_Datatype datatype, int *count);
191 XBT_PUBLIC(int) MPI_Test(MPI_Request* request, int* flag, MPI_Status* status);
192 XBT_PUBLIC(int) MPI_Testany(int count, MPI_Request requests[], int* index, int* flag, MPI_Status* status);
193 XBT_PUBLIC(int) MPI_Wait(MPI_Request* request, MPI_Status* status);
194 XBT_PUBLIC(int) MPI_Waitany(int count, MPI_Request requests[], int* index, MPI_Status* status); 
195 XBT_PUBLIC(int) MPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]);
196 XBT_PUBLIC(int) MPI_Waitsome(int incount, MPI_Request requests[], int* outcount, int* indices, MPI_Status status[]);
197
198 XBT_PUBLIC(int) MPI_Bcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
199 XBT_PUBLIC(int) MPI_Barrier(MPI_Comm comm);
200 XBT_PUBLIC(int) MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
201 XBT_PUBLIC(int) MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, int root, MPI_Comm comm);
202 XBT_PUBLIC(int) MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
203 XBT_PUBLIC(int) MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype, MPI_Comm comm);
204 XBT_PUBLIC(int) MPI_Scatter(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
205 XBT_PUBLIC(int) MPI_Scatterv(void* sendbuf, int* sendcounts, int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm);
206 XBT_PUBLIC(int) MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm);
207 XBT_PUBLIC(int) MPI_Allreduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
208 XBT_PUBLIC(int) MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int* recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
209 XBT_PUBLIC(int) MPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
210 XBT_PUBLIC(int) MPI_Alltoallv(void* sendbuf, int* sendcounts, int* senddisps, MPI_Datatype sendtype, void* recvbuf, int *recvcounts, int* recvdisps, MPI_Datatype recvtype, MPI_Comm comm);
211
212 /*
213 TODO
214 XBT_PUBLIC(int) MPI_Comm_split(MPI_Comm comm, int color, int key,
215                                MPI_Comm* comm_out);
216 */
217 // smpi functions
218 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char** argv);
219 /*
220 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int);
221 XBT_PUBLIC(void) smpi_exit(int);
222 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval* tv, struct timezone* tz);
223 */
224
225 /*
226 TODO
227 XBT_PUBLIC(void) smpi_do_once_1(const char* file, int line);
228 XBT_PUBLIC(int) smpi_do_once_2(void);
229 XBT_PUBLIC(void) smpi_do_once_3(void);
230
231 #define SMPI_DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3())
232 */
233
234 SG_END_DECL()
235 #endif