Skip to content

Commit

Permalink
coll/basic: fix MPI_Alltoallw(MPI_IN_PLACE) gap handling
Browse files Browse the repository at this point in the history
The temporary buffer must be shifted by the true_extent on a
per type basis (since the various datatypes might have different
true_extent).

Thanks Heiko Bauke for reporting this.

Refs. open-mpi#9329

Signed-off-by: Gilles Gouaillardet <[email protected]>
  • Loading branch information
ggouaillardet committed Aug 30, 2021
1 parent 2e19085 commit 0041ce8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ompi/mca/coll/basic/coll_basic_alltoallw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2013 FUJITSU LIMITED. All rights reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014-2021 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
Expand Down Expand Up @@ -44,7 +44,7 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
{
int i, j, size, rank, err = MPI_SUCCESS, max_size;
ompi_request_t *req;
char *tmp_buffer, *save_buffer = NULL;
char *save_buffer = NULL;
ptrdiff_t ext, gap = 0;

/* Initialize. */
Expand All @@ -65,11 +65,10 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
}

/* Allocate a temporary buffer */
tmp_buffer = save_buffer = calloc (max_size, 1);
if (NULL == tmp_buffer) {
save_buffer = calloc (max_size, 1);
if (NULL == save_buffer) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
tmp_buffer -= gap;

/* in-place alltoallw slow algorithm (but works) */
for (i = 0 ; i < size ; ++i) {
Expand All @@ -83,6 +82,10 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con

/* Initiate all send/recv to/from others. */
if (i == rank && msg_size_j != 0) {
char * tmp_buffer;
/* Shift the temporary buffer according to the current datatype */
(void)opal_datatype_span(&rdtypes[j]->super, rcounts[j], &gap);
tmp_buffer = save_buffer - gap;
/* Copy the data into the temporary buffer */
err = ompi_datatype_copy_content_same_ddt (rdtypes[j], rcounts[j],
tmp_buffer, (char *) rbuf + rdisps[j]);
Expand All @@ -98,6 +101,10 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
comm));
if (MPI_SUCCESS != err) { goto error_hndl; }
} else if (j == rank && msg_size_i != 0) {
char * tmp_buffer;
/* Shift the temporary buffer according to the current datatype */
(void)opal_datatype_span(&rdtypes[i]->super, rcounts[i], &gap);
tmp_buffer = save_buffer - gap;
/* Copy the data into the temporary buffer */
err = ompi_datatype_copy_content_same_ddt (rdtypes[i], rcounts[i],
tmp_buffer, (char *) rbuf + rdisps[i]);
Expand Down

0 comments on commit 0041ce8

Please sign in to comment.