Skip to content

Commit a7b4d3e

Browse files
committed
coll/base/alltoallv: skip send/recv 0-byte data
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 <wenduwan@amazon.com>
1 parent 5fa32f7 commit a7b4d3e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ompi/mca/coll/base/coll_base_alltoallv.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ ompi_coll_base_alltoallv_intra_pairwise(const void *sbuf, const int *scounts, co
199199
mca_coll_base_module_t *module)
200200
{
201201
int line = -1, err = 0, rank, size, step = 0, sendto, recvfrom;
202+
size_t sdtype_size, rdtype_size;
202203
void *psnd, *prcv;
203204
ptrdiff_t sext, rext;
204205

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

217+
ompi_datatype_type_size(sdtype, &sdtype_size);
218+
ompi_datatype_type_size(rdtype, &rdtype_size);
219+
220+
if (0 == sdtype_size || 0 == rdtype_size) {
221+
/* Nothing to exchange */
222+
return MPI_SUCCESS;
223+
}
224+
216225
ompi_datatype_type_extent(sdtype, &sext);
217226
ompi_datatype_type_extent(rdtype, &rext);
218227

@@ -263,6 +272,7 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
263272
mca_coll_base_module_t *module)
264273
{
265274
int i, size, rank, err, nreqs;
275+
size_t sdtype_size = 0, rdtype_size = 0;
266276
char *psnd, *prcv;
267277
ptrdiff_t sext, rext;
268278
ompi_request_t **preq, **reqs;
@@ -280,13 +290,21 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
280290
OPAL_OUTPUT((ompi_coll_base_framework.framework_output,
281291
"coll:base:alltoallv_intra_basic_linear rank %d", rank));
282292

293+
ompi_datatype_type_size(rdtype, &rdtype_size);
294+
ompi_datatype_type_size(sdtype, &sdtype_size);
295+
296+
if (0 == rdtype_size || 0 == sdtype_size) {
297+
/* Nothing to exchange */
298+
return MPI_SUCCESS;
299+
}
300+
283301
ompi_datatype_type_extent(sdtype, &sext);
284302
ompi_datatype_type_extent(rdtype, &rext);
285303

286304
/* Simple optimization - handle send to self first */
287305
psnd = ((char *) sbuf) + (ptrdiff_t)sdisps[rank] * sext;
288306
prcv = ((char *) rbuf) + (ptrdiff_t)rdisps[rank] * rext;
289-
if (0 != scounts[rank]) {
307+
if (0 < scounts[rank]) {
290308
err = ompi_datatype_sndrcv(psnd, scounts[rank], sdtype,
291309
prcv, rcounts[rank], rdtype);
292310
if (MPI_SUCCESS != err) {
@@ -310,7 +328,7 @@ ompi_coll_base_alltoallv_intra_basic_linear(const void *sbuf, const int *scounts
310328
continue;
311329
}
312330

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

329-
if (scounts[i] > 0) {
347+
if (0 < scounts[i]) {
330348
++nreqs;
331349
psnd = ((char *) sbuf) + (ptrdiff_t)sdisps[i] * sext;
332350
err = MCA_PML_CALL(isend_init(psnd, scounts[i], sdtype,

0 commit comments

Comments
 (0)