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