From d1c5955b73cf61affea39e1cbcd4e79923da5504 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 30 Jun 2017 09:47:08 +0900 Subject: [PATCH] coll/base: optimize handling of zero-byte datatypes in mca_coll_base_alltoallv_intra_basic_inplace() Signed-off-by: Gilles Gouaillardet --- ompi/mca/coll/base/coll_base_alltoallv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ompi/mca/coll/base/coll_base_alltoallv.c b/ompi/mca/coll/base/coll_base_alltoallv.c index 2d23572674..d7a2dbb949 100644 --- a/ompi/mca/coll/base/coll_base_alltoallv.c +++ b/ompi/mca/coll/base/coll_base_alltoallv.c @@ -44,14 +44,13 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts { int i, j, size, rank, err=MPI_SUCCESS; char *allocated_buffer, *tmp_buffer; - size_t max_size, rdtype_size; + size_t max_size; ptrdiff_t ext, gap = 0; /* Initialize. */ size = ompi_comm_size(comm); rank = ompi_comm_rank(comm); - ompi_datatype_type_size(rdtype, &rdtype_size); /* If only one process, we're done. */ if (1 == size) { @@ -68,6 +67,10 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts } /* The gap will always be the same as we are working on the same datatype */ + if (OPAL_UNLIKELY(0 == max_size)) { + return MPI_SUCCESS; + } + /* Allocate a temporary buffer */ allocated_buffer = calloc (max_size, 1); if (NULL == allocated_buffer) { @@ -79,7 +82,7 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts /* in-place alltoallv slow algorithm (but works) */ for (i = 0 ; i < size ; ++i) { for (j = i+1 ; j < size ; ++j) { - if (i == rank && 0 != rcounts[j] && 0 != rdtype_size) { + if (i == rank && 0 != rcounts[j]) { /* Copy the data into the temporary buffer */ err = ompi_datatype_copy_content_same_ddt (rdtype, rcounts[j], tmp_buffer, (char *) rbuf + rdisps[j] * ext); @@ -92,7 +95,7 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts j, MCA_COLL_BASE_TAG_ALLTOALLV, comm, MPI_STATUS_IGNORE); if (MPI_SUCCESS != err) { goto error_hndl; } - } else if (j == rank && 0 != rcounts[i] && 0 != rdtype_size) { + } else if (j == rank && 0 != rcounts[i]) { /* Copy the data into the temporary buffer */ err = ompi_datatype_copy_content_same_ddt (rdtype, rcounts[i], tmp_buffer, (char *) rbuf + rdisps[i] * ext);