Debian Codegraph @

src/mpi/coll/alltoallv/alltoallv_intra_scattered.c

raw symbols SCIP
1 /*
2 * Copyright (C) by Argonne National Laboratory
3 * See COPYRIGHT in top-level directory
4 */
5
6 #include "mpiimpl.h"cxx . . $ `<file>/src/include/mpiimpl.h`/
7
8 /* Algorithm: MPI_Alltoallv
9 *
10 * Since each process sends/receives different amounts of data to
11 * every other process, we don't know the total message size for all
12 * processes without additional communication. Therefore we simply use
13 * the "middle of the road" isend/irecv algorithm that works
14 * reasonably well in all cases.
15 *
16 * We post all irecvs and isends and then do a waitall. We scatter the
17 * order of sources and destinations among the processes, so that all
18 * processes don't try to send/recv to/from the same process at the
19 * same time.
20 *
21 * *** Modification: We post only a small number of isends and irecvs
22 * at a time and wait on them as suggested by Tony Ladd. ***
23 */
24 int MPIR_Alltoallv_intra_scatteredcxx . . $ MPIR_Alltoallv_intra_scattered(50153ee6b41e1e94).(const void *sendbuf, const MPI_Aintcxx . . $ MPI_Aint# * sendcounts,
25 const MPI_Aintcxx . . $ MPI_Aint# * sdispls, MPI_Datatypecxx . . $ MPI_Datatype# sendtype, void *recvbuf,
26 const MPI_Aintcxx . . $ MPI_Aint# * recvcounts, const MPI_Aintcxx . . $ MPI_Aint# * rdispls,
27 MPI_Datatypecxx . . $ MPI_Datatype# recvtype, MPIR_Commcxx . . $ MPIR_Comm# * comm_ptr, int coll_attr)
28 {
29 int comm_size, i;
30 MPI_Aintcxx . . $ MPI_Aint# send_extent, recv_extent;
31 int mpi_errno = MPI_SUCCESScxx . . $ `src/include/mpi.h:655:9`!;
32 MPI_Statuscxx . . $ MPI_Status# *starray;
33 MPIR_Requestcxx . . $ MPIR_Request# **reqarray;
34 int dst, rank, req_cnt;
35 int ii, ss, bblock;
36
37 MPIR_CHKLMEM_DECLcxx . . $ `src/include/mpir_mem.h:108:9`!();
38
39 MPIR_COMM_RANK_SIZEcxx . . $ `src/include/mpir_comm.h:412:9`!(comm_ptr, rank, comm_size);
40
41 /* Get extent of recv type, but send type is only valid if (sendbuf!=MPI_IN_PLACE) */
42 MPIR_Datatype_get_extent_macrocxx . . $ `src/include/mpir_datatype.h:462:9`!(recvtype, recv_extent);
43
44 #ifdef HAVE_ERROR_CHECKINGcxx . . $ `src/include/mpichconf.h:269:9`!
45 MPIR_Assertcxx . . $ `src/include/mpir_assert.h:39:9`!(sendbuf != MPI_IN_PLACEcxx . . $ `src/include/mpi.h:555:9`!); /* call the pairwise_sendrecv_algo */
46 #endif
47
48 bblock = MPIR_CVAR_ALLTOALL_THROTTLEcxx . . $ MPIR_CVAR_ALLTOALL_THROTTLE.;
49 if (bblock == 0)
50 bblock = comm_size;
51
52 MPIR_Datatype_get_extent_macrocxx . . $ `src/include/mpir_datatype.h:462:9`!(sendtype, send_extent);
53
54 MPIR_CHKLMEM_MALLOCcxx . . $ `src/include/mpir_mem.h:118:9`!(starray, 2 * bblock * sizeof(MPI_Status));
55 MPIR_CHKLMEM_MALLOCcxx . . $ `src/include/mpir_mem.h:118:9`!(reqarray, 2 * bblock * sizeof(MPIR_Request *));
56
57 /* post only bblock isends/irecvs at a time as suggested by Tony Ladd */
58 for (ii = 0; ii < comm_size; ii += bblock) {
59 req_cnt = 0;
60 ss = comm_size - ii < bblock ? comm_size - ii : bblock;
61
62 /* do the communication -- post ss sends and receives: */
63 for (i = 0; i < ss; i++) {
64 dst = (rank + i + ii) % comm_size;
65 if (recvcounts[dst]) {
66 MPI_Aintcxx . . $ MPI_Aint# type_size;
67 MPIR_Datatype_get_size_macrocxx . . $ `src/include/mpir_datatype.h:437:9`!(recvtype, type_size);
68 if (type_size) {
69 mpi_errno = MPIC_Irecvcxx . . $ MPIC_Irecv(d5a3955da26b940f).((char *) recvbuf + rdispls[dst] * recv_extent,
70 recvcounts[dst], recvtype, dst,
71 MPIR_ALLTOALLV_TAGcxx . . $ `src/include/mpir_tags.h:20:9`!, comm_ptr, &reqarray[req_cnt]);
72 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
73 req_cnt++;
74 }
75 }
76 }
77
78 for (i = 0; i < ss; i++) {
79 dst = (rank - i - ii + comm_size) % comm_size;
80 if (sendcounts[dst]) {
81 MPI_Aintcxx . . $ MPI_Aint# type_size;
82 MPIR_Datatype_get_size_macrocxx . . $ `src/include/mpir_datatype.h:437:9`!(sendtype, type_size);
83 if (type_size) {
84 mpi_errno = MPIC_Isendcxx . . $ MPIC_Isend(92f04c3ea3bbad99).((char *) sendbuf + sdispls[dst] * send_extent,
85 sendcounts[dst], sendtype, dst,
86 MPIR_ALLTOALLV_TAGcxx . . $ `src/include/mpir_tags.h:20:9`!, comm_ptr,
87 &reqarray[req_cnt], coll_attr);
88 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
89 req_cnt++;
90 }
91 }
92 }
93
94 mpi_errno = MPIC_Waitallcxx . . $ MPIC_Waitall(96058919363a54c1).(req_cnt, reqarray, starray);
95 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
96
97 /* --BEGIN ERROR HANDLING-- */
98 if (mpi_errno == MPI_ERR_IN_STATUScxx . . $ `src/include/mpi.h:685:9`!) {
99 for (i = 0; i < req_cnt; i++) {
100 if (starray[i].MPI_ERRORcxx . . $ MPI_Status#MPI_ERROR. != MPI_SUCCESScxx . . $ `src/include/mpi.h:655:9`!) {
101 mpi_errno = starray[i].MPI_ERRORcxx . . $ MPI_Status#MPI_ERROR.;
102 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
103 }
104 }
105 }
106 /* --END ERROR HANDLING-- */
107 }
108
109 fn_exit:
110 MPIR_CHKLMEM_FREEALLcxx . . $ `src/include/mpir_mem.h:129:9`!();
111 return mpi_errno;
112 fn_fail:
113 goto fn_exit;
114 }