Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
avoid breaking the shiny new and working functionality from jean-noel
[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
26
27 //*****************************************************************************************
28
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 } s_smpi_subtype_t;
36
37 /*one exemple of implementation for the vector is already here*/
38 typedef struct s_smpi_mpi_vector{
39   s_smpi_subtype_t base;
40   size_t block_stride;
41   size_t block_length;
42   size_t block_count;
43   MPI_Datatype old_type;
44   size_t size_oldtype;
45 } s_smpi_mpi_vector_t;
46
47 typedef struct s_smpi_mpi_datatype{
48   size_t size;
49   /* this let us know if a serialization is required*/
50   size_t has_subtype;
51   MPI_Aint lb;
52   MPI_Aint ub;
53   int flags;
54   /* this let us know how to serialize and unserialize*/
55   void *substruct;
56 } s_smpi_mpi_datatype_t;
57
58
59 //*****************************************************************************************
60
61 typedef struct s_smpi_mpi_request {
62   void *buf;
63   /* in the case of non-contignous memory the user address shoud be keep
64    * to unserialize the data inside the user memory*/
65   void *old_buf;
66   /* this let us know how tounserialize at the end of
67    * the communication*/
68   MPI_Datatype old_type;
69   size_t size;
70   int src;
71   int dst;
72   int tag;
73   MPI_Comm comm;
74   smx_action_t action;
75   unsigned flags;
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 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
110                        void *recvbuf, int recvcount,
111                        MPI_Datatype recvtype);
112 int smpi_datatype_contiguous(int count, MPI_Datatype old_type,
113                        MPI_Datatype* new_type);
114 int smpi_datatype_vector(int count, int blocklen, int stride,
115                       MPI_Datatype old_type, MPI_Datatype* new_type);
116
117 int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride,
118                       MPI_Datatype old_type, MPI_Datatype* new_type);
119 int smpi_datatype_indexed(int count, int* blocklens, int* indices,
120                      MPI_Datatype old_type, MPI_Datatype* new_type);
121 int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices,
122                      MPI_Datatype old_type, MPI_Datatype* new_type);
123 int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices,
124                     MPI_Datatype* old_types, MPI_Datatype* new_type);
125
126 void smpi_datatype_create(MPI_Datatype* new_type, int size, int has_subtype, void *struct_type, int flags);
127
128
129 void smpi_datatype_free(MPI_Datatype* type);
130 void smpi_datatype_commit(MPI_Datatype* datatype);
131
132 void unserialize_vector( const void *contiguous_vector,
133                          void *noncontiguous_vector,
134                          size_t count,
135                          void *type);
136
137 void serialize_vector( const void *noncontiguous_vector,
138                        void *contiguous_vector,
139                        size_t count,
140                        void *type);
141
142 s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride,
143                                                   int block_length,
144                                                   int block_count,
145                                                   MPI_Datatype old_type,
146                                                   int size_oldtype);
147
148
149 void smpi_empty_status(MPI_Status * status);
150 MPI_Op smpi_op_new(MPI_User_function * function, int commute);
151 void smpi_op_destroy(MPI_Op op);
152 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
153                    MPI_Datatype * datatype);
154
155 MPI_Group smpi_group_new(int size);
156 void smpi_group_destroy(MPI_Group group);
157 void smpi_group_set_mapping(MPI_Group group, int index, int rank);
158 int smpi_group_index(MPI_Group group, int rank);
159 int smpi_group_rank(MPI_Group group, int index);
160 int smpi_group_use(MPI_Group group);
161 int smpi_group_unuse(MPI_Group group);
162 int smpi_group_size(MPI_Group group);
163 int smpi_group_compare(MPI_Group group1, MPI_Group group2);
164
165 MPI_Comm smpi_comm_new(MPI_Group group);
166 void smpi_comm_destroy(MPI_Comm comm);
167 MPI_Group smpi_comm_group(MPI_Comm comm);
168 int smpi_comm_size(MPI_Comm comm);
169 void smpi_comm_get_name(MPI_Comm comm, char* name, int* len);
170 int smpi_comm_rank(MPI_Comm comm);
171 MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key);
172
173 MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
174                                int dst, int tag, MPI_Comm comm);
175 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
176                                int src, int tag, MPI_Comm comm);
177 void smpi_mpi_start(MPI_Request request);
178 void smpi_mpi_startall(int count, MPI_Request * requests);
179 void smpi_mpi_request_free(MPI_Request * request);
180 MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
181                             int dst, int tag, MPI_Comm comm);
182 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
183                            int dst, int tag, MPI_Comm comm);
184 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
185                             int src, int tag, MPI_Comm comm);
186 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
187                            int src, int tag, MPI_Comm comm);
188 void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
189                    int tag, MPI_Comm comm, MPI_Status * status);
190 void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
191                    int tag, MPI_Comm comm);
192 void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
193                        int dst, int sendtag, void *recvbuf, int recvcount,
194                        MPI_Datatype recvtype, int src, int recvtag,
195                        MPI_Comm comm, MPI_Status * status);
196 int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
197 int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
198                      MPI_Status * status);
199 int smpi_mpi_testall(int count, MPI_Request requests[],
200                      MPI_Status status[]);
201 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
202 void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag,
203                     MPI_Status* status);
204 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
205 void smpi_mpi_wait(MPI_Request * request, MPI_Status * status);
206 int smpi_mpi_waitany(int count, MPI_Request requests[],
207                      MPI_Status * status);
208 void smpi_mpi_waitall(int count, MPI_Request requests[],
209                       MPI_Status status[]);
210 int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
211                       MPI_Status status[]);
212 int smpi_mpi_testsome(int incount, MPI_Request requests[], int *indices,
213                       MPI_Status status[]);
214 void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
215                     MPI_Comm comm);
216 void smpi_mpi_barrier(MPI_Comm comm);
217 void smpi_mpi_gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
218                      void *recvbuf, int recvcount, MPI_Datatype recvtype,
219                      int root, MPI_Comm comm);
220 void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
221                       void *recvbuf, int *recvcounts, int *displs,
222                       MPI_Datatype recvtype, int root, MPI_Comm comm);
223 void smpi_mpi_allgather(void *sendbuf, int sendcount,
224                         MPI_Datatype sendtype, void *recvbuf,
225                         int recvcount, MPI_Datatype recvtype,
226                         MPI_Comm comm);
227 void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
228                          MPI_Datatype sendtype, void *recvbuf,
229                          int *recvcounts, int *displs,
230                          MPI_Datatype recvtype, MPI_Comm comm);
231 void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
232                       void *recvbuf, int recvcount, MPI_Datatype recvtype,
233                       int root, MPI_Comm comm);
234 void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
235                        MPI_Datatype sendtype, void *recvbuf, int recvcount,
236                        MPI_Datatype recvtype, int root, MPI_Comm comm);
237 void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
238                      MPI_Datatype datatype, MPI_Op op, int root,
239                      MPI_Comm comm);
240 void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
241                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
242 void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
243                    MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
244
245 void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
246                      MPI_Comm comm, int arity);
247 void nary_tree_barrier(MPI_Comm comm, int arity);
248
249 int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
250                                    MPI_Datatype sendtype, void *recvbuf,
251                                    int recvcount, MPI_Datatype recvtype,
252                                    MPI_Comm comm);
253 int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
254                                           MPI_Datatype sendtype,
255                                           void *recvbuf, int recvcount,
256                                           MPI_Datatype recvtype,
257                                           MPI_Comm comm);
258 int smpi_coll_tuned_alltoall_pairwise(void *sendbuf, int sendcount,
259                                       MPI_Datatype sendtype, void *recvbuf,
260                                       int recvcount, MPI_Datatype recvtype,
261                                       MPI_Comm comm);
262 int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
263                               int *senddisps, MPI_Datatype sendtype,
264                               void *recvbuf, int *recvcounts,
265                               int *recvdisps, MPI_Datatype recvtype,
266                               MPI_Comm comm);
267
268 // utilities
269 void smpi_bench_destroy(void);
270 void smpi_bench_begin(void);
271 void smpi_bench_end(void);
272 void smpi_execute_flops(double flops);
273
274 // f77 wrappers
275 void mpi_init__(int*);
276 void mpi_finalize__(int*);
277 void mpi_abort__(int* comm, int* errorcode, int* ierr);
278 void mpi_comm_rank__(int* comm, int* rank, int* ierr);
279 void mpi_comm_size__(int* comm, int* size, int* ierr);
280 double mpi_wtime__(void);
281
282 void mpi_comm_dup__(int* comm, int* newcomm, int* ierr);
283 void mpi_comm_split__(int* comm, int* color, int* key, int* comm_out, int* ierr);
284
285 void mpi_send_init__(void *buf, int* count, int* datatype, int* dst, int* tag,
286                      int* comm, int* request, int* ierr);
287 void mpi_isend__(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_recv_init__(void *buf, int* count, int* datatype, int* src, int* tag,
292                      int* comm, int* request, int* ierr);
293 void mpi_irecv__(void *buf, int* count, int* datatype, int* src, int* tag,
294                  int* comm, int* request, int* ierr);
295 void mpi_recv__(void* buf, int* count, int* datatype, int* src,
296                 int* tag, int* comm, MPI_Status* status, int* ierr);
297 void mpi_start__(int* request, int* ierr);
298 void mpi_startall__(int* count, int* requests, int* ierr);
299 void mpi_wait__(int* request, MPI_Status* status, int* ierr);
300 void mpi_waitany__(int* count, int* requests, int* index, MPI_Status* status, int* ierr);
301 void mpi_waitall__(int* count, int* requests, MPI_Status* status, int* ierr);
302
303 void mpi_barrier__(int* comm, int* ierr);
304 void mpi_bcast__(void* buf, int* count, int* datatype, int* root, int* comm, int* ierr);
305 void mpi_reduce__(void* sendbuf, void* recvbuf, int* count,
306                   int* datatype, int* op, int* root, int* comm, int* ierr);
307 void mpi_allreduce__(void* sendbuf, void* recvbuf, int* count, int* datatype,
308                      int* op, int* comm, int* ierr);
309 void mpi_scatter__(void* sendbuf, int* sendcount, int* sendtype,
310                    void* recvbuf, int* recvcount, int* recvtype,
311                    int* root, int* comm, int* ierr);
312 void mpi_gather__(void* sendbuf, int* sendcount, int* sendtype,
313                   void* recvbuf, int* recvcount, int* recvtype,
314                   int* root, int* comm, int* ierr);
315 void mpi_allgather__(void* sendbuf, int* sendcount, int* sendtype,
316                      void* recvbuf, int* recvcount, int* recvtype,
317                      int* comm, int* ierr);
318 void mpi_scan__(void* sendbuf, void* recvbuf, int* count, int* datatype,
319                 int* op, int* comm, int* ierr);
320 void mpi_alltoall__(void* sendbuf, int* sendcount, int* sendtype,
321                     void* recvbuf, int* recvcount, int* recvtype, int* comm, int* ierr);
322
323 #endif