Logo AND Algorithmique Numérique Distribuée

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