Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a3ad1369ef30e5e437f9e9af4b10d4a4b25793fb
[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 SMPI_RAND_SEED 5
11 #define MPI_ANY_SOURCE -1
12 #define MPI_ANY_TAG -1
13 #define MPI_UNDEFINED -1
14 // errorcodes
15 #define MPI_SUCCESS     0
16 #define MPI_ERR_COMM    1
17 #define MPI_ERR_ARG     2
18 #define MPI_ERR_TYPE    3
19 #define MPI_ERR_REQUEST 4
20 #define MPI_ERR_INTERN  5
21 #define MPI_ERR_COUNT   6
22 #define MPI_ERR_RANK    7
23 #define MPI_ERR_TAG     8
24 #define MPI_ERR_TRUNCATE 9
25 // MPI_Comm
26      typedef struct smpi_mpi_communicator_t *smpi_mpi_communicator_t;
27      typedef smpi_mpi_communicator_t MPI_Comm;
28
29 // MPI_Datatype
30      typedef struct smpi_mpi_datatype_t *smpi_mpi_datatype_t;
31      typedef smpi_mpi_datatype_t MPI_Datatype;
32
33 // MPI_Request
34      typedef struct smpi_mpi_request_t *smpi_mpi_request_t;
35      typedef smpi_mpi_request_t MPI_Request;
36
37 // MPI_Op
38      typedef struct smpi_mpi_op_t *smpi_mpi_op_t;
39      typedef smpi_mpi_op_t MPI_Op;
40
41 // MPI_Status
42      struct smpi_mpi_status_t {
43        int MPI_SOURCE;
44        int MPI_TAG;
45        int MPI_ERROR;
46      };
47      typedef struct smpi_mpi_status_t smpi_mpi_status_t;
48      typedef smpi_mpi_status_t MPI_Status;
49
50 // global SMPI data structure
51      typedef struct smpi_mpi_global_t {
52
53        smpi_mpi_communicator_t mpi_comm_world;
54
55        smpi_mpi_datatype_t mpi_byte;
56        smpi_mpi_datatype_t mpi_char;
57        smpi_mpi_datatype_t mpi_int;
58        smpi_mpi_datatype_t mpi_float;
59        smpi_mpi_datatype_t mpi_double;
60
61        smpi_mpi_op_t mpi_land;
62        smpi_mpi_op_t mpi_sum;
63        smpi_mpi_op_t mpi_prod;
64        smpi_mpi_op_t mpi_min;
65        smpi_mpi_op_t mpi_max;
66
67      } s_smpi_mpi_global_t;
68      typedef struct smpi_mpi_global_t *smpi_mpi_global_t;
69      extern smpi_mpi_global_t smpi_mpi_global;
70
71 #define MPI_COMM_WORLD    (smpi_mpi_global->mpi_comm_world)
72 #define MPI_COMM_NULL     NULL
73
74 #define MPI_STATUS_IGNORE NULL
75 #define MPI_Aint          ptrdiff_t
76
77 #define MPI_BYTE          (smpi_mpi_global->mpi_byte)
78 #define MPI_CHAR          (smpi_mpi_global->mpi_char)
79 #define MPI_INT           (smpi_mpi_global->mpi_int)
80 #define MPI_FLOAT         (smpi_mpi_global->mpi_float)
81 #define MPI_DOUBLE        (smpi_mpi_global->mpi_double)
82
83 #define MPI_LAND          (smpi_mpi_global->mpi_land)
84 #define MPI_SUM           (smpi_mpi_global->mpi_sum)
85 #define MPI_PROD          (smpi_mpi_global->mpi_prod)
86 #define MPI_MIN           (smpi_mpi_global->mpi_min)
87 #define MPI_MAX           (smpi_mpi_global->mpi_max)
88
89 // MPI macros
90 #define MPI_Init(a, b) SMPI_MPI_Init(a, b)
91 #define MPI_Finalize() SMPI_MPI_Finalize()
92 #define MPI_Abort(a, b) SMPI_MPI_Abort(a, b)
93 #define MPI_Comm_size(a, b) SMPI_MPI_Comm_size(a, b)
94 #define MPI_Comm_split(a, b, c, d) SMPI_MPI_Comm_split(a, b, c, d)
95 #define MPI_Comm_rank(a, b) SMPI_MPI_Comm_rank(a, b)
96 #define MPI_Type_size(a, b) SMPI_MPI_Type_size(a, b)
97 #define MPI_Type_get_extent(a, b, c) SMPI_MPI_Type_get_extent(a, b, c)
98 #define MPI_Type_lb(a, b) SMPI_MPI_Type_lb(a, b)
99 #define MPI_Type_ub(a, b) SMPI_MPI_Type_ub(a, b)
100
101 #define MPI_Barrier(a) SMPI_MPI_Barrier(a)
102 #define MPI_Irecv(a, b, c, d, e, f, g) SMPI_MPI_Irecv(a, b, c, d, e, f, g)
103 #define MPI_Recv(a, b, c, d, e, f, g) SMPI_MPI_Recv(a, b, c, d, e, f, g)
104 #define MPI_Isend(a, b, c, d, e, f, g) SMPI_MPI_Isend(a, b, c, d, e, f, g)
105 #define MPI_Send(a, b, c, d, e, f) SMPI_MPI_Send(a, b, c, d, e, f)
106 #define MPI_Sendrecv( a, b, c, d, e, f, g, h, i, j, k, l) SMPI_MPI_Sendrecv(a, b, c, d, e, f, g, h, i, j, k, l) 
107 #define MPI_Bcast(a, b, c, d, e) SMPI_MPI_Bcast(a, b, c, d, e)
108 #define MPI_Wait(a, b) SMPI_MPI_Wait(a, b)
109 #define MPI_Waitall(a, b, c) SMPI_MPI_Waitall(a, b, c)
110 #define MPI_Waitany(a, b, c, d) SMPI_MPI_Waitany(a, b, c, d)
111 #define MPI_Wtime() SMPI_MPI_Wtime()
112 #define MPI_Reduce(a, b, c, d, e, f, g) SMPI_MPI_Reduce(a, b, c, d, e, f, g)
113 #define MPI_Allreduce(a, b, c, d, e, f) SMPI_MPI_Allreduce(a, b, c, d, e, f)
114 #define MPI_Scatter(a, b, c, d, e, f, g, h )  SMPI_MPI_Scatter(a, b, c, d, e, f, g, h)
115 #define MPI_Alltoall(a, b, c, d, e, f, g )  SMPI_MPI_Alltoall(a, b, c, d, e, f, g)
116 #define MPI_Alltoallv(a, b, c, d, e, f, g, h, i)  SMPI_MPI_Alltoallv(a, b, c, d, e, f, g, h, i)
117 #define MPI_Gather(a, b, c, d, e, f, g, h) SMPI_MPI_Gather(a, b, c, d, e, f, g, h)
118 #define MPI_Gatherv(a, b, c, d, e, f, g, h, i) SMPI_MPI_Gatherv(a, b, c, d, e, f, g, h, i)
119 #define MPI_Scatterv(a, b, c, d, e, f, g, h, i) SMPI_MPI_Scatterv(a, b, c, d, e, f, g, h, i)
120 #define MPI_Reduce_scatter(a, b, c, d, e, f) SMPI_MPI_Reduce_scatter(a, b, c, d, e, f)
121 #define MPI_Allgather(a, b, c, d, e, f, g) SMPI_MPI_Allgather(a, b, c, d, e, f, g)
122 #define MPI_Allgatherv(a, b, c, d, e, f, g, h) SMPI_MPI_Allgatherv(a, b, c, d, e, f, g, h)
123
124 // SMPI Functions
125 XBT_PUBLIC(int) SMPI_MPI_Init(int *argc, char ***argv);
126 XBT_PUBLIC(int) SMPI_MPI_Finalize(void);
127 XBT_PUBLIC(int) SMPI_MPI_Abort(MPI_Comm comm, int errorcode);
128 XBT_PUBLIC(int) SMPI_MPI_Comm_size(MPI_Comm comm, int *size);
129 XBT_PUBLIC(int) SMPI_MPI_Comm_rank(MPI_Comm comm, int *rank);
130 XBT_PUBLIC(int) SMPI_MPI_Type_size(MPI_Datatype datatype, size_t * size);
131 XBT_PUBLIC(int) SMPI_MPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint* lb, MPI_Aint *extent);
132 XBT_PUBLIC(int) SMPI_MPI_Type_lb(MPI_Datatype datatype, MPI_Aint* disp);
133 XBT_PUBLIC(int) SMPI_MPI_Type_ub(MPI_Datatype datatype, MPI_Aint* disp);
134
135
136 XBT_PUBLIC(int) SMPI_MPI_Barrier(MPI_Comm comm);
137 XBT_PUBLIC(int) SMPI_MPI_Irecv(void *buf, int count, MPI_Datatype datatype,
138                                int src, int tag, MPI_Comm comm,
139                                MPI_Request * request);
140 XBT_PUBLIC(int) SMPI_MPI_Recv(void *buf, int count, MPI_Datatype datatype,
141                               int src, int tag, MPI_Comm comm,
142                               MPI_Status * status);
143 XBT_PUBLIC(int) SMPI_MPI_Isend(void *buf, int count, MPI_Datatype datatype,
144                                int dst, int tag, MPI_Comm comm,
145                                MPI_Request * request);
146 XBT_PUBLIC(int) SMPI_MPI_Send(void *buf, int count, MPI_Datatype datatype,
147                               int dst, int tag, MPI_Comm comm);
148
149 XBT_PUBLIC(int) SMPI_MPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, 
150                                   void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, 
151                                         MPI_Comm comm, MPI_Status *status);
152
153 XBT_PUBLIC(int) SMPI_MPI_Bcast(void *buf, int count, MPI_Datatype datatype,
154                                int root, MPI_Comm comm);
155 XBT_PUBLIC(int) SMPI_MPI_Wait(MPI_Request * request, MPI_Status * status);
156 XBT_PUBLIC(int) SMPI_MPI_Waitall(int count, MPI_Request requests[],
157                                  MPI_Status status[]);
158 XBT_PUBLIC(int) SMPI_MPI_Waitany(int count, MPI_Request requests[],
159                                  int *index, MPI_Status status[]);
160 XBT_PUBLIC(int) SMPI_MPI_Comm_split(MPI_Comm comm, int color, int key,
161                                     MPI_Comm * comm_out);
162 XBT_PUBLIC(double) SMPI_MPI_Wtime(void);
163
164 XBT_PUBLIC(int) SMPI_MPI_Reduce(void *sendbuf, void *recvbuf, int count,
165                                 MPI_Datatype datatype, MPI_Op op, int root,
166                                 MPI_Comm comm);
167 XBT_PUBLIC(int) SMPI_MPI_Allreduce(void *sendbuf, void *recvbuf, int count,
168                                     MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
169
170 XBT_PUBLIC(int) SMPI_MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype datatype,
171                                      void *recvbuf, int recvcount, MPI_Datatype recvtype,int root, MPI_Comm comm);
172
173 XBT_PUBLIC(int) SMPI_MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype datatype,
174                                      void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
175 XBT_PUBLIC(int) SMPI_MPI_Alltoallv(void *sendbuf, int *scounts, int *sdisps, MPI_Datatype datatype, 
176                            void *recvbuf, int *rcounts, int *rdisps, MPI_Datatype recvtype,
177                              MPI_Comm comm);
178 XBT_PUBLIC(int) SMPI_MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
179                                 void* recvbuf, int recvcount, MPI_Datatype recvtype,
180                                 int root, MPI_Comm comm);
181 XBT_PUBLIC(int) SMPI_MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
182                      void* recvbuf, int* recvcounts, int* displs, MPI_Datatype recvtype,
183                      int root, MPI_Comm comm);
184 XBT_PUBLIC(int) SMPI_MPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, MPI_Datatype sendtype,
185                       void* recvbuf, int recvcount, MPI_Datatype recvtype,
186                       int root, MPI_Comm comm);
187 XBT_PUBLIC(int) SMPI_MPI_Reduce_scatter(void* sendbuf, void* recvbuf, int *recvcounts,
188                             MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
189 XBT_PUBLIC(int) SMPI_MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
190                        void* recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
191 XBT_PUBLIC(int) SMPI_MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype,
192                        void* recvbuf, int *recvcounts, int *displs, MPI_Datatype recvtype,
193                        MPI_Comm comm);
194 // smpi functions
195 XBT_IMPORT_NO_EXPORT(int) smpi_simulated_main(int argc, char **argv);
196 XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int);
197 XBT_PUBLIC(void) smpi_exit(int);
198 XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv, struct timezone *tz);
199
200 XBT_PUBLIC(void) smpi_do_once_1(const char *file, int line);
201 XBT_PUBLIC(int) smpi_do_once_2(void);
202 XBT_PUBLIC(void) smpi_do_once_3(void);
203
204 #define SMPI_DO_ONCE for (smpi_do_once_1(__FILE__, __LINE__); smpi_do_once_2(); smpi_do_once_3())
205
206 SG_END_DECL()
207 #endif