This source file includes following definitions.
- nbc_scatterv_init
- ompi_coll_libnbc_iscatterv
- nbc_scatterv_inter_init
- ompi_coll_libnbc_iscatterv_inter
- ompi_coll_libnbc_scatterv_init
- ompi_coll_libnbc_scatterv_inter_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "nbc_internal.h"
25
26
27
28
29
30
31 static int nbc_scatterv_init(const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
32 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
33 struct ompi_communicator_t *comm, ompi_request_t ** request,
34 struct mca_coll_base_module_2_3_0_t *module, bool persistent) {
35 int rank, p, res;
36 MPI_Aint sndext;
37 NBC_Schedule *schedule;
38 char *sbuf, inplace = 0;
39 ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
40
41 rank = ompi_comm_rank (comm);
42 if (root == rank) {
43 NBC_IN_PLACE(sendbuf, recvbuf, inplace);
44 }
45
46 p = ompi_comm_size (comm);
47
48 schedule = OBJ_NEW(NBC_Schedule);
49 if (OPAL_UNLIKELY(NULL == schedule)) {
50 return OMPI_ERR_OUT_OF_RESOURCE;
51 }
52
53
54 if (rank == root) {
55 res = ompi_datatype_type_extent (sendtype, &sndext);
56 if (MPI_SUCCESS != res) {
57 NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
58 OBJ_RELEASE(schedule);
59 return res;
60 }
61
62 for (int i = 0 ; i < p ; ++i) {
63 sbuf = (char *) sendbuf + displs[i] * sndext;
64 if (i == root) {
65 if (!inplace) {
66
67 res = NBC_Sched_copy (sbuf, false, sendcounts[i], sendtype,
68 recvbuf, false, recvcount, recvtype, schedule, false);
69 } else {
70 res = OMPI_SUCCESS;
71 }
72 } else {
73
74 res = NBC_Sched_send (sbuf, false, sendcounts[i], sendtype, i, schedule, false);
75 }
76
77 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
78 OBJ_RELEASE(schedule);
79 return res;
80 }
81 }
82 } else {
83
84 res = NBC_Sched_recv (recvbuf, false, recvcount, recvtype, root, schedule, false);
85 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
86 OBJ_RELEASE(schedule);
87 return res;
88 }
89 }
90
91 res = NBC_Sched_commit (schedule);
92 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
93 OBJ_RELEASE(schedule);
94 return res;
95 }
96
97 res = NBC_Schedule_request(schedule, comm, libnbc_module, persistent, request, NULL);
98 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
99 OBJ_RELEASE(schedule);
100 return res;
101 }
102
103 return OMPI_SUCCESS;
104 }
105
106 int ompi_coll_libnbc_iscatterv(const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
107 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
108 struct ompi_communicator_t *comm, ompi_request_t ** request,
109 struct mca_coll_base_module_2_3_0_t *module) {
110 int res = nbc_scatterv_init(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root,
111 comm, request, module, false);
112 if (OPAL_LIKELY(OMPI_SUCCESS != res)) {
113 return res;
114 }
115 res = NBC_Start(*(ompi_coll_libnbc_request_t **)request);
116 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
117 NBC_Return_handle (*(ompi_coll_libnbc_request_t **)request);
118 *request = &ompi_request_null.request;
119 return res;
120 }
121
122 return OMPI_SUCCESS;
123 }
124
125 static int nbc_scatterv_inter_init (const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
126 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
127 struct ompi_communicator_t *comm, ompi_request_t ** request,
128 struct mca_coll_base_module_2_3_0_t *module, bool persistent) {
129 int res, rsize;
130 MPI_Aint sndext;
131 NBC_Schedule *schedule;
132 char *sbuf;
133 ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
134
135 rsize = ompi_comm_remote_size (comm);
136
137 schedule = OBJ_NEW(NBC_Schedule);
138 if (OPAL_UNLIKELY(NULL == schedule)) {
139 return OMPI_ERR_OUT_OF_RESOURCE;
140 }
141
142
143 if (MPI_ROOT != root && MPI_PROC_NULL != root) {
144
145 res = NBC_Sched_recv(recvbuf, false, recvcount, recvtype, root, schedule, false);
146 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
147 OBJ_RELEASE(schedule);
148 return res;
149 }
150 } else if (MPI_ROOT == root) {
151 res = ompi_datatype_type_extent(sendtype, &sndext);
152 if (MPI_SUCCESS != res) {
153 NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
154 OBJ_RELEASE(schedule);
155 return res;
156 }
157
158 for (int i = 0 ; i < rsize ; ++i) {
159 sbuf = (char *)sendbuf + displs[i] * sndext;
160
161 res = NBC_Sched_send (sbuf, false, sendcounts[i], sendtype, i, schedule, false);
162 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
163 OBJ_RELEASE(schedule);
164 return res;
165 }
166 }
167 }
168
169 res = NBC_Sched_commit(schedule);
170 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
171 OBJ_RELEASE(schedule);
172 return res;
173 }
174
175 res = NBC_Schedule_request(schedule, comm, libnbc_module, persistent, request, NULL);
176 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
177 OBJ_RELEASE(schedule);
178 return res;
179 }
180
181 return OMPI_SUCCESS;
182 }
183
184 int ompi_coll_libnbc_iscatterv_inter(const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
185 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
186 struct ompi_communicator_t *comm, ompi_request_t ** request,
187 struct mca_coll_base_module_2_3_0_t *module) {
188 int res = nbc_scatterv_inter_init(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root,
189 comm, request, module, false);
190 if (OPAL_LIKELY(OMPI_SUCCESS != res)) {
191 return res;
192 }
193 res = NBC_Start(*(ompi_coll_libnbc_request_t **)request);
194 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
195 NBC_Return_handle (*(ompi_coll_libnbc_request_t **)request);
196 *request = &ompi_request_null.request;
197 return res;
198 }
199
200 return OMPI_SUCCESS;
201 }
202
203 int ompi_coll_libnbc_scatterv_init(const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
204 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
205 struct ompi_communicator_t *comm, MPI_Info info, ompi_request_t ** request,
206 struct mca_coll_base_module_2_3_0_t *module) {
207 int res = nbc_scatterv_init(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root,
208 comm, request, module, true);
209 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
210 return res;
211 }
212
213 return OMPI_SUCCESS;
214 }
215
216 int ompi_coll_libnbc_scatterv_inter_init(const void* sendbuf, const int *sendcounts, const int *displs, MPI_Datatype sendtype,
217 void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,
218 struct ompi_communicator_t *comm, MPI_Info info, ompi_request_t ** request,
219 struct mca_coll_base_module_2_3_0_t *module) {
220 int res = nbc_scatterv_inter_init(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root,
221 comm, request, module, true);
222 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
223 return res;
224 }
225
226 return OMPI_SUCCESS;
227 }