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