Debian Codegraph @

src/mpi/coll/ialltoall/ialltoall_tsp_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 === BEGIN_MPI_T_CVAR_INFO_BLOCK ===
9
10 cvars:
11 - name : MPIR_CVAR_IALLTOALL_SCATTERED_OUTSTANDING_TASKS
12 category : COLLECTIVE
13 type : int
14 default : 64
15 class : none
16 verbosity : MPI_T_VERBOSITY_USER_BASIC
17 scope : MPI_T_SCOPE_ALL_EQ
18 description : >-
19 Maximum number of outstanding sends and recvs posted at a time
20
21 - name : MPIR_CVAR_IALLTOALL_SCATTERED_BATCH_SIZE
22 category : COLLECTIVE
23 type : int
24 default : 4
25 class : none
26 verbosity : MPI_T_VERBOSITY_USER_BASIC
27 scope : MPI_T_SCOPE_ALL_EQ
28 description : >-
29 Number of send/receive tasks that scattered algorithm waits for
30 completion before posting another batch of send/receives of that size
31
32 === END_MPI_T_CVAR_INFO_BLOCK ===
33 */
34
35
36 /* Routine to schedule a scattered based alltoall */
37 int MPIR_TSP_Ialltoall_sched_intra_scatteredcxx . . $ MPIR_TSP_Ialltoall_sched_intra_scattered(a7e8e0149b3b4d80).(const void *sendbuf, MPI_Aintcxx . . $ MPI_Aint# sendcount,
38 MPI_Datatypecxx . . $ MPI_Datatype# sendtype, void *recvbuf,
39 MPI_Aintcxx . . $ MPI_Aint# recvcount, MPI_Datatypecxx . . $ MPI_Datatype# recvtype,
40 MPIR_Commcxx . . $ MPIR_Comm# * comm, int batch_size, int bblock,
41 MPIR_TSP_sched_tcxx . . $ MPIR_TSP_sched_t# sched)
42 {
43 int mpi_errno = MPI_SUCCESScxx . . $ `src/include/mpi.h:655:9`!;
44 int src, dst;
45 int i, j, ww;
46 int invtcs;
47 void *data_buf;
48 int *vtcs, *recv_id, *send_id;
49 MPI_Aintcxx . . $ MPI_Aint# recvtype_extent;
50 MPI_Aintcxx . . $ MPI_Aint# sendtype_extent;
51 MPI_Aintcxx . . $ MPI_Aint# recvtype_lb, sendtype_lb, sendtype_true_extent, recvtype_true_extent;
52 int size, rank, vtx_id;
53 int is_inplace;
54 int tag = 0;
55 MPIR_FUNC_ENTERcxx . . $ `src/include/mpir_func.h:57:9`!;
56
57 /* For correctness, transport based collectives need to get the
58 * tag from the same pool as schedule based collectives */
59 mpi_errno = MPIR_Sched_next_tagcxx . . $ `src/mpid/ch4/include/mpid_sched.h:12:9`!(comm, &tag);
60 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
61
62 MPIR_COMM_RANK_SIZEcxx . . $ `src/include/mpir_comm.h:412:9`!(comm, rank, size);
63 is_inplace = (sendbuf == MPI_IN_PLACEcxx . . $ `src/include/mpi.h:555:9`!);
64
65 /* vtcs is twice the batch size to store both send and recv ids */
66 vtcs = (int *) MPL_malloccxx . . $ MPL_malloc(47e2c277390bf45).(sizeof(int) * 2 * batch_size, MPL_MEM_COLLcxx . . $ MPL_MEM_COLL.);
67 recv_id = (int *) MPL_malloccxx . . $ MPL_malloc(47e2c277390bf45).(sizeof(int) * bblock, MPL_MEM_COLLcxx . . $ MPL_MEM_COLL.);
68 send_id = (int *) MPL_malloccxx . . $ MPL_malloc(47e2c277390bf45).(sizeof(int) * bblock, MPL_MEM_COLLcxx . . $ MPL_MEM_COLL.);
69 MPIR_Assertcxx . . $ `src/include/mpir_assert.h:39:9`!(vtcs);
70 MPIR_Assertcxx . . $ `src/include/mpir_assert.h:39:9`!(recv_id);
71 MPIR_Assertcxx . . $ `src/include/mpir_assert.h:39:9`!(send_id);
72
73 if (bblock > size)
74 bblock = size;
75
76 /* Get datatype info of sendtype and recvtype */
77 MPIR_Datatype_get_extent_macrocxx . . $ `src/include/mpir_datatype.h:462:9`!(recvtype, recvtype_extent);
78 MPIR_Type_get_true_extent_implcxx . . $ MPIR_Type_get_true_extent_impl(76a2ea8aac5bbe77).(recvtype, &recvtype_lb, &recvtype_true_extent);
79 recvtype_extent = MPL_MAXcxx . . $ `src/mpl/include/mpl_base.h:105:9`!(recvtype_extent, recvtype_true_extent);
80
81 if (!is_inplace) {
82 MPIR_Datatype_get_extent_macrocxx . . $ `src/include/mpir_datatype.h:462:9`!(sendtype, sendtype_extent);
83 MPIR_Type_get_true_extent_implcxx . . $ MPIR_Type_get_true_extent_impl(76a2ea8aac5bbe77).(sendtype, &sendtype_lb, &sendtype_true_extent);
84 sendtype_extent = MPL_MAXcxx . . $ `src/mpl/include/mpl_base.h:105:9`!(sendtype_extent, sendtype_true_extent);
85 } else {
86 sendcount = recvcount;
87 sendtype = recvtype;
88 sendtype_extent = recvtype_extent;
89 }
90
91 if (is_inplace) {
92 data_buf = (void *) MPIR_TSP_sched_malloccxx . . $ MPIR_TSP_sched_malloc(7cf5f2fc6057a0cc).(size * recvcount * recvtype_extent, sched);
93 MPIR_Assertcxx . . $ `src/include/mpir_assert.h:39:9`!(data_buf != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
94 mpi_errno =
95 MPIR_TSP_sched_localcopycxx . . $ MPIR_TSP_sched_localcopy(e23c285a5816c4b9).((char *) recvbuf, size * recvcount, recvtype,
96 (char *) data_buf, size * recvcount, recvtype, sched, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
97 &vtx_id);
98 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
99 mpi_errno = MPIR_TSP_sched_fencecxx . . $ MPIR_TSP_sched_fence(dedf1e9b1c614a07).(sched);
100 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
101 } else {
102 data_buf = (void *) sendbuf;
103 }
104
105 /* First, post bblock number of sends/recvs */
106 for (i = 0; i < bblock; i++) {
107 src = (rank + i) % size;
108 mpi_errno =
109 MPIR_TSP_sched_irecvcxx . . $ MPIR_TSP_sched_irecv(2270ed5ad98bfa2b).((char *) recvbuf + src * recvcount * recvtype_extent,
110 recvcount, recvtype, src, tag, comm, sched, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &recv_id[i]);
111 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
112
113 dst = (rank - i + size) % size;
114 mpi_errno =
115 MPIR_TSP_sched_isendcxx . . $ MPIR_TSP_sched_isend(29099b4ae230c868).((char *) data_buf + dst * sendcount * sendtype_extent,
116 sendcount, sendtype, dst, tag, comm, sched, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &send_id[i]);
117 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
118 }
119
120 /* Post more send/recv pairs as the previous ones finish */
121 for (i = bblock; i < size; i += batch_size) {
122 ww = MPL_MINcxx . . $ `src/mpl/include/mpl_base.h:106:9`!(size - i, batch_size);
123 int idx = 0; /* Store vtcs array from the start */
124 /* Get the send and recv ids from previous sends/recvs.
125 * ((i + j) % bblock) would ensure extracting and storing
126 * dependencies in order from '0, 1,...,bblock' */
127 for (j = 0; j < ww; j++) {
128 vtcs[idx++] = recv_id[(i + j) % bblock];
129 vtcs[idx++] = send_id[(i + j) % bblock];
130 }
131 mpi_errno = MPIR_TSP_sched_selective_sinkcxx . . $ MPIR_TSP_sched_selective_sink(1ea641a0622712dd).(sched, 2 * ww, vtcs, &invtcs);
132 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
133 for (j = 0; j < ww; j++) {
134 src = (rank + i + j) % size;
135 mpi_errno =
136 MPIR_TSP_sched_irecvcxx . . $ MPIR_TSP_sched_irecv(2270ed5ad98bfa2b).((char *) recvbuf + src * recvcount * recvtype_extent,
137 recvcount, recvtype, src, tag, comm, sched, 1, &invtcs,
138 &recv_id[(i + j) % bblock]);
139 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
140
141 dst = (rank - i - j + size) % size;
142 mpi_errno =
143 MPIR_TSP_sched_isendcxx . . $ MPIR_TSP_sched_isend(29099b4ae230c868).((char *) data_buf + dst * sendcount * sendtype_extent,
144 sendcount, sendtype, dst, tag, comm, sched, 1, &invtcs,
145 &send_id[(i + j) % bblock]);
146 MPIR_ERR_CHECKcxx . . $ `src/include/mpir_err.h:810:9`!(mpi_errno);
147 }
148 }
149
150 MPL_freecxx . . $ `src/mpl/include/mpl_trmem.h:308:9`!(vtcs);
151 MPL_freecxx . . $ `src/mpl/include/mpl_trmem.h:308:9`!(recv_id);
152 MPL_freecxx . . $ `src/mpl/include/mpl_trmem.h:308:9`!(send_id);
153
154 fn_exit:
155 MPIR_FUNC_EXITcxx . . $ `src/include/mpir_func.h:58:9`!;
156 return mpi_errno;
157
158 fn_fail:
159 goto fn_exit;
160 }