Skip to content

Commit 9424bb2

Browse files
committed
coll/base: optimize handling of zero-byte datatypes in mca_coll_base_alltoallv_intra_basic_inplace()
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp> (back-ported from commit d1c5955)
1 parent b0001e9 commit 9424bb2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ompi/mca/coll/base/coll_base_alltoallv.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,16 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
4545
int i, j, size, rank, err=MPI_SUCCESS;
4646
ompi_request_t *req;
4747
char *allocated_buffer, *tmp_buffer;
48-
size_t max_size, rdtype_size;
49-
OPAL_PTRDIFF_TYPE ext, gap;
48+
size_t max_size;
49+
OPAL_PTRDIFF_TYPE ext, gap = 0;
5050

5151
/* Initialize. */
5252

5353
size = ompi_comm_size(comm);
5454
rank = ompi_comm_rank(comm);
55-
ompi_datatype_type_size(rdtype, &rdtype_size);
5655

5756
/* If only one process, we're done. */
58-
if (1 == size || 0 == rdtype_size) {
57+
if (1 == size) {
5958
return MPI_SUCCESS;
6059
}
6160

@@ -67,6 +66,10 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
6766
}
6867
/* The gap will always be the same as we are working on the same datatype */
6968

69+
if (OPAL_UNLIKELY(0 == max_size)) {
70+
return MPI_SUCCESS;
71+
}
72+
7073
/* Allocate a temporary buffer */
7174
allocated_buffer = calloc (max_size, 1);
7275
if (NULL == allocated_buffer) {
@@ -78,7 +81,7 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
7881
/* in-place alltoallv slow algorithm (but works) */
7982
for (i = 0 ; i < size ; ++i) {
8083
for (j = i+1 ; j < size ; ++j) {
81-
if (i == rank && 0 != rcounts[j] && 0 != rdtype_size) {
84+
if (i == rank && 0 != rcounts[j]) {
8285
/* Copy the data into the temporary buffer */
8386
err = ompi_datatype_copy_content_same_ddt (rdtype, rcounts[j],
8487
tmp_buffer, (char *) rbuf + rdisps[j] * ext);
@@ -93,7 +96,7 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
9396
j, MCA_COLL_BASE_TAG_ALLTOALLV, MCA_PML_BASE_SEND_STANDARD,
9497
comm));
9598
if (MPI_SUCCESS != err) { goto error_hndl; }
96-
} else if (j == rank && 0 != rcounts[i] && 0 != rdtype_size) {
99+
} else if (j == rank && 0 != rcounts[i]) {
97100
/* Copy the data into the temporary buffer */
98101
err = ompi_datatype_copy_content_same_ddt (rdtype, rcounts[i],
99102
tmp_buffer, (char *) rbuf + rdisps[i] * ext);

0 commit comments

Comments
 (0)