Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove warnings in smpi selector
[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_interface.h"
14 #include "smpi/smpi.h"
15 #include "smpi/smpif.h"
16 #include "smpi/smpi_cocci.h"
17 #include "instr/instr_private.h"
18
19 struct s_smpi_process_data;
20 typedef struct s_smpi_process_data *smpi_process_data_t;
21
22 #define PERSISTENT     0x1
23 #define NON_PERSISTENT 0x2
24 #define SEND           0x4
25 #define RECV           0x8
26 #define RECV_DELETE    0x10
27 #define ISEND          0x20
28 #define SSEND          0x40
29 // this struct is here to handle the problem of non-contignous data
30 // for each such structure these function should be implemented (vector
31 // index hvector hindex struct)
32 typedef struct s_smpi_subtype{
33   void (*serialize)(const void * input, void *output, size_t count, void* subtype);
34   void (*unserialize)(const void * input, void *output, size_t count, void* subtype);
35   void (*subtype_free)(MPI_Datatype* type);
36 } s_smpi_subtype_t;
37
38 typedef struct s_smpi_mpi_datatype{
39   size_t size;
40   /* this let us know if a serialization is required*/
41   size_t has_subtype;
42   MPI_Aint lb;
43   MPI_Aint ub;
44   int flags;
45   /* this let us know how to serialize and unserialize*/
46   void *substruct;
47   int in_use;
48 } s_smpi_mpi_datatype_t;
49
50 //*****************************************************************************************
51
52 typedef struct s_smpi_mpi_request {
53   void *buf;
54   /* in the case of non-contignous memory the user address shoud be keep
55    * to unserialize the data inside the user memory*/
56   void *old_buf;
57   /* this let us know how tounserialize at the end of
58    * the communication*/
59   MPI_Datatype old_type;
60   size_t size;
61   int src;
62   int dst;
63   int tag;
64   //to handle cases where we have an unknown sender
65   //We can't override src, tag, and size, because the request may be reused later
66   int real_src;
67   int real_tag;
68   int truncated;
69   size_t real_size;
70   MPI_Comm comm;
71   smx_action_t action;
72   unsigned flags;
73   int detached;
74   MPI_Request detached_sender;
75   int refcount;
76 #ifdef HAVE_TRACING
77   int send;
78   int recv;
79 #endif
80 } s_smpi_mpi_request_t;
81
82 void smpi_process_init(int *argc, char ***argv);
83 void smpi_process_destroy(void);
84 void smpi_process_finalize(void);
85
86 smpi_process_data_t smpi_process_data(void);
87 smpi_process_data_t smpi_process_remote_data(int index);
88 void smpi_process_set_user_data(void *);
89 void* smpi_process_get_user_data(void);
90 int smpi_process_count(void);
91 smx_rdv_t smpi_process_mailbox(void);
92 smx_rdv_t smpi_process_remote_mailbox(int index);
93 smx_rdv_t smpi_process_mailbox_small(void);
94 smx_rdv_t smpi_process_remote_mailbox_small(int index);
95 xbt_os_timer_t smpi_process_timer(void);
96 void smpi_process_simulated_start(void);
97 double smpi_process_simulated_elapsed(void);
98
99 void print_request(const char *message, MPI_Request request);
100
101 void smpi_global_init(void);
102 void smpi_global_destroy(void);
103
104 size_t smpi_datatype_size(MPI_Datatype datatype);
105 MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
106 MPI_Aint smpi_datatype_ub(MPI_Datatype datatype);
107 int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
108                          MPI_Aint * extent);
109 MPI_Aint smpi_datatype_get_extent(MPI_Datatype datatype);
110 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
111                        void *recvbuf, int recvcount,
112                        MPI_Datatype recvtype);
113 void smpi_datatype_use(MPI_Datatype type);
114 void smpi_datatype_unuse(MPI_Datatype type);
115
116 int smpi_datatype_contiguous(int count, MPI_Datatype old_type,
117                        MPI_Datatype* new_type);
118 int smpi_datatype_vector(int count, int blocklen, int stride,
119                       MPI_Datatype old_type, MPI_Datatype* new_type);
120
121 int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride,
122                       MPI_Datatype old_type, MPI_Datatype* new_type);
123 int smpi_datatype_indexed(int count, int* blocklens, int* indices,
124                      MPI_Datatype old_type, MPI_Datatype* new_type);
125 int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices,
126                      MPI_Datatype old_type, MPI_Datatype* new_type);
127 int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices,
128                     MPI_Datatype* old_types, MPI_Datatype* new_type);
129
130 void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int has_subtype, void *struct_type, int flags);
131
132
133 void smpi_datatype_free(MPI_Datatype* type);
134 void smpi_datatype_commit(MPI_Datatype* datatype);
135
136 void smpi_empty_status(MPI_Status * status);
137 MPI_Op smpi_op_new(MPI_User_function * function, int commute);
138 void smpi_op_destroy(MPI_Op op);
139 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
140                    MPI_Datatype * datatype);
141
142 MPI_Group smpi_group_new(int size);
143 void smpi_group_destroy(MPI_Group group);
144 void smpi_group_set_mapping(MPI_Group group, int index, int rank);
145 int smpi_group_index(MPI_Group group, int rank);
146 int smpi_group_rank(MPI_Group group, int index);
147 int smpi_group_use(MPI_Group group);
148 int smpi_group_unuse(MPI_Group group);
149 int smpi_group_size(MPI_Group group);
150 int smpi_group_compare(MPI_Group group1, MPI_Group group2);
151
152 MPI_Comm smpi_comm_new(MPI_Group group);
153 void smpi_comm_destroy(MPI_Comm comm);
154 MPI_Group smpi_comm_group(MPI_Comm comm);
155 int smpi_comm_size(MPI_Comm comm);
156 void smpi_comm_get_name(MPI_Comm comm, char* name, int* len);
157 int smpi_comm_rank(MPI_Comm comm);
158 MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key);
159
160 MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
161                                int dst, int tag, MPI_Comm comm);
162 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
163                                int src, int tag, MPI_Comm comm);
164 MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype,
165                                int dst, int tag, MPI_Comm comm);
166 void smpi_mpi_start(MPI_Request request);
167 void smpi_mpi_startall(int count, MPI_Request * requests);
168 void smpi_mpi_request_free(MPI_Request * request);
169 MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
170                             int dst, int tag, MPI_Comm comm);
171 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
172                            int dst, int tag, MPI_Comm comm);
173 MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype,
174                            int dst, int tag, MPI_Comm comm);
175 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
176                             int src, int tag, MPI_Comm comm);
177 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
178                            int src, int tag, MPI_Comm comm);
179 void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
180                    int tag, MPI_Comm comm, MPI_Status * status);
181 void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
182                    int tag, MPI_Comm comm);
183 void smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype, int dst,
184                    int tag, MPI_Comm comm);
185 void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
186                        int dst, int sendtag, void *recvbuf, int recvcount,
187                        MPI_Datatype recvtype, int src, int recvtag,
188                        MPI_Comm comm, MPI_Status * status);
189 int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
190 int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
191                      MPI_Status * status);
192 int smpi_mpi_testall(int count, MPI_Request requests[],
193                      MPI_Status status[]);
194 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
195 void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag,
196                     MPI_Status* status);
197 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
198 void smpi_mpi_wait(MPI_Request * request, MPI_Status * status);
199 int smpi_mpi_waitany(int count, MPI_Request requests[],
200                      MPI_Status * status);
201 int smpi_mpi_waitall(int count, MPI_Request requests[],
202                       MPI_Status status[]);
203 int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
204                       MPI_Status status[]);
205 int smpi_mpi_testsome(int incount, MPI_Request requests[], int *indices,
206                       MPI_Status status[]);
207 void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
208                     MPI_Comm comm);
209 void smpi_mpi_barrier(MPI_Comm comm);
210 void smpi_mpi_gather(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_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
214                       void *recvbuf, int *recvcounts, int *displs,
215                       MPI_Datatype recvtype, int root, MPI_Comm comm);
216 void smpi_mpi_allgather(void *sendbuf, int sendcount,
217                         MPI_Datatype sendtype, void *recvbuf,
218                         int recvcount, MPI_Datatype recvtype,
219                         MPI_Comm comm);
220 void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
221                          MPI_Datatype sendtype, void *recvbuf,
222                          int *recvcounts, int *displs,
223                          MPI_Datatype recvtype, MPI_Comm comm);
224 void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
225                       void *recvbuf, int recvcount, MPI_Datatype recvtype,
226                       int root, MPI_Comm comm);
227 void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
228                        MPI_Datatype sendtype, void *recvbuf, int recvcount,
229                        MPI_Datatype recvtype, int root, MPI_Comm comm);
230 void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
231                      MPI_Datatype datatype, MPI_Op op, int root,
232                      MPI_Comm comm);
233 void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
234                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
235 void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
236                    MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
237
238 void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
239                      MPI_Comm comm, int arity);
240 void nary_tree_barrier(MPI_Comm comm, int arity);
241
242 int smpi_coll_tuned_alltoall_ompi2(void *sendbuf, int sendcount,
243                                       MPI_Datatype sendtype, void *recvbuf,
244                                       int recvcount, MPI_Datatype recvtype,
245                                       MPI_Comm comm);
246 int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
247                                    MPI_Datatype sendtype, void *recvbuf,
248                                    int recvcount, MPI_Datatype recvtype,
249                                    MPI_Comm comm);
250 int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
251                                           MPI_Datatype sendtype,
252                                           void *recvbuf, int recvcount,
253                                           MPI_Datatype recvtype,
254                                           MPI_Comm comm);
255 int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
256                               int *senddisps, MPI_Datatype sendtype,
257                               void *recvbuf, int *recvcounts,
258                               int *recvdisps, MPI_Datatype recvtype,
259                               MPI_Comm comm);
260
261 // utilities
262 void smpi_bench_destroy(void);
263 void smpi_bench_begin(void);
264 void smpi_bench_end(void);
265 void smpi_execute_flops(double flops);
266
267 // f77 wrappers
268 void mpi_init_(int*);
269 void mpi_finalize_(int*);
270 void mpi_abort_(int* comm, int* errorcode, int* ierr);
271 void mpi_comm_rank_(int* comm, int* rank, int* ierr);
272 void mpi_comm_size_(int* comm, int* size, int* ierr);
273 double mpi_wtime_(void);
274 double mpi_wtick_(void);
275 void mpi_initialized_(int* flag, int* ierr);
276
277 void mpi_comm_dup_(int* comm, int* newcomm, int* ierr);
278 void mpi_comm_create_(int* comm, int* group, int* newcomm, int* ierr);
279 void mpi_comm_free_(int* comm, int* ierr);
280 void mpi_comm_split_(int* comm, int* color, int* key, int* comm_out, int* ierr);
281 void mpi_group_incl_(int* group, int* n, int* key, int* group_out, int* ierr) ;
282 void mpi_comm_group_(int* comm, int* group_out,  int* ierr);
283 void mpi_send_init_(void *buf, int* count, int* datatype, int* dst, int* tag,
284                      int* comm, int* request, int* ierr);
285 void mpi_isend_(void *buf, int* count, int* datatype, int* dst,
286                  int* tag, int* comm, int* request, int* ierr);
287 void mpi_irsend_(void *buf, int* count, int* datatype, int* dst,
288                  int* tag, int* comm, int* request, int* ierr);
289 void mpi_send_(void* buf, int* count, int* datatype, int* dst,
290                 int* tag, int* comm, int* ierr);
291 void mpi_rsend_(void* buf, int* count, int* datatype, int* dst,
292                 int* tag, int* comm, int* ierr);
293 void mpi_recv_init_(void *buf, int* count, int* datatype, int* src, int* tag,
294                      int* comm, int* request, int* ierr);
295 void mpi_irecv_(void *buf, int* count, int* datatype, int* src, int* tag,
296                  int* comm, int* request, int* ierr);
297 void mpi_recv_(void* buf, int* count, int* datatype, int* src,
298                 int* tag, int* comm, MPI_Status* status, int* ierr);
299 void mpi_start_(int* request, int* ierr);
300 void mpi_startall_(int* count, int* requests, int* ierr);
301 void mpi_wait_(int* request, MPI_Status* status, int* ierr);
302 void mpi_waitany_(int* count, int* requests, int* index, MPI_Status* status, int* ierr);
303 void mpi_waitall_(int* count, int* requests, MPI_Status* status, int* ierr);
304
305 void mpi_barrier_(int* comm, int* ierr);
306 void mpi_bcast_(void* buf, int* count, int* datatype, int* root, int* comm, int* ierr);
307 void mpi_reduce_(void* sendbuf, void* recvbuf, int* count,
308                   int* datatype, int* op, int* root, int* comm, int* ierr);
309 void mpi_allreduce_(void* sendbuf, void* recvbuf, int* count, int* datatype,
310                      int* op, int* comm, int* ierr);
311 void mpi_reduce_scatter_(void* sendbuf, void* recvbuf, int* recvcounts, int* datatype,
312                      int* op, int* comm, int* ierr) ;
313 void mpi_scatter_(void* sendbuf, int* sendcount, int* sendtype,
314                    void* recvbuf, int* recvcount, int* recvtype,
315                    int* root, int* comm, int* ierr);
316 void mpi_scatterv_(void* sendbuf, int* sendcounts, int* displs, int* sendtype,
317                    void* recvbuf, int* recvcount, int* recvtype,
318                    int* root, int* comm, int* ierr);
319 void mpi_gather_(void* sendbuf, int* sendcount, int* sendtype,
320                   void* recvbuf, int* recvcount, int* recvtype,
321                   int* root, int* comm, int* ierr);
322 void mpi_gatherv_(void* sendbuf, int* sendcount, int* sendtype,
323                   void* recvbuf, int* recvcounts, int* displs, int* recvtype,
324                   int* root, int* comm, int* ierr);
325 void mpi_allgather_(void* sendbuf, int* sendcount, int* sendtype,
326                      void* recvbuf, int* recvcount, int* recvtype,
327                      int* comm, int* ierr);
328 void mpi_allgatherv_(void* sendbuf, int* sendcount, int* sendtype,
329                      void* recvbuf, int* recvcount,int* displs, int* recvtype,
330                      int* comm, int* ierr) ;
331 void mpi_type_size_(int* datatype, int *size, int* ierr);
332
333 void mpi_scan_(void* sendbuf, void* recvbuf, int* count, int* datatype,
334                 int* op, int* comm, int* ierr);
335 void mpi_alltoall_(void* sendbuf, int* sendcount, int* sendtype,
336                     void* recvbuf, int* recvcount, int* recvtype, int* comm, int* ierr);
337 void mpi_alltoallv_(void* sendbuf, int* sendcounts, int* senddisps, int* sendtype,
338                     void* recvbuf, int* recvcounts, int* recvdisps, int* recvtype, int* comm, int* ierr);
339 void mpi_get_processor_name_(char *name, int *resultlen, int* ierr);
340 void mpi_test_ (int * request, int *flag, MPI_Status * status, int* ierr);
341 void mpi_testall_ (int* count, int * requests,  int *flag, MPI_Status * statuses, int* ierr);
342 void mpi_get_count_(MPI_Status * status, int* datatype, int *count, int* ierr);
343 void mpi_type_extent_(int* datatype, MPI_Aint * extent, int* ierr);
344 void mpi_attr_get_(int* comm, int* keyval, void* attr_value, int* flag, int* ierr );
345 void mpi_type_commit_(int* datatype,  int* ierr);
346 void mpi_type_vector_(int* count, int* blocklen, int* stride, int* old_type, int* newtype,  int* ierr);
347 void mpi_type_create_vector_(int* count, int* blocklen, int* stride, int* old_type, int* newtype,  int* ierr);
348 void mpi_type_hvector_(int* count, int* blocklen, MPI_Aint* stride, int* old_type, int* newtype,  int* ierr);
349 void mpi_type_create_hvector_(int* count, int* blocklen, MPI_Aint* stride, int* old_type, int* newtype,  int* ierr);
350 void mpi_type_free_(int* datatype, int* ierr);
351 void mpi_type_lb_(int* datatype, MPI_Aint * extent, int* ierr);
352 void mpi_type_ub_(int* datatype, MPI_Aint * extent, int* ierr);
353 void mpi_win_fence_( int* assert,  int* win, int* ierr);
354 void mpi_win_free_( int* win, int* ierr);
355 void mpi_win_create_( int *base, MPI_Aint* size, int* disp_unit, int* info, int* comm, int *win, int* ierr);
356 void mpi_info_create_( int *info, int* ierr);
357 void mpi_info_set_( int *info, char *key, char *value, int* ierr);
358 void mpi_info_free_(int* info, int* ierr);
359 void mpi_get_( int *origin_addr, int* origin_count, int* origin_datatype, int* target_rank,
360     MPI_Aint* target_disp, int* target_count, int* target_datatype, int* win, int* ierr);
361 void mpi_error_string_(int* errorcode, char* string, int* resultlen, int* ierr);
362 void mpi_sendrecv_(void* sendbuf, int* sendcount, int* sendtype, int* dst,
363                 int* sendtag, void *recvbuf, int* recvcount,
364                 int* recvtype, int* src, int* recvtag,
365                 int* comm, MPI_Status* status, int* ierr);
366
367 /********** Tracing **********/
368 /* from smpi_instr.c */
369 void TRACE_internal_smpi_set_category (const char *category);
370 const char *TRACE_internal_smpi_get_category (void);
371 void TRACE_smpi_collective_in(int rank, int root, const char *operation);
372 void TRACE_smpi_collective_out(int rank, int root, const char *operation);
373 void TRACE_smpi_computing_init(int rank);
374 void TRACE_smpi_computing_out(int rank);
375 void TRACE_smpi_computing_in(int rank);
376
377 #endif