Skip to content

Commit c7b7619

Browse files
ggouaillardetawlauria
authored andcommitted
coll/basic: fix MPI_Alltoallw(MPI_IN_PLACE) gap handling
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. #9329 Signed-off-by: Gilles Gouaillardet <[email protected]> (cherry picked from commit 0041ce8) Signed-off-by: Brian Barrett <[email protected]> (cherry picked from commit 8ff0a09)
1 parent aa2514c commit c7b7619

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ompi/mca/coll/basic/coll_basic_alltoallw.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2013 FUJITSU LIMITED. All rights reserved.
17-
* Copyright (c) 2014-2016 Research Organization for Information Science
18-
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2014-2021 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
2020
* Copyright (c) 2017 IBM Corporation. All rights reserved.
2121
* $COPYRIGHT$
@@ -44,7 +44,7 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
4444
{
4545
int i, j, size, rank, err = MPI_SUCCESS, max_size;
4646
ompi_request_t *req;
47-
char *tmp_buffer, *save_buffer = NULL;
47+
char *save_buffer = NULL;
4848
ptrdiff_t ext, gap = 0;
4949

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

6767
/* Allocate a temporary buffer */
68-
tmp_buffer = save_buffer = calloc (max_size, 1);
69-
if (NULL == tmp_buffer) {
68+
save_buffer = calloc (max_size, 1);
69+
if (NULL == save_buffer) {
7070
return OMPI_ERR_OUT_OF_RESOURCE;
7171
}
72-
tmp_buffer -= gap;
7372

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

8483
/* Initiate all send/recv to/from others. */
8584
if (i == rank && msg_size_j != 0) {
85+
char * tmp_buffer;
86+
/* Shift the temporary buffer according to the current datatype */
87+
(void)opal_datatype_span(&rdtypes[j]->super, rcounts[j], &gap);
88+
tmp_buffer = save_buffer - gap;
8689
/* Copy the data into the temporary buffer */
8790
err = ompi_datatype_copy_content_same_ddt (rdtypes[j], rcounts[j],
8891
tmp_buffer, (char *) rbuf + rdisps[j]);
@@ -98,6 +101,10 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
98101
comm));
99102
if (MPI_SUCCESS != err) { goto error_hndl; }
100103
} else if (j == rank && msg_size_i != 0) {
104+
char * tmp_buffer;
105+
/* Shift the temporary buffer according to the current datatype */
106+
(void)opal_datatype_span(&rdtypes[i]->super, rcounts[i], &gap);
107+
tmp_buffer = save_buffer - gap;
101108
/* Copy the data into the temporary buffer */
102109
err = ompi_datatype_copy_content_same_ddt (rdtypes[i], rcounts[i],
103110
tmp_buffer, (char *) rbuf + rdisps[i]);

0 commit comments

Comments
 (0)