Skip to content

Commit 555a8d7

Browse files
authored
Merge pull request #9168 from karasevb/topic/master/ucx_pml_dtype_retain
pml/ucx: fix datatype refcount
2 parents 30a561b + 63bab27 commit 555a8d7

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

ompi/mca/pml/ucx/pml_ucx.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,9 @@ int mca_pml_ucx_irecv_init(void *buf, size_t count, ompi_datatype_t *datatype,
550550
req->flags = 0;
551551
req->buffer = buf;
552552
req->count = count;
553-
req->datatype.datatype = mca_pml_ucx_get_datatype(datatype);
553+
req->ompi_datatype = datatype;
554+
req->datatype = mca_pml_ucx_get_datatype(datatype);
555+
OMPI_DATATYPE_RETAIN(datatype);
554556

555557
PML_UCX_MAKE_RECV_TAG(req->tag, req->recv.tag_mask, tag, src, comm);
556558

@@ -694,12 +696,13 @@ int mca_pml_ucx_isend_init(const void *buf, size_t count, ompi_datatype_t *datat
694696
req->tag = PML_UCX_MAKE_SEND_TAG(tag, comm);
695697
req->send.mode = mode;
696698
req->send.ep = ep;
699+
req->ompi_datatype = datatype;
697700

698701
if (MCA_PML_BASE_SEND_BUFFERED == mode) {
699-
req->datatype.ompi_datatype = datatype;
700702
OBJ_RETAIN(datatype);
701703
} else {
702-
req->datatype.datatype = mca_pml_ucx_get_datatype(datatype);
704+
req->datatype = mca_pml_ucx_get_datatype(datatype);
705+
OMPI_DATATYPE_RETAIN(datatype);
703706
}
704707

705708
*request = &req->ompi;
@@ -1122,16 +1125,16 @@ int mca_pml_ucx_start(size_t count, ompi_request_t** requests)
11221125
tmp_req = (ompi_request_t*)mca_pml_ucx_common_send(preq->send.ep,
11231126
preq->buffer,
11241127
preq->count,
1125-
preq->datatype.ompi_datatype,
1126-
preq->datatype.datatype,
1128+
preq->ompi_datatype,
1129+
preq->datatype,
11271130
preq->tag,
11281131
preq->send.mode,
11291132
mca_pml_ucx_psend_completion);
11301133
} else {
11311134
PML_UCX_VERBOSE(8, "start recv request %p", (void*)preq);
11321135
tmp_req = (ompi_request_t*)ucp_tag_recv_nb(ompi_pml_ucx.ucp_worker,
11331136
preq->buffer, preq->count,
1134-
preq->datatype.datatype,
1137+
preq->datatype,
11351138
preq->tag,
11361139
preq->recv.tag_mask,
11371140
mca_pml_ucx_precv_completion);

ompi/mca/pml/ucx/pml_ucx_request.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ static int mca_pml_ucx_persistent_request_free(ompi_request_t **rptr)
218218
}
219219
if ((preq->flags & MCA_PML_UCX_REQUEST_FLAG_SEND) &&
220220
(MCA_PML_BASE_SEND_BUFFERED == preq->send.mode)) {
221-
OBJ_RELEASE(preq->datatype.ompi_datatype);
221+
OBJ_RELEASE(preq->ompi_datatype);
222+
} else {
223+
OMPI_DATATYPE_RELEASE(preq->ompi_datatype);
222224
}
223225
PML_UCX_FREELIST_RETURN(&ompi_pml_ucx.persistent_reqs, &preq->ompi.super);
224226
*rptr = MPI_REQUEST_NULL;

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)