|
2 | 2 | * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
3 | 3 | * University Research and Technology
|
4 | 4 | * Corporation. All rights reserved.
|
5 |
| - * Copyright (c) 2004-2021 The University of Tennessee and The University |
| 5 | + * Copyright (c) 2004-2022 The University of Tennessee and The University |
6 | 6 | * of Tennessee Research Foundation. All rights
|
7 | 7 | * reserved.
|
8 | 8 | * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
@@ -244,25 +244,21 @@ int ompi_coll_base_retain_datatypes( ompi_request_t *req, ompi_datatype_t *stype
|
244 | 244 | return OMPI_SUCCESS;
|
245 | 245 | }
|
246 | 246 |
|
247 |
| -static void release_vecs_callback(ompi_coll_base_nbc_request_t *request) { |
248 |
| - ompi_communicator_t *comm = request->super.req_mpi_object.comm; |
249 |
| - int scount, rcount; |
250 |
| - if (OMPI_COMM_IS_TOPO(comm)) { |
251 |
| - (void)mca_topo_base_neighbor_count (comm, &rcount, &scount); |
252 |
| - } else { |
253 |
| - scount = rcount = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm); |
254 |
| - } |
| 247 | +static void release_vecs_callback(ompi_coll_base_nbc_request_t *request) |
| 248 | +{ |
255 | 249 | if (NULL != request->data.refcounted.vecs.stypes) {
|
256 |
| - for (int i=0; i<scount; i++) { |
257 |
| - if (NULL != request->data.refcounted.vecs.stypes[i]) { |
| 250 | + for (int i = 0; i < request->data.refcounted.vecs.scount; i++) { |
| 251 | + if (NULL != request->data.refcounted.vecs.stypes[i] && |
| 252 | + !ompi_datatype_is_predefined(request->data.refcounted.vecs.stypes[i])) { |
258 | 253 | OMPI_DATATYPE_RELEASE_NO_NULLIFY(request->data.refcounted.vecs.stypes[i]);
|
259 | 254 | }
|
260 | 255 | }
|
261 | 256 | request->data.refcounted.vecs.stypes = NULL;
|
262 | 257 | }
|
263 | 258 | if (NULL != request->data.refcounted.vecs.rtypes) {
|
264 |
| - for (int i=0; i<rcount; i++) { |
265 |
| - if (NULL != request->data.refcounted.vecs.rtypes[i]) { |
| 259 | + for (int i = 0; i < request->data.refcounted.vecs.rcount; i++) { |
| 260 | + if (NULL != request->data.refcounted.vecs.rtypes[i] && |
| 261 | + !ompi_datatype_is_predefined(request->data.refcounted.vecs.rtypes[i])) { |
266 | 262 | OMPI_DATATYPE_RELEASE_NO_NULLIFY(request->data.refcounted.vecs.rtypes[i]);
|
267 | 263 | }
|
268 | 264 | }
|
@@ -292,35 +288,47 @@ static int free_vecs_callback(struct ompi_request_t **rptr) {
|
292 | 288 | }
|
293 | 289 |
|
294 | 290 | int ompi_coll_base_retain_datatypes_w( ompi_request_t *req,
|
295 |
| - ompi_datatype_t * const stypes[], ompi_datatype_t * const rtypes[]) { |
| 291 | + ompi_datatype_t * const stypes[], |
| 292 | + ompi_datatype_t * const rtypes[], |
| 293 | + bool use_topo) |
| 294 | +{ |
296 | 295 | ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
|
297 |
| - bool retain = false; |
298 | 296 | ompi_communicator_t *comm = request->super.req_mpi_object.comm;
|
299 | 297 | int scount, rcount;
|
| 298 | + |
300 | 299 | if (REQUEST_COMPLETE(req)) {
|
301 | 300 | return OMPI_SUCCESS;
|
302 | 301 | }
|
303 |
| - if (OMPI_COMM_IS_TOPO(comm)) { |
| 302 | + |
| 303 | + if (use_topo && OMPI_COMM_IS_TOPO(comm)) { |
304 | 304 | (void)mca_topo_base_neighbor_count (comm, &rcount, &scount);
|
305 | 305 | } else {
|
306 | 306 | scount = rcount = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
|
307 | 307 | }
|
308 | 308 |
|
309 |
| - for (int i=0; i<scount; i++) { |
310 |
| - if (NULL != stypes && NULL != stypes[i] && !ompi_datatype_is_predefined(stypes[i])) { |
311 |
| - OBJ_RETAIN(stypes[i]); |
312 |
| - retain = true; |
| 309 | + request->data.refcounted.vecs.scount = 0; /* default value */ |
| 310 | + if (NULL != stypes) { |
| 311 | + for (int i = 0; i < scount; i++) { |
| 312 | + if (NULL != stypes[i] && !ompi_datatype_is_predefined(stypes[i])) { |
| 313 | + OBJ_RETAIN(stypes[i]); |
| 314 | + request->data.refcounted.vecs.scount = i; /* last valid type */ |
| 315 | + } |
313 | 316 | }
|
314 | 317 | }
|
315 |
| - for (int i=0; i<rcount; i++) { |
316 |
| - if (NULL != rtypes && NULL != rtypes[i] && !ompi_datatype_is_predefined(rtypes[i])) { |
317 |
| - OBJ_RETAIN(rtypes[i]); |
318 |
| - retain = true; |
| 318 | + request->data.refcounted.vecs.rcount = 0; /* default value */ |
| 319 | + if (NULL != rtypes) { |
| 320 | + for (int i = 0; i < rcount; i++) { |
| 321 | + if (NULL != rtypes[i] && !ompi_datatype_is_predefined(rtypes[i])) { |
| 322 | + OBJ_RETAIN(rtypes[i]); |
| 323 | + request->data.refcounted.vecs.rcount = i; /* last valid type */ |
| 324 | + } |
319 | 325 | }
|
320 | 326 | }
|
321 |
| - if (OPAL_UNLIKELY(retain)) { |
| 327 | + if (OPAL_LIKELY(request->data.refcounted.vecs.scount | request->data.refcounted.vecs.rcount) ) { |
322 | 328 | request->data.refcounted.vecs.stypes = (ompi_datatype_t **) stypes;
|
323 | 329 | request->data.refcounted.vecs.rtypes = (ompi_datatype_t **) rtypes;
|
| 330 | + request->data.refcounted.vecs.scount = scount; |
| 331 | + request->data.refcounted.vecs.rcount = rcount; |
324 | 332 | if (req->req_persistent) {
|
325 | 333 | request->cb.req_free = req->req_free;
|
326 | 334 | req->req_free = free_vecs_callback;
|
|
0 commit comments