Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
generalize non contiguous send method to other MPI types (hvector, indexed, hindexed...
[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 // 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 } s_smpi_subtype_t;
34
35 typedef struct s_smpi_mpi_datatype{
36   size_t size;
37   /* this let us know if a serialization is required*/
38   size_t has_subtype;
39   MPI_Aint lb;
40   MPI_Aint ub;
41   int flags;
42   /* this let us know how to serialize and unserialize*/
43   void *substruct;
44 } s_smpi_mpi_datatype_t;
45
46 //*****************************************************************************************
47
48 typedef struct s_smpi_mpi_request {
49   void *buf;
50   /* in the case of non-contignous memory the user address shoud be keep
51    * to unserialize the data inside the user memory*/
52   void *old_buf;
53   /* this let us know how tounserialize at the end of
54    * the communication*/
55   MPI_Datatype old_type;
56   size_t size;
57   int src;
58   int dst;
59   int tag;
60   MPI_Comm comm;
61   smx_action_t action;
62   unsigned flags;
63 #ifdef HAVE_TRACING
64   int send;
65   int recv;
66 #endif
67 } s_smpi_mpi_request_t;
68
69 void smpi_process_init(int *argc, char ***argv);
70 void smpi_process_destroy(void);
71 void smpi_process_finalize(void);
72
73 smpi_process_data_t smpi_process_data(void);
74 smpi_process_data_t smpi_process_remote_data(int index);
75 void smpi_process_set_user_data(void *);
76 void* smpi_process_get_user_data(void);
77 int smpi_process_count(void);
78 smx_rdv_t smpi_process_mailbox(void);
79 smx_rdv_t smpi_process_remote_mailbox(int index);
80 smx_rdv_t smpi_process_mailbox_small(void);
81 smx_rdv_t smpi_process_remote_mailbox_small(int index);
82 xbt_os_timer_t smpi_process_timer(void);
83 void smpi_process_simulated_start(void);
84 double smpi_process_simulated_elapsed(void);
85
86 void print_request(const char *message, MPI_Request request);
87
88 void smpi_global_init(void);
89 void smpi_global_destroy(void);
90
91 size_t smpi_datatype_size(MPI_Datatype datatype);
92 MPI_Aint smpi_datatype_lb(MPI_Datatype datatype);
93 MPI_Aint smpi_datatype_ub(MPI_Datatype datatype);
94 int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
95                          MPI_Aint * extent);
96 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
97                        void *recvbuf, int recvcount,
98                        MPI_Datatype recvtype);
99 int smpi_datatype_contiguous(int count, MPI_Datatype old_type,
100                        MPI_Datatype* new_type);
101 int smpi_datatype_vector(int count, int blocklen, int stride,
102                       MPI_Datatype old_type, MPI_Datatype* new_type);
103
104 int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride,
105                       MPI_Datatype old_type, MPI_Datatype* new_type);
106 int smpi_datatype_indexed(int count, int* blocklens, int* indices,
107                      MPI_Datatype old_type, MPI_Datatype* new_type);
108 int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices,
109                      MPI_Datatype old_type, MPI_Datatype* new_type);
110 int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices,
111                     MPI_Datatype* old_types, MPI_Datatype* new_type);
112
113 void smpi_datatype_create(MPI_Datatype* new_type, int size, int has_subtype, void *struct_type, int flags);
114
115
116 void smpi_datatype_free(MPI_Datatype* type);
117 void smpi_datatype_commit(MPI_Datatype* datatype);
118
119 void smpi_empty_status(MPI_Status * status);
120 MPI_Op smpi_op_new(MPI_User_function * function, int commute);
121 void smpi_op_destroy(MPI_Op op);
122 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
123                    MPI_Datatype * datatype);
124
125 MPI_Group smpi_group_new(int size);
126 void smpi_group_destroy(MPI_Group group);
127 void smpi_group_set_mapping(MPI_Group group, int index, int rank);
128 int smpi_group_index(MPI_Group group, int rank);
129 int smpi_group_rank(MPI_Group group, int index);
130 int smpi_group_use(MPI_Group group);
131 int smpi_group_unuse(MPI_Group group);
132 int smpi_group_size(MPI_Group group);
133 int smpi_group_compare(MPI_Group group1, MPI_Group group2);
134
135 MPI_Comm smpi_comm_new(MPI_Group group);
136 void smpi_comm_destroy(MPI_Comm comm);
137 MPI_Group smpi_comm_group(MPI_Comm comm);
138 int smpi_comm_size(MPI_Comm comm);
139 void smpi_comm_get_name(MPI_Comm comm, char* name, int* len);
140 int smpi_comm_rank(MPI_Comm comm);
141 MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key);
142
143 MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype,
144                                int dst, int tag, MPI_Comm comm);
145 MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype,
146                                int src, int tag, MPI_Comm comm);
147 void smpi_mpi_start(MPI_Request request);
148 void smpi_mpi_startall(int count, MPI_Request * requests);
149 void smpi_mpi_request_free(MPI_Request * request);
150 MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype,
151                             int dst, int tag, MPI_Comm comm);
152 MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype,
153                            int dst, int tag, MPI_Comm comm);
154 MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype,
155                             int src, int tag, MPI_Comm comm);
156 MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype,
157                            int src, int tag, MPI_Comm comm);
158 void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src,
159                    int tag, MPI_Comm comm, MPI_Status * status);
160 void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst,
161                    int tag, MPI_Comm comm);
162 void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
163                        int dst, int sendtag, void *recvbuf, int recvcount,
164                        MPI_Datatype recvtype, int src, int recvtag,
165                        MPI_Comm comm, MPI_Status * status);
166 int smpi_mpi_test(MPI_Request * request, MPI_Status * status);
167 int smpi_mpi_testany(int count, MPI_Request requests[], int *index,
168                      MPI_Status * status);
169 int smpi_mpi_testall(int count, MPI_Request requests[],
170                      MPI_Status status[]);
171 void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status);
172 void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag,
173                     MPI_Status* status);
174 int smpi_mpi_get_count(MPI_Status * status, MPI_Datatype datatype);
175 void smpi_mpi_wait(MPI_Request * request, MPI_Status * status);
176 int smpi_mpi_waitany(int count, MPI_Request requests[],
177                      MPI_Status * status);
178 void smpi_mpi_waitall(int count, MPI_Request requests[],
179                       MPI_Status status[]);
180 int smpi_mpi_waitsome(int incount, MPI_Request requests[], int *indices,
181                       MPI_Status status[]);
182 int smpi_mpi_testsome(int incount, MPI_Request requests[], int *indices,
183                       MPI_Status status[]);
184 void smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root,
185                     MPI_Comm comm);
186 void smpi_mpi_barrier(MPI_Comm comm);
187 void smpi_mpi_gather(void *sendbuf, int sendcount, MPI_Datatype sendtype,
188                      void *recvbuf, int recvcount, MPI_Datatype recvtype,
189                      int root, MPI_Comm comm);
190 void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
191                       void *recvbuf, int *recvcounts, int *displs,
192                       MPI_Datatype recvtype, int root, MPI_Comm comm);
193 void smpi_mpi_allgather(void *sendbuf, int sendcount,
194                         MPI_Datatype sendtype, void *recvbuf,
195                         int recvcount, MPI_Datatype recvtype,
196                         MPI_Comm comm);
197 void smpi_mpi_allgatherv(void *sendbuf, int sendcount,
198                          MPI_Datatype sendtype, void *recvbuf,
199                          int *recvcounts, int *displs,
200                          MPI_Datatype recvtype, MPI_Comm comm);
201 void smpi_mpi_scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype,
202                       void *recvbuf, int recvcount, MPI_Datatype recvtype,
203                       int root, MPI_Comm comm);
204 void smpi_mpi_scatterv(void *sendbuf, int *sendcounts, int *displs,
205                        MPI_Datatype sendtype, void *recvbuf, int recvcount,
206                        MPI_Datatype recvtype, int root, MPI_Comm comm);
207 void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count,
208                      MPI_Datatype datatype, MPI_Op op, int root,
209                      MPI_Comm comm);
210 void smpi_mpi_allreduce(void *sendbuf, void *recvbuf, int count,
211                         MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
212 void smpi_mpi_scan(void *sendbuf, void *recvbuf, int count,
213                    MPI_Datatype datatype, MPI_Op op, MPI_Comm comm);
214
215 void nary_tree_bcast(void *buf, int count, MPI_Datatype datatype, int root,
216                      MPI_Comm comm, int arity);
217 void nary_tree_barrier(MPI_Comm comm, int arity);
218
219 int smpi_coll_tuned_alltoall_bruck(void *sendbuf, int sendcount,
220                                    MPI_Datatype sendtype, void *recvbuf,
221                                    int recvcount, MPI_Datatype recvtype,
222                                    MPI_Comm comm);
223 int smpi_coll_tuned_alltoall_basic_linear(void *sendbuf, int sendcount,
224                                           MPI_Datatype sendtype,
225                                           void *recvbuf, int recvcount,
226                                           MPI_Datatype recvtype,
227                                           MPI_Comm comm);
228 int smpi_coll_tuned_alltoall_pairwise(void *sendbuf, int sendcount,
229                                       MPI_Datatype sendtype, void *recvbuf,
230                                       int recvcount, MPI_Datatype recvtype,
231                                       MPI_Comm comm);
232 int smpi_coll_basic_alltoallv(void *sendbuf, int *sendcounts,
233                               int *senddisps, MPI_Datatype sendtype,
234                               void *recvbuf, int *recvcounts,
235                               int *recvdisps, MPI_Datatype recvtype,
236                               MPI_Comm comm);
237
238 // utilities
239 void smpi_bench_destroy(void);
240 void smpi_bench_begin(void);
241 void smpi_bench_end(void);
242 void smpi_execute_flops(double flops);
243
244 // f77 wrappers
245 void mpi_init__(int*);
246 void mpi_finalize__(int*);
247 void mpi_abort__(int* comm, int* errorcode, int* ierr);
248 void mpi_comm_rank__(int* comm, int* rank, int* ierr);
249 void mpi_comm_size__(int* comm, int* size, int* ierr);
250 double mpi_wtime__(void);
251
252 void mpi_comm_dup__(int* comm, int* newcomm, int* ierr);
253 void mpi_comm_split__(int* comm, int* color, int* key, int* comm_out, int* ierr);
254
255 void mpi_send_init__(void *buf, int* count, int* datatype, int* dst, int* tag,
256                      int* comm, int* request, int* ierr);
257 void mpi_isend__(void *buf, int* count, int* datatype, int* dst,
258                  int* tag, int* comm, int* request, int* ierr);
259 void mpi_send__(void* buf, int* count, int* datatype, int* dst,
260                 int* tag, int* comm, int* ierr);
261 void mpi_recv_init__(void *buf, int* count, int* datatype, int* src, int* tag,
262                      int* comm, int* request, int* ierr);
263 void mpi_irecv__(void *buf, int* count, int* datatype, int* src, int* tag,
264                  int* comm, int* request, int* ierr);
265 void mpi_recv__(void* buf, int* count, int* datatype, int* src,
266                 int* tag, int* comm, MPI_Status* status, int* ierr);
267 void mpi_start__(int* request, int* ierr);
268 void mpi_startall__(int* count, int* requests, int* ierr);
269 void mpi_wait__(int* request, MPI_Status* status, int* ierr);
270 void mpi_waitany__(int* count, int* requests, int* index, MPI_Status* status, int* ierr);
271 void mpi_waitall__(int* count, int* requests, MPI_Status* status, int* ierr);
272
273 void mpi_barrier__(int* comm, int* ierr);
274 void mpi_bcast__(void* buf, int* count, int* datatype, int* root, int* comm, int* ierr);
275 void mpi_reduce__(void* sendbuf, void* recvbuf, int* count,
276                   int* datatype, int* op, int* root, int* comm, int* ierr);
277 void mpi_allreduce__(void* sendbuf, void* recvbuf, int* count, int* datatype,
278                      int* op, int* comm, int* ierr);
279 void mpi_scatter__(void* sendbuf, int* sendcount, int* sendtype,
280                    void* recvbuf, int* recvcount, int* recvtype,
281                    int* root, int* comm, int* ierr);
282 void mpi_gather__(void* sendbuf, int* sendcount, int* sendtype,
283                   void* recvbuf, int* recvcount, int* recvtype,
284                   int* root, int* comm, int* ierr);
285 void mpi_allgather__(void* sendbuf, int* sendcount, int* sendtype,
286                      void* recvbuf, int* recvcount, int* recvtype,
287                      int* comm, int* ierr);
288 void mpi_scan__(void* sendbuf, void* recvbuf, int* count, int* datatype,
289                 int* op, int* comm, int* ierr);
290 void mpi_alltoall__(void* sendbuf, int* sendcount, int* sendtype,
291                     void* recvbuf, int* recvcount, int* recvtype, int* comm, int* ierr);
292
293 #endif