Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / smpi / private.h
1 /* Copyright (c) 2007, 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_PRIVATE_H
8 #define SMPI_PRIVATE_H
9
10 #include "xbt.h"
11 #include "xbt/xbt_os_time.h"
12 #include "simgrid/simix.h"
13 #include "smpi/smpi.h"
14 #include "smpi/smpif.h"
15 #include "smpi/smpi_cocci.h"
16 #include "instr/instr_private.h"
17
18 struct s_smpi_process_data;
19 typedef struct s_smpi_process_data *smpi_process_data_t;
20
21 #define PERSISTENT     0x1
22 #define NON_PERSISTENT 0x2
23 #define SEND           0x4
24 #define RECV           0x8
25 #define RECV_DELETE     0x10
26
27 // this struct is here to handle the problem of non-contignous data
28 // for each such structure these function should be implemented (vector
29 // index hvector hindex struct)
30 typedef struct s_smpi_subtype{
31   void (*serialize)(const void * input, void *output, size_t count, void* subtype);
32   void (*unserialize)(const void * input, void *output, size_t count, void* subtype);
33   void (*subtype_free)(MPI_Datatype* type);
34 } s_smpi_subtype_t;
35
36 typedef struct s_smpi_mpi_datatype{
37   size_t size;
38   /* this let us know if a serialization is required*/
39   size_t has_subtype;
40   MPI_Aint lb;
41   MPI_Aint ub;
42   int flags;
43   /* this let us know how to serialize and unserialize*/
44   void *substruct;
45 } s_smpi_mpi_datatype_t;
46
47 //*****************************************************************************************
48
49 typedef struct s_smpi_mpi_request {
50   void *buf;
51   /* in the case of non-contignous memory the user address shoud be keep
52    * to unserialize the data inside the user memory*/
53   void *old_buf;
54   /* this let us know how tounserialize at the end of
55    * the communication*/
56   MPI_Datatype old_type;
57   size_t size;
58   int src;
59   int dst;
60   int tag;
61   //to handle cases where we have an unknown sender
62   //We can't override src, tag, and size, because the request may be reused later
63   int real_src;
64   int real_tag;
65   int truncated;
66   size_t real_size;
67   MPI_Comm comm;
68   smx_action_t action;
69   unsigned flags;
70   int detached;
71 #ifdef HAVE_TRACING
72   int send;
73   int recv;
74 #endif
75 } s_smpi_mpi_request_t;
76
77 void smpi_process_init(int *argc, char ***argv);
78 void smpi_process_destroy(void);
79 void smpi_process_finalize(void);
80
81 smpi_process_data_t smpi_process_data(void);
82 smpi_process_data_t smpi_process_remote_data(int index);
83 void smpi_process_set_user_data(void *);
84 void* smpi_process_get_user_data(void);
85 int smpi_process_count(void);
86 smx_rdv_t smpi_process_mailbox(void);
87 smx_rdv_t smpi_process_remote_mailbox(int index);
88 smx_rdv_t smpi_process_mailbox_small(void);
89 smx_rdv_t smpi_process_remote_mailbox_small(int index);
90 xbt_os_timer_t smpi_process_timer(void);
91 void smpi_process_simulated_start(void);
92 double smpi_process_simulated_elapsed(void);
93
94 void print_request(const char *message, MPI_Request request);
95
96 void smpi_global_init(void);
97 void smpi_global_destroy(void);
98
99 size_t smpi_datatype_size(MPI_Datatype datatype);
100 MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
101 MPI_Aint smpi_datatype_ub(MPI_Datatype datatype);
102 int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
103                          MPI_Aint * extent);
104 MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype);
105 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
106                        void *recvbuf, int recvcount,
107                        MPI_Datatype recvtype);
108 int smpi_datatype_contiguous(int count, MPI_Datatype old_type,
109                        MPI_Datatype* new_type);
110 int smpi_datatype_vector(int count, int blocklen, int stride,
111                       MPI_Datatype old_type, MPI_Datatype* new_type);
112
113 int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride,
114                       MPI_Datatype old_type, MPI_Datatype* new_type);
115 int smpi_datatype_indexed(int count, int* blocklens, int* indices,
116                      MPI_Datatype old_type, MPI_Datatype* new_type);
117 int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices,
118                      MPI_Datatype old_type, MPI_Datatype* new_type);
119 int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices,
120                     MPI_Datatype* old_types, MPI_Datatype* new_type);
121
122 void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int has_subtype, void *struct_type, int flags);
123
124
125 void smpi_datatype_free(MPI_Datatype* type);
126 void smpi_datatype_commit(MPI_Datatype* datatype);
127
128 void smpi_empty_status(MPI_Status * status);
129 MPI_Op smpi_op_new(MPI_User_function * function, int commute);
130 void smpi_op_destroy(MPI_Op op);
131 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
132                    MPI_Datatype * datatype);
133
134 MPI_Group smpi_group_new(int size);
135 void smpi_group_destroy(MPI_Group group);
136 void smpi_group_set_mapping(MPI_Group group, int index, int rank);
137 int smpi_group_index(MPI_Group group, int rank);
138 int smpi_group_rank(MPI_Group group, int index);
139 int smpi_group_use(MPI_Group group);
140 int smpi_group_unuse(MPI_Group group);
141 int smpi_group_size(MPI_Group group);
142 int smpi_group_compare(MPI_Group group1, MPI_Group group2);
143
144 MPI_Comm smpi_comm_new(MPI_Group group);
145 void smpi_comm_destroy(MPI_Comm comm);
146 MPI_Group smpi_comm_group(MPI_Comm comm);
147 int smpi_comm_size(MPI_Comm comm);
148 void smpi_comm_get_name(MPI_Comm comm, char* name, int* len);
149 int smpi_comm_rank(MPI_Comm comm);
150 MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key);
151
152 MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
153                                int dst, int tag, MPI_Comm comm);
154 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
155                                int src, int tag, MPI_Comm comm);
156 void smpi_mpi_start(MPI_Request request);
157 void smpi_mpi_startall(int count, MPI_Request * requests);
158 void smpi_mpi_request_free(MPI_Request * request);
159 MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
160                             int dst, int tag, MPI_Comm comm);
161 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
162                            int dst, int tag, MPI_Comm comm);
163 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
164                             int src, int tag, MPI_Comm comm);
165 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
166                            int src, int tag, MPI_Comm comm);
167 void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
168                    int tag, MPI_Comm comm, MPI_Status * status);
169 void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
170                    int tag, MPI_Comm comm);
171 void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
172                        int dst, int sendtag, void *recvbuf, int recvcount,
173                        MPI_Datatype recvtype, int src, int recvtag,
174                        MPI_Comm comm, MPI_Status * status);
175 int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
176 int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
177                      MPI_Status * status);
178 int smpi_mpi_testall(int count, MPI_Request requests[],
179                      MPI_Status status[]);
180 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
181 void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag,
182                     MPI_Status* status);
183 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
184 void smpi_mpi_wait(MPI_Request * request, MPI_Status * status);
185 int smpi_mpi_waitany(int count, MPI_Request requests[],
186                      MPI_Status * status);
187 int smpi_mpi_waitall(int count, MPI_Request requests[],
188                       MPI_Status status[]);
189 int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
190                       MPI_Status status[]);
191 int smpi_mpi_testsome(int incount, MPI_Request requests[], int *indices,
192                       MPI_Status status[]);
193 void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
194                     MPI_Comm comm);
195 void smpi_mpi_barrier(MPI_Comm comm);
196 void smpi_mpi_gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
197                      void *recvbuf, int recvcount, MPI_Datatype recvtype,
198                      int root, MPI_Comm comm);
199 void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
200                       void *recvbuf, int *recvcounts, int *displs,
201                       MPI_Datatype recvtype, int root, MPI_Comm comm);
202 void smpi_mpi_allgather(void *sendbuf, int sendcount,
203                         MPI_Datatype sendtype, void *recvbuf,
204                         int recvcount, MPI_Datatype recvtype,
205                         MPI_Comm comm);
206 void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
207                          MPI_Datatype sendtype, void *recvbuf,
208                          int *recvcounts, int *displs,
209                          MPI_Datatype recvtype, MPI_Comm comm);
210 void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
211                       void *recvbuf, int recvcount, MPI_Datatype recvtype,
212                       int root, MPI_Comm comm);
213 void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
214                        MPI_Datatype sendtype, void *recvbuf, int recvcount,
215                        MPI_Datatype recvtype, int root, MPI_Comm comm);
216 void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
217                      MPI_Datatype datatype, MPI_Op op, int root,
218                      MPI_Comm comm);
219 void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
220                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
221 void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
222                    MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
223
224 void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
225                      MPI_Comm comm, int arity);
226 void nary_tree_barrier(MPI_Comm comm, int arity);
227
228 int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
229                                    MPI_Datatype sendtype, void *recvbuf,
230                                    int recvcount, MPI_Datatype recvtype,
231                                    MPI_Comm comm);
232 int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
233                                           MPI_Datatype sendtype,
234                                           void *recvbuf, int recvcount,
235                                           MPI_Datatype recvtype,
236                                           MPI_Comm comm);
237 int smpi_coll_tuned_alltoall_pairwise(void *sendbuf, int sendcount,
238                                       MPI_Datatype sendtype, void *recvbuf,
239                                       int recvcount, MPI_Datatype recvtype,
240                                       MPI_Comm comm);
241 int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
242                               int *senddisps, MPI_Datatype sendtype,
243                               void *recvbuf, int *recvcounts,
244                               int *recvdisps, MPI_Datatype recvtype,
245                               MPI_Comm comm);
246
247 // utilities
248 void smpi_bench_destroy(void);
249 void smpi_bench_begin(void);
250 void smpi_bench_end(void);
251 void smpi_execute_flops(double flops);
252
253 // f77 wrappers
254 void mpi_init__(int*);
255 void mpi_finalize__(int*);
256 void mpi_abort__(int* comm, int* errorcode, int* ierr);
257 void mpi_comm_rank__(int* comm, int* rank, int* ierr);
258 void mpi_comm_size__(int* comm, int* size, int* ierr);
259 double mpi_wtime__(void);
260 double mpi_wtick__(void);
261
262 void mpi_comm_dup__(int* comm, int* newcomm, int* ierr);
263 void mpi_comm_split__(int* comm, int* color, int* key, int* comm_out, int* ierr);
264
265 void mpi_send_init__(void *buf, int* count, int* datatype, int* dst, int* tag,
266                      int* comm, int* request, int* ierr);
267 void mpi_isend__(void *buf, int* count, int* datatype, int* dst,
268                  int* tag, int* comm, int* request, int* ierr);
269 void mpi_send__(void* buf, int* count, int* datatype, int* dst,
270                 int* tag, int* comm, int* ierr);
271 void mpi_recv_init__(void *buf, int* count, int* datatype, int* src, int* tag,
272                      int* comm, int* request, int* ierr);
273 void mpi_irecv__(void *buf, int* count, int* datatype, int* src, int* tag,
274                  int* comm, int* request, int* ierr);
275 void mpi_recv__(void* buf, int* count, int* datatype, int* src,
276                 int* tag, int* comm, MPI_Status* status, int* ierr);
277 void mpi_start__(int* request, int* ierr);
278 void mpi_startall__(int* count, int* requests, int* ierr);
279 void mpi_wait__(int* request, MPI_Status* status, int* ierr);
280 void mpi_waitany__(int* count, int* requests, int* index, MPI_Status* status, int* ierr);
281 void mpi_waitall__(int* count, int* requests, MPI_Status* status, int* ierr);
282
283 void mpi_barrier__(int* comm, int* ierr);
284 void mpi_bcast__(void* buf, int* count, int* datatype, int* root, int* comm, int* ierr);
285 void mpi_reduce__(void* sendbuf, void* recvbuf, int* count,
286                   int* datatype, int* op, int* root, int* comm, int* ierr);
287 void mpi_allreduce__(void* sendbuf, void* recvbuf, int* count, int* datatype,
288                      int* op, int* comm, int* ierr);
289 void mpi_scatter__(void* sendbuf, int* sendcount, int* sendtype,
290                    void* recvbuf, int* recvcount, int* recvtype,
291                    int* root, int* comm, int* ierr);
292 void mpi_gather__(void* sendbuf, int* sendcount, int* sendtype,
293                   void* recvbuf, int* recvcount, int* recvtype,
294                   int* root, int* comm, int* ierr);
295 void mpi_gatherv__(void* sendbuf, int* sendcount, int* sendtype,
296                   void* recvbuf, int* recvcounts, int* displs, int* recvtype,
297                   int* root, int* comm, int* ierr);
298 void mpi_allgather__(void* sendbuf, int* sendcount, int* sendtype,
299                      void* recvbuf, int* recvcount, int* recvtype,
300                      int* comm, int* ierr);
301 void mpi_allgatherv__(void* sendbuf, int* sendcount, int* sendtype,
302                      void* recvbuf, int* recvcount,int* displs, int* recvtype,
303                      int* comm, int* ierr) ;
304 void mpi_type_size__(int* datatype, int *size, int* ierr);
305
306 void mpi_scan__(void* sendbuf, void* recvbuf, int* count, int* datatype,
307                 int* op, int* comm, int* ierr);
308 void mpi_alltoall__(void* sendbuf, int* sendcount, int* sendtype,
309                     void* recvbuf, int* recvcount, int* recvtype, int* comm, int* ierr);
310 void mpi_get_processor_name__(char *name, int *resultlen, int* ierr);
311 void mpi_test__ (int * request, int *flag, MPI_Status * status, int* ierr);
312 void mpi_get_count__(MPI_Status * status, int* datatype, int *count, int* ierr);
313 void mpi_type_extent__(int* datatype, MPI_Aint * extent, int* ierr);
314 void mpi_type_lb__(int* datatype, MPI_Aint * extent, int* ierr);
315 void mpi_type_ub__(int* datatype, MPI_Aint * extent, int* ierr);
316 void mpi_sendrecv__(void* sendbuf, int* sendcount, int* sendtype, int* dst,
317                 int* sendtag, void *recvbuf, int* recvcount,
318                 int* recvtype, int* src, int* recvtag,
319                 int* comm, MPI_Status* status, int* ierr);
320
321
322 #endif