Skip to content

Commit 2a9fc68

Browse files
authored
Merge pull request #9644 from ggouaillardet/topic/coll_basic_scatterv
coll/basic: correctly handle zero size datatypes in gatherv/scatterv
2 parents ba79fa9 + acabc6b commit 2a9fc68

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

ompi/mca/coll/basic/coll_basic_gatherv.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2015 Research Organization for Information Science
13-
* and Technology (RIST). All rights reserved.
12+
* Copyright (c) 2015-2021 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
1414
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -47,6 +47,7 @@ mca_coll_basic_gatherv_intra(const void *sbuf, int scount,
4747
int i, rank, size, err;
4848
char *ptmp;
4949
ptrdiff_t lb, extent;
50+
size_t rdsize;
5051

5152
size = ompi_comm_size(comm);
5253
rank = ompi_comm_rank(comm);
@@ -58,7 +59,9 @@ mca_coll_basic_gatherv_intra(const void *sbuf, int scount,
5859
0) */
5960

6061
if (rank != root) {
61-
if (scount > 0) {
62+
size_t sdsize;
63+
ompi_datatype_type_size(sdtype, &sdsize);
64+
if (scount > 0 && sdsize > 0) {
6265
return MCA_PML_CALL(send(sbuf, scount, sdtype, root,
6366
MCA_COLL_BASE_TAG_GATHERV,
6467
MCA_PML_BASE_SEND_STANDARD, comm));
@@ -68,6 +71,12 @@ mca_coll_basic_gatherv_intra(const void *sbuf, int scount,
6871

6972
/* I am the root, loop receiving data. */
7073

74+
ompi_datatype_type_size(rdtype, &rdsize);
75+
if (OPAL_UNLIKELY(0 == rdsize)) {
76+
/* bozzo case */
77+
return MPI_SUCCESS;
78+
}
79+
7180
err = ompi_datatype_get_extent(rdtype, &lb, &extent);
7281
if (OMPI_SUCCESS != err) {
7382
return OMPI_ERROR;

ompi/mca/coll/basic/coll_basic_scatterv.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12-
* Copyright (c) 2015 Research Organization for Information Science
13-
* and Technology (RIST). All rights reserved.
12+
* Copyright (c) 2015-2021 Research Organization for Information Science
13+
* and Technology (RIST). All rights reserved.
1414
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -49,6 +49,7 @@ mca_coll_basic_scatterv_intra(const void *sbuf, const int *scounts,
4949
int i, rank, size, err;
5050
char *ptmp;
5151
ptrdiff_t lb, extent;
52+
size_t sdsize;
5253

5354
/* Initialize */
5455

@@ -58,15 +59,23 @@ mca_coll_basic_scatterv_intra(const void *sbuf, const int *scounts,
5859
/* If not root, receive data. */
5960

6061
if (rank != root) {
62+
size_t rdsize;
63+
ompi_datatype_type_size(rdtype, &rdsize);
6164
/* Only receive if there is something to receive */
62-
if (rcount > 0) {
65+
if (rcount > 0 && rdsize > 0) {
6366
return MCA_PML_CALL(recv(rbuf, rcount, rdtype,
6467
root, MCA_COLL_BASE_TAG_SCATTERV,
6568
comm, MPI_STATUS_IGNORE));
6669
}
6770
return MPI_SUCCESS;
6871
}
6972

73+
ompi_datatype_type_size(sdtype, &sdsize);
74+
if (OPAL_UNLIKELY(0 == sdsize)) {
75+
/* bozzo case */
76+
return MPI_SUCCESS;
77+
}
78+
7079
/* I am the root, loop sending data. */
7180

7281
err = ompi_datatype_get_extent(sdtype, &lb, &extent);

0 commit comments

Comments
 (0)