1 | |
---|
2 | #include "mpiP.h" |
---|
3 | |
---|
4 | |
---|
5 | |
---|
6 | /* |
---|
7 | * COLLECTIVE |
---|
8 | */ |
---|
9 | |
---|
10 | |
---|
11 | FC_FUNC( mpi_barrier , MPI_BARRIER )(int *comm, int *ierror) |
---|
12 | { |
---|
13 | *ierror=MPI_Barrier( *comm ); |
---|
14 | } |
---|
15 | |
---|
16 | |
---|
17 | int MPI_Barrier(MPI_Comm comm ) |
---|
18 | { |
---|
19 | return(MPI_SUCCESS); |
---|
20 | } |
---|
21 | |
---|
22 | |
---|
23 | /*********/ |
---|
24 | |
---|
25 | |
---|
26 | FC_FUNC( mpi_bcast , MPI_BCAST )(void *buffer, int *count, int *datatype, |
---|
27 | int *root, int *comm, int *ierror ) |
---|
28 | { |
---|
29 | *ierror=MPI_Bcast(buffer, *count, *datatype, *root, *comm); |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, |
---|
35 | int root, MPI_Comm comm ) |
---|
36 | { |
---|
37 | if (root==MPI_ROOT) |
---|
38 | return(MPI_SUCCESS); |
---|
39 | |
---|
40 | if (root!=0) |
---|
41 | { |
---|
42 | fprintf(stderr,"MPI_Bcast: bad root = %d\n",root); |
---|
43 | abort(); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | return(MPI_SUCCESS); |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | /*********/ |
---|
52 | |
---|
53 | |
---|
54 | FC_FUNC( mpi_gather , MPI_GATHER ) |
---|
55 | (void *sendbuf, int *sendcount, int *sendtype, |
---|
56 | void *recvbuf, int *recvcount, int *recvtype, |
---|
57 | int *root, int *comm, int *ierror) |
---|
58 | { |
---|
59 | *ierror=MPI_Gather( sendbuf, *sendcount, *sendtype, |
---|
60 | recvbuf, *recvcount, *recvtype, |
---|
61 | *root, *comm); |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
66 | void* recvbuf, int recvcount, MPI_Datatype recvtype, |
---|
67 | int root, MPI_Comm comm) |
---|
68 | { |
---|
69 | if (root==MPI_ROOT) |
---|
70 | return(MPI_SUCCESS); |
---|
71 | |
---|
72 | if (root!=0) |
---|
73 | { |
---|
74 | fprintf(stderr,"MPI_Gather: bad root = %d\n",root); |
---|
75 | abort(); |
---|
76 | } |
---|
77 | |
---|
78 | memcpy(recvbuf,sendbuf,sendcount*sendtype); |
---|
79 | |
---|
80 | return(MPI_SUCCESS); |
---|
81 | } |
---|
82 | |
---|
83 | /*********/ |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | FC_FUNC( mpi_gatherv , MPI_GATHERV ) |
---|
88 | ( void *sendbuf, int *sendcount, int *sendtype, |
---|
89 | void *recvbuf, int *recvcounts, int *displs, |
---|
90 | int *recvtype, int *root, int *comm, int *ierror) |
---|
91 | { |
---|
92 | *ierror=MPI_Gatherv( sendbuf, *sendcount, *sendtype, |
---|
93 | recvbuf, recvcounts, displs, |
---|
94 | *recvtype, *root, *comm); |
---|
95 | } |
---|
96 | |
---|
97 | |
---|
98 | int MPI_Gatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
99 | void* recvbuf, int *recvcounts, int *displs, |
---|
100 | MPI_Datatype recvtype, int root, MPI_Comm comm) |
---|
101 | { |
---|
102 | int offset; |
---|
103 | |
---|
104 | if (root==MPI_ROOT) |
---|
105 | return(MPI_SUCCESS); |
---|
106 | |
---|
107 | if (root!=0) |
---|
108 | { |
---|
109 | fprintf(stderr,"MPI_Gatherv: bad root = %d\n",root); |
---|
110 | abort(); |
---|
111 | } |
---|
112 | |
---|
113 | offset=displs[0]*recvtype; |
---|
114 | memcpy( (char *)recvbuf+offset, sendbuf, recvcounts[0] * recvtype); |
---|
115 | |
---|
116 | return(MPI_SUCCESS); |
---|
117 | } |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | /*********/ |
---|
122 | |
---|
123 | |
---|
124 | FC_FUNC( mpi_allgather , MPI_ALLGATHER ) |
---|
125 | ( void *sendbuf, int *sendcount, int *sendtype, |
---|
126 | void *recvbuf, int *recvcount, int *recvtype, |
---|
127 | int *comm, int *ierror) |
---|
128 | { |
---|
129 | *ierror=MPI_Allgather( sendbuf, *sendcount, *sendtype, |
---|
130 | recvbuf, *recvcount, *recvtype, |
---|
131 | *comm ); |
---|
132 | } |
---|
133 | |
---|
134 | |
---|
135 | int MPI_Allgather(void* sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
136 | void* recvbuf, int recvcount, MPI_Datatype recvtype, |
---|
137 | MPI_Comm comm) |
---|
138 | { |
---|
139 | |
---|
140 | memcpy(recvbuf,sendbuf,sendcount * sendtype); |
---|
141 | |
---|
142 | return(MPI_SUCCESS); |
---|
143 | |
---|
144 | } |
---|
145 | |
---|
146 | |
---|
147 | /*********/ |
---|
148 | |
---|
149 | |
---|
150 | FC_FUNC( mpi_allgatherv , MPI_ALLGATHERV ) |
---|
151 | ( void *sendbuf, int *sendcount, int *sendtype, |
---|
152 | void *recvbuf, int *recvcounts, int *displs, |
---|
153 | int *recvtype, int *comm, int *ierror) |
---|
154 | { |
---|
155 | *ierror=MPI_Allgatherv( sendbuf, *sendcount, *sendtype, |
---|
156 | recvbuf, recvcounts, displs, |
---|
157 | *recvtype, *comm ); |
---|
158 | } |
---|
159 | |
---|
160 | |
---|
161 | int MPI_Allgatherv(void* sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
162 | void* recvbuf, int *recvcounts, int *displs, |
---|
163 | MPI_Datatype recvtype, MPI_Comm comm) |
---|
164 | { |
---|
165 | int offset; |
---|
166 | |
---|
167 | offset=displs[0]*recvtype; |
---|
168 | memcpy( (char *)recvbuf+offset, sendbuf, recvcounts[0] * recvtype); |
---|
169 | |
---|
170 | return(MPI_SUCCESS); |
---|
171 | } |
---|
172 | |
---|
173 | |
---|
174 | /*********/ |
---|
175 | |
---|
176 | |
---|
177 | FC_FUNC( mpi_scatter , MPI_SCATTER ) |
---|
178 | ( void *sendbuf, int *sendcount, int *sendtype, |
---|
179 | void *recvbuf, int *recvcount, int *recvtype, |
---|
180 | int *root, int *comm, int *ierror) |
---|
181 | { |
---|
182 | *ierror=MPI_Scatter( sendbuf, *sendcount, *sendtype, |
---|
183 | recvbuf, *recvcount, *recvtype, |
---|
184 | *root, *comm); |
---|
185 | } |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | int MPI_Scatter( void* sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
190 | void* recvbuf, int recvcount, MPI_Datatype recvtype, |
---|
191 | int root, MPI_Comm comm) |
---|
192 | { |
---|
193 | if (root==MPI_ROOT) |
---|
194 | return(MPI_SUCCESS); |
---|
195 | |
---|
196 | if (root!=0) |
---|
197 | { |
---|
198 | fprintf(stderr,"MPI_Scatter: bad root = %d\n",root); |
---|
199 | abort(); |
---|
200 | } |
---|
201 | |
---|
202 | memcpy(recvbuf,sendbuf,sendcount * sendtype); |
---|
203 | |
---|
204 | return(MPI_SUCCESS); |
---|
205 | } |
---|
206 | |
---|
207 | |
---|
208 | |
---|
209 | /*********/ |
---|
210 | |
---|
211 | |
---|
212 | FC_FUNC( mpi_scatterv , MPI_SCATTERV ) |
---|
213 | ( void *sendbuf, int *sendcounts, int *displs, |
---|
214 | int *sendtype, void *recvbuf, int *recvcount, |
---|
215 | int *recvtype, int *root, int *comm, int *ierror) |
---|
216 | { |
---|
217 | *ierror=MPI_Scatterv(sendbuf, sendcounts, displs, |
---|
218 | *sendtype, recvbuf, *recvcount, |
---|
219 | *recvtype, *root, *comm); |
---|
220 | } |
---|
221 | |
---|
222 | |
---|
223 | |
---|
224 | int MPI_Scatterv(void* sendbuf, int *sendcounts, int *displs, |
---|
225 | MPI_Datatype sendtype, void* recvbuf, int recvcount, |
---|
226 | MPI_Datatype recvtype, int root, MPI_Comm comm) |
---|
227 | { |
---|
228 | int offset; |
---|
229 | |
---|
230 | if (root==MPI_ROOT) |
---|
231 | return(MPI_SUCCESS); |
---|
232 | |
---|
233 | if (root!=0) |
---|
234 | { |
---|
235 | fprintf(stderr,"MPI_Scatterv: bad root = %d\n",root); |
---|
236 | abort(); |
---|
237 | } |
---|
238 | |
---|
239 | offset=displs[0]*sendtype; |
---|
240 | memcpy(recvbuf,(char *)sendbuf+offset,sendcounts[0] * sendtype); |
---|
241 | |
---|
242 | return(MPI_SUCCESS); |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | |
---|
247 | /*********/ |
---|
248 | |
---|
249 | |
---|
250 | FC_FUNC( mpi_reduce , MPI_REDUCE ) |
---|
251 | ( void *sendbuf, void *recvbuf, int *count, |
---|
252 | int *datatype, int *op, int *root, int *comm, |
---|
253 | int *ierror) |
---|
254 | { |
---|
255 | *ierror=MPI_Reduce(sendbuf, recvbuf, *count, |
---|
256 | *datatype, *op, *root, *comm); |
---|
257 | } |
---|
258 | |
---|
259 | |
---|
260 | |
---|
261 | int MPI_Reduce(void* sendbuf, void* recvbuf, int count, |
---|
262 | MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) |
---|
263 | |
---|
264 | { |
---|
265 | if (root==MPI_ROOT) |
---|
266 | return(MPI_SUCCESS); |
---|
267 | |
---|
268 | if (root!=0) |
---|
269 | { |
---|
270 | fprintf(stderr,"MPI_Reduce: bad root = %d\n",root); |
---|
271 | abort(); |
---|
272 | } |
---|
273 | |
---|
274 | memcpy(recvbuf,sendbuf,count * datatype); |
---|
275 | |
---|
276 | return(MPI_SUCCESS); |
---|
277 | } |
---|
278 | |
---|
279 | |
---|
280 | /*********/ |
---|
281 | |
---|
282 | |
---|
283 | FC_FUNC( mpi_allreduce , MPI_ALLREDUCE ) |
---|
284 | ( void *sendbuf, void *recvbuf, int *count, |
---|
285 | int *datatype, int *op, int *comm, int *ierror) |
---|
286 | { |
---|
287 | *ierror=MPI_Allreduce(sendbuf, recvbuf, *count, |
---|
288 | *datatype, *op, *comm); |
---|
289 | |
---|
290 | } |
---|
291 | |
---|
292 | |
---|
293 | int MPI_Allreduce(void* sendbuf, void* recvbuf, int count, |
---|
294 | MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) |
---|
295 | { |
---|
296 | |
---|
297 | memcpy(recvbuf,sendbuf,count * datatype); |
---|
298 | |
---|
299 | return(MPI_SUCCESS); |
---|
300 | |
---|
301 | } |
---|
302 | |
---|
303 | |
---|
304 | /*********/ |
---|
305 | |
---|
306 | |
---|
307 | FC_FUNC( mpi_scan , MPI_SCAN ) |
---|
308 | ( void *sendbuf, void *recvbuf, int *count, |
---|
309 | int *datatype, int *op, int *comm, |
---|
310 | int *ierror) |
---|
311 | { |
---|
312 | *ierror=MPI_Scan( sendbuf, recvbuf, *count, |
---|
313 | *datatype, *op, *comm); |
---|
314 | } |
---|
315 | |
---|
316 | |
---|
317 | |
---|
318 | int MPI_Scan( void* sendbuf, void* recvbuf, int count, |
---|
319 | MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) |
---|
320 | |
---|
321 | { |
---|
322 | |
---|
323 | memcpy(recvbuf,sendbuf,count * datatype); |
---|
324 | |
---|
325 | return(MPI_SUCCESS); |
---|
326 | } |
---|
327 | |
---|
328 | |
---|
329 | /*********/ |
---|
330 | |
---|
331 | |
---|
332 | FC_FUNC( mpi_alltoall , MPI_ALLTOALL ) |
---|
333 | ( void *sendbuf, int *sendcount, int *sendtype, |
---|
334 | void *recvbuf, int *recvcount, int *recvtype, |
---|
335 | int *comm, int *ierror ) |
---|
336 | { |
---|
337 | *ierror=MPI_Alltoall(sendbuf, *sendcount, *sendtype, |
---|
338 | recvbuf, *recvcount, *recvtype, |
---|
339 | *comm); |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, |
---|
344 | void *recvbuf, int recvcount, MPI_Datatype recvtype, |
---|
345 | MPI_Comm comm) |
---|
346 | { |
---|
347 | |
---|
348 | memcpy(recvbuf,sendbuf,sendcount * sendtype); |
---|
349 | |
---|
350 | return(MPI_SUCCESS); |
---|
351 | } |
---|
352 | |
---|
353 | |
---|
354 | /*********/ |
---|
355 | |
---|
356 | |
---|
357 | FC_FUNC( mpi_alltoallv , MPI_ALLTOALLV ) |
---|
358 | ( void *sendbuf, int *sendcounts, int *sdispls, int *sendtype, |
---|
359 | void *recvbuf, int *recvcounts, int *rdispls, int *recvtype, |
---|
360 | int *comm, int *ierror ) |
---|
361 | { |
---|
362 | |
---|
363 | *ierror=MPI_Alltoallv(sendbuf, sendcounts, sdispls, *sendtype, |
---|
364 | recvbuf, recvcounts, rdispls, *recvtype, |
---|
365 | *comm); |
---|
366 | |
---|
367 | } |
---|
368 | |
---|
369 | int MPI_Alltoallv(void *sendbuf, int *sendcounts, |
---|
370 | int *sdispls, MPI_Datatype sendtype, |
---|
371 | void *recvbuf, int *recvcounts, |
---|
372 | int *rdispls, MPI_Datatype recvtype, |
---|
373 | MPI_Comm comm) |
---|
374 | |
---|
375 | { |
---|
376 | int send_offset; |
---|
377 | int recv_offset; |
---|
378 | |
---|
379 | send_offset=sdispls[0]*sendtype; |
---|
380 | recv_offset=rdispls[0]*recvtype; |
---|
381 | |
---|
382 | |
---|
383 | memcpy( (char *)recvbuf+recv_offset, (char *)sendbuf+send_offset, |
---|
384 | sendcounts[0] * sendtype); |
---|
385 | |
---|
386 | |
---|
387 | return(MPI_SUCCESS); |
---|
388 | } |
---|
389 | |
---|
390 | |
---|
391 | /*********/ |
---|
392 | |
---|
393 | |
---|
394 | FC_FUNC( mpi_op_create , MPI_OP_CREATE ) |
---|
395 | ( void *function, int *commute, int *op, int *ierror ) |
---|
396 | { |
---|
397 | *ierror=MPI_Op_create(function,*commute,op); |
---|
398 | } |
---|
399 | |
---|
400 | |
---|
401 | |
---|
402 | int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op) |
---|
403 | { |
---|
404 | *op=MPI_OP_NULL; |
---|
405 | |
---|
406 | return(MPI_SUCCESS); |
---|
407 | |
---|
408 | } |
---|
409 | |
---|
410 | |
---|
411 | |
---|
412 | |
---|
413 | /*********/ |
---|
414 | |
---|
415 | MPI_Op MPI_Op_f2c(MPI_Fint op) |
---|
416 | { |
---|
417 | return(op); |
---|
418 | } |
---|
419 | |
---|
420 | |
---|
421 | /*********/ |
---|
422 | |
---|
423 | |
---|
424 | MPI_Fint MPI_Op_c2f(MPI_Op op) |
---|
425 | { |
---|
426 | return(op); |
---|
427 | } |
---|
428 | |
---|