Skip to content

Commit 5ba7ef0

Browse files
authored
Merge pull request #9175 from karasevb/topic/v4.1.x/ucx_pml_dtype_retain
v4.1.x: pml/ucx: fix datatype refcount
2 parents bca1cba + f740e46 commit 5ba7ef0

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

ompi/mca/pml/ucx/pml_ucx.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,9 @@ int mca_pml_ucx_irecv_init(void *buf, size_t count, ompi_datatype_t *datatype,
564564
req->flags = 0;
565565
req->buffer = buf;
566566
req->count = count;
567-
req->datatype.datatype = mca_pml_ucx_get_datatype(datatype);
567+
req->ompi_datatype = datatype;
568+
req->datatype = mca_pml_ucx_get_datatype(datatype);
569+
OMPI_DATATYPE_RETAIN(datatype);
568570

569571
PML_UCX_MAKE_RECV_TAG(req->tag, req->recv.tag_mask, tag, src, comm);
570572

@@ -699,12 +701,13 @@ int mca_pml_ucx_isend_init(const void *buf, size_t count, ompi_datatype_t *datat
699701
req->tag = PML_UCX_MAKE_SEND_TAG(tag, comm);
700702
req->send.mode = mode;
701703
req->send.ep = ep;
704+
req->ompi_datatype = datatype;
705+
OMPI_DATATYPE_RETAIN(datatype);
702706

703707
if (MCA_PML_BASE_SEND_BUFFERED == mode) {
704-
req->datatype.ompi_datatype = datatype;
705-
OBJ_RETAIN(datatype);
708+
req->datatype = NULL;
706709
} else {
707-
req->datatype.datatype = mca_pml_ucx_get_datatype(datatype);
710+
req->datatype = mca_pml_ucx_get_datatype(datatype);
708711
}
709712

710713
*request = &req->ompi;
@@ -1113,16 +1116,16 @@ int mca_pml_ucx_start(size_t count, ompi_request_t** requests)
11131116
tmp_req = (ompi_request_t*)mca_pml_ucx_common_send(preq->send.ep,
11141117
preq->buffer,
11151118
preq->count,
1116-
preq->datatype.ompi_datatype,
1117-
preq->datatype.datatype,
1119+
preq->ompi_datatype,
1120+
preq->datatype,
11181121
preq->tag,
11191122
preq->send.mode,
11201123
mca_pml_ucx_psend_completion);
11211124
} else {
11221125
PML_UCX_VERBOSE(8, "start recv request %p", (void*)preq);
11231126
tmp_req = (ompi_request_t*)ucp_tag_recv_nb(ompi_pml_ucx.ucp_worker,
11241127
preq->buffer, preq->count,
1125-
preq->datatype.datatype,
1128+
preq->datatype,
11261129
preq->tag,
11271130
preq->recv.tag_mask,
11281131
mca_pml_ucx_precv_completion);

ompi/mca/pml/ucx/pml_ucx_request.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,7 @@ static int mca_pml_ucx_persistent_request_free(ompi_request_t **rptr)
212212
mca_pml_ucx_persistent_request_detach(preq, tmp_req);
213213
ucp_request_free(tmp_req);
214214
}
215-
if ((preq->flags & MCA_PML_UCX_REQUEST_FLAG_SEND) &&
216-
(MCA_PML_BASE_SEND_BUFFERED == preq->send.mode)) {
217-
OBJ_RELEASE(preq->datatype.ompi_datatype);
218-
}
215+
OMPI_DATATYPE_RELEASE(preq->ompi_datatype);
219216
PML_UCX_FREELIST_RETURN(&ompi_pml_ucx.persistent_reqs, &preq->ompi.super);
220217
*rptr = MPI_REQUEST_NULL;
221218
return OMPI_SUCCESS;

ompi/mca/pml/ucx/pml_ucx_request.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ struct pml_ucx_persistent_request {
9999
unsigned flags;
100100
void *buffer;
101101
size_t count;
102-
union {
103-
ucp_datatype_t datatype;
104-
ompi_datatype_t *ompi_datatype;
105-
} datatype;
102+
ucp_datatype_t datatype;
103+
ompi_datatype_t *ompi_datatype;
106104
ucp_tag_t tag;
107105
struct {
108106
mca_pml_base_send_mode_t mode;

0 commit comments

Comments
 (0)