Skip to content

v4.1.x: refactor UCC collective operations to handle MPI_IN_PLACE correctly #13229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ompi/mca/coll/ucc/coll_ucc_allgather.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ static inline ucc_status_t mca_coll_ucc_allgather_init(const void *sbuf, size_t
ucc_coll_req_h *req,
mca_coll_ucc_req_t *coll_req)
{
ucc_datatype_t ucc_sdt, ucc_rdt;
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
bool is_inplace = (MPI_IN_PLACE == sbuf);
int comm_size = ompi_comm_size(ucc_module->comm);

if (!ompi_datatype_is_contiguous_memory_layout(sdtype, scount) ||
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(sdtype, scount)) ||
!ompi_datatype_is_contiguous_memory_layout(rdtype, rcount * comm_size)) {
goto fallback;
}
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);

ucc_rdt = ompi_dtype_to_ucc_dtype(rdtype);
if (!is_inplace) {
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
}

if (COLL_UCC_DT_UNSUPPORTED == ucc_sdt ||
COLL_UCC_DT_UNSUPPORTED == ucc_rdt) {
UCC_VERBOSE(5, "ompi_datatype is not supported: dtype = %s",
Expand All @@ -49,7 +54,7 @@ static inline ucc_status_t mca_coll_ucc_allgather_init(const void *sbuf, size_t
}
};

if (MPI_IN_PLACE == sbuf) {
if (is_inplace) {
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
}
Expand Down
10 changes: 7 additions & 3 deletions ompi/mca/coll/ucc/coll_ucc_allgatherv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ static inline ucc_status_t mca_coll_ucc_allgatherv_init(const void *sbuf, size_t
ucc_coll_req_h *req,
mca_coll_ucc_req_t *coll_req)
{
ucc_datatype_t ucc_sdt, ucc_rdt;
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
bool is_inplace = (MPI_IN_PLACE == sbuf);

ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
ucc_rdt = ompi_dtype_to_ucc_dtype(rdtype);
if (!is_inplace) {
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
}

if (COLL_UCC_DT_UNSUPPORTED == ucc_sdt ||
COLL_UCC_DT_UNSUPPORTED == ucc_rdt) {
UCC_VERBOSE(5, "ompi_datatype is not supported: dtype = %s",
Expand All @@ -47,7 +51,7 @@ static inline ucc_status_t mca_coll_ucc_allgatherv_init(const void *sbuf, size_t
}
};

if (MPI_IN_PLACE == sbuf) {
if (is_inplace) {
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
}
Expand Down
13 changes: 9 additions & 4 deletions ompi/mca/coll/ucc/coll_ucc_alltoall.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ static inline ucc_status_t mca_coll_ucc_alltoall_init(const void *sbuf, size_t s
ucc_coll_req_h *req,
mca_coll_ucc_req_t *coll_req)
{
ucc_datatype_t ucc_sdt, ucc_rdt;
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
bool is_inplace = (MPI_IN_PLACE == sbuf);
int comm_size = ompi_comm_size(ucc_module->comm);

if (!ompi_datatype_is_contiguous_memory_layout(sdtype, scount * comm_size) ||
if (!(is_inplace || ompi_datatype_is_contiguous_memory_layout(sdtype, scount * comm_size)) ||
!ompi_datatype_is_contiguous_memory_layout(rdtype, rcount * comm_size)) {
goto fallback;
}
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);

ucc_rdt = ompi_dtype_to_ucc_dtype(rdtype);
if (!is_inplace) {
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
}

if (COLL_UCC_DT_UNSUPPORTED == ucc_sdt ||
COLL_UCC_DT_UNSUPPORTED == ucc_rdt) {
UCC_VERBOSE(5, "ompi_datatype is not supported: dtype = %s",
Expand All @@ -49,7 +54,7 @@ static inline ucc_status_t mca_coll_ucc_alltoall_init(const void *sbuf, size_t s
}
};

if (MPI_IN_PLACE == sbuf) {
if (is_inplace) {
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
}
Expand Down
10 changes: 7 additions & 3 deletions ompi/mca/coll/ucc/coll_ucc_alltoallv.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ static inline ucc_status_t mca_coll_ucc_alltoallv_init(const void *sbuf, const i
ucc_coll_req_h *req,
mca_coll_ucc_req_t *coll_req)
{
ucc_datatype_t ucc_sdt, ucc_rdt;
ucc_datatype_t ucc_sdt = UCC_DT_INT8, ucc_rdt = UCC_DT_INT8;
bool is_inplace = (MPI_IN_PLACE == sbuf);

ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
ucc_rdt = ompi_dtype_to_ucc_dtype(rdtype);
if (!is_inplace) {
ucc_sdt = ompi_dtype_to_ucc_dtype(sdtype);
}

if (COLL_UCC_DT_UNSUPPORTED == ucc_sdt ||
COLL_UCC_DT_UNSUPPORTED == ucc_rdt) {
UCC_VERBOSE(5, "ompi_datatype is not supported: dtype = %s",
Expand Down Expand Up @@ -48,7 +52,7 @@ static inline ucc_status_t mca_coll_ucc_alltoallv_init(const void *sbuf, const i
}
};

if (MPI_IN_PLACE == sbuf) {
if (is_inplace) {
coll.mask = UCC_COLL_ARGS_FIELD_FLAGS;
coll.flags = UCC_COLL_ARGS_FLAG_IN_PLACE;
}
Expand Down