Skip to content

Commit 5658e45

Browse files
ggouaillardetawlauria
authored andcommitted
coll/basic: correctly handle zero size datatypes in gatherv
Since no message is sent/received when the count is zero, do not send/receive any message when the datatype size is zero. Refs. #9619 Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp> (cherry picked from commit acabc6b)
1 parent 530f2b5 commit 5658e45

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
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;

0 commit comments

Comments
 (0)