Skip to content

Commit

Permalink
coll/base/alltoallv: skip send/recv 0-byte data
Browse files Browse the repository at this point in the history
The previous change c1a98f1 should have
checked for total data size in bytes instead of count. This patch fixes
that.

Signed-off-by: Wenduo Wang <[email protected]>
  • Loading branch information
wenduwan committed Jan 13, 2024
1 parent 5fa32f7 commit 477be61
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions ompi/mca/coll/base/coll_base_alltoallv.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ ompi_coll_base_alltoallv_intra_pairwise(const void *sbuf, const int *scounts, co
mca_coll_base_module_t *module)
{
int line = -1, err = 0, rank, size, step = 0, sendto, recvfrom;
size_t sndsz, rcvsz;
void *psnd, *prcv;
ptrdiff_t sext, rext;

Expand All @@ -213,6 +214,14 @@ ompi_coll_base_alltoallv_intra_pairwise(const void *sbuf, const int *scounts, co
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
"coll:base:alltoallv_intra_pairwise rank %d", rank));

ompi_datatype_type_size(sdtype, &sndsz);
ompi_datatype_type_size(rdtype, &rcvsz);

if (0 == sndsz || 0 == rcvsz) {
/* Nothing to exchange */
return MPI_SUCCESS;
}

ompi_datatype_type_extent(sdtype, &sext);
ompi_datatype_type_extent(rdtype, &rext);

Expand Down Expand Up @@ -263,6 +272,7 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
mca_coll_base_module_t *module)
{
int i, size, rank, err, nreqs;
size_t sdtype_size = 0, rdtype_size = 0;
char *psnd, *prcv;
ptrdiff_t sext, rext;
ompi_request_t **preq, **reqs;
Expand All @@ -280,13 +290,21 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
"coll:base:alltoallv_intra_basic_linear rank %d", rank));

ompi_datatype_type_size(rdtype, &rdtype_size);
ompi_datatype_type_size(sdtype, &sdtype_size);

if (0 == rdtype_size || 0 == sdtype_size) {
/* Nothing to exchange */
return MPI_SUCCESS;
}

ompi_datatype_type_extent(sdtype, &sext);
ompi_datatype_type_extent(rdtype, &rext);

/* Simple optimization - handle send to self first */
psnd = ((char *) sbuf) + (ptrdiff_t)sdisps[rank] * sext;
prcv = ((char *) rbuf) + (ptrdiff_t)rdisps[rank] * rext;
if (0 != scounts[rank]) {
if (0 < scounts[rank]) {
err = ompi_datatype_sndrcv(psnd, scounts[rank], sdtype,
prcv, rcounts[rank], rdtype);
if (MPI_SUCCESS != err) {
Expand All @@ -310,7 +328,7 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
continue;
}

if (rcounts[i] > 0) {
if (0 < rcounts[i]) {
++nreqs;
prcv = ((char *) rbuf) + (ptrdiff_t)rdisps[i] * rext;
err = MCA_PML_CALL(irecv_init(prcv, rcounts[i], rdtype,
Expand All @@ -326,7 +344,7 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
continue;
}

if (scounts[i] > 0) {
if (0 < scounts[i]) {
++nreqs;
psnd = ((char *) sbuf) + (ptrdiff_t)sdisps[i] * sext;
err = MCA_PML_CALL(isend_init(psnd, scounts[i], sdtype,
Expand Down

0 comments on commit 477be61

Please sign in to comment.