Skip to content

Commit fd13b27

Browse files
authored
Merge pull request #6889 from ggouaillardet/topic/v4.0.x/nbc_fixes
coll/base: only retain datatypes/op if the request has not yet completed
2 parents 8087147 + 39ec580 commit fd13b27

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

ompi/mca/coll/base/coll_base_util.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ int ompi_rounddown(int num, int factor)
108108
static void release_objs_callback(struct ompi_coll_base_nbc_request_t *request) {
109109
if (NULL != request->data.objs.objs[0]) {
110110
OBJ_RELEASE(request->data.objs.objs[0]);
111+
request->data.objs.objs[0] = NULL;
111112
}
112113
if (NULL != request->data.objs.objs[1]) {
113114
OBJ_RELEASE(request->data.objs.objs[1]);
115+
request->data.objs.objs[1] = NULL;
114116
}
115117
}
116118

@@ -139,6 +141,9 @@ int ompi_coll_base_retain_op( ompi_request_t *req, ompi_op_t *op,
139141
ompi_datatype_t *type) {
140142
ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
141143
bool retain = false;
144+
if (REQUEST_COMPLETE(req)) {
145+
return OMPI_SUCCESS;
146+
}
142147
if (!ompi_op_is_intrinsic(op)) {
143148
OBJ_RETAIN(op);
144149
request->data.op.op = op;
@@ -175,6 +180,9 @@ int ompi_coll_base_retain_datatypes( ompi_request_t *req, ompi_datatype_t *stype
175180
ompi_datatype_t *rtype) {
176181
ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
177182
bool retain = false;
183+
if (REQUEST_COMPLETE(req)) {
184+
return OMPI_SUCCESS;
185+
}
178186
if (NULL != stype && !ompi_datatype_is_predefined(stype)) {
179187
OBJ_RETAIN(stype);
180188
request->data.types.stype = stype;
@@ -207,15 +215,21 @@ static void release_vecs_callback(ompi_coll_base_nbc_request_t *request) {
207215
} else {
208216
scount = rcount = OMPI_COMM_IS_INTER(comm)?ompi_comm_remote_size(comm):ompi_comm_size(comm);
209217
}
210-
for (int i=0; i<scount; i++) {
211-
if (NULL != request->data.vecs.stypes && NULL != request->data.vecs.stypes[i]) {
212-
OMPI_DATATYPE_RELEASE(request->data.vecs.stypes[i]);
218+
if (NULL != request->data.vecs.stypes) {
219+
for (int i=0; i<scount; i++) {
220+
if (NULL != request->data.vecs.stypes[i]) {
221+
OMPI_DATATYPE_RELEASE(request->data.vecs.stypes[i]);
222+
}
213223
}
224+
request->data.vecs.stypes = NULL;
214225
}
215-
for (int i=0; i<rcount; i++) {
216-
if (NULL != request->data.vecs.rtypes && NULL != request->data.vecs.rtypes[i]) {
217-
OMPI_DATATYPE_RELEASE(request->data.vecs.rtypes[i]);
226+
if (NULL != request->data.vecs.rtypes) {
227+
for (int i=0; i<rcount; i++) {
228+
if (NULL != request->data.vecs.rtypes[i]) {
229+
OMPI_DATATYPE_RELEASE(request->data.vecs.rtypes[i]);
230+
}
218231
}
232+
request->data.vecs.rtypes = NULL;
219233
}
220234
}
221235

@@ -246,6 +260,9 @@ int ompi_coll_base_retain_datatypes_w( ompi_request_t *req,
246260
bool retain = false;
247261
ompi_communicator_t *comm = request->super.req_mpi_object.comm;
248262
int scount, rcount;
263+
if (REQUEST_COMPLETE(req)) {
264+
return OMPI_SUCCESS;
265+
}
249266
if (OMPI_COMM_IS_TOPO(comm)) {
250267
(void)mca_topo_base_neighbor_count (comm, &rcount, &scount);
251268
} else {

ompi/mca/coll/libnbc/coll_libnbc_component.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,6 @@ request_construct(ompi_coll_libnbc_request_t *request)
460460

461461

462462
OBJ_CLASS_INSTANCE(ompi_coll_libnbc_request_t,
463-
ompi_request_t,
463+
ompi_coll_base_nbc_request_t,
464464
request_construct,
465465
NULL);

0 commit comments

Comments
 (0)