Skip to content

Commit 7c9ab0a

Browse files
authored
Merge pull request #9668 from bwbarrett/bugfix/alltoallv_in_place
Alltoall{,v,w} IN_PLACE fixes
2 parents f8344de + 6802702 commit 7c9ab0a

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

ompi/mca/coll/base/coll_base_alltoall.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Copyright (c) 2014-2017 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2017 IBM Corporation. All rights reserved.
18+
* Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
19+
* reserved.
1820
* $COPYRIGHT$
1921
*
2022
* Additional copyrights may follow
@@ -108,13 +110,13 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
108110

109111
/* Receive data from the right */
110112
err = MCA_PML_CALL(irecv ((char *) rbuf + right * rcount * extent, rcount, rdtype,
111-
right, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
113+
right, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
112114
if (MPI_SUCCESS != err) { goto error_hndl; }
113115

114116
if( left != right ) {
115117
/* Send data to the left */
116118
err = MCA_PML_CALL(send ((char *) rbuf + left * rcount * extent, rcount, rdtype,
117-
left, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
119+
left, MCA_COLL_BASE_TAG_ALLTOALL, MCA_PML_BASE_SEND_STANDARD,
118120
comm));
119121
if (MPI_SUCCESS != err) { goto error_hndl; }
120122

@@ -123,13 +125,13 @@ mca_coll_base_alltoall_intra_basic_inplace(const void *rbuf, int rcount,
123125

124126
/* Receive data from the left */
125127
err = MCA_PML_CALL(irecv ((char *) rbuf + left * rcount * extent, rcount, rdtype,
126-
left, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
128+
left, MCA_COLL_BASE_TAG_ALLTOALL, comm, &req));
127129
if (MPI_SUCCESS != err) { goto error_hndl; }
128130
}
129131

130132
/* Send data to the right */
131133
err = MCA_PML_CALL(send ((char *) tmp_buffer, packed_size, MPI_PACKED,
132-
right, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
134+
right, MCA_COLL_BASE_TAG_ALLTOALL, MCA_PML_BASE_SEND_STANDARD,
133135
comm));
134136
if (MPI_SUCCESS != err) { goto error_hndl; }
135137

ompi/mca/coll/base/coll_base_alltoallv.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* Copyright (c) 2014-2017 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2017 IBM Corporation. All rights reserved.
20+
* Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
21+
* reserved.
2022
* $COPYRIGHT$
2123
*
2224
* Additional copyrights may follow
@@ -52,7 +54,8 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
5254
mca_coll_base_module_t *module)
5355
{
5456
int i, size, rank, left, right, err = MPI_SUCCESS, line;
55-
ompi_request_t *req;
57+
ptrdiff_t extent;
58+
ompi_request_t *req = MPI_REQUEST_NULL;
5659
char *tmp_buffer;
5760
size_t packed_size = 0, max_size;
5861
opal_convertor_t convertor;
@@ -87,6 +90,8 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
8790
}
8891
#endif /* OPAL_ENABLE_HETEROGENEOUS_SUPPORT */
8992

93+
ompi_datatype_type_extent(rdtype, &extent);
94+
9095
/* Allocate a temporary buffer */
9196
tmp_buffer = calloc (max_size, 1);
9297
if( NULL == tmp_buffer) { err = OMPI_ERR_OUT_OF_RESOURCE; line = __LINE__; goto error_hndl; }
@@ -102,43 +107,43 @@ mca_coll_base_alltoallv_intra_basic_inplace(const void *rbuf, const int *rcounts
102107
ompi_proc_t *right_proc = ompi_comm_peer_lookup(comm, right);
103108
opal_convertor_clone(right_proc->super.proc_convertor, &convertor, 0);
104109
opal_convertor_prepare_for_send(&convertor, &rdtype->super, rcounts[right],
105-
(char *) rbuf + rdisps[right]);
110+
(char *) rbuf + rdisps[right] * extent);
106111
packed_size = max_size;
107112
err = opal_convertor_pack(&convertor, &iov, &iov_count, &packed_size);
108113
if (1 != err) { goto error_hndl; }
109114

110115
/* Receive data from the right */
111-
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[right], rcounts[right], rdtype,
112-
right, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
116+
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[right] * extent, rcounts[right], rdtype,
117+
right, MCA_COLL_BASE_TAG_ALLTOALLV, comm, &req));
113118
if (MPI_SUCCESS != err) { goto error_hndl; }
114119
}
115120

116121
if( (left != right) && (0 != rcounts[left]) ) {
117122
/* Send data to the left */
118-
err = MCA_PML_CALL(send ((char *) rbuf + rdisps[left], rcounts[left], rdtype,
119-
left, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
123+
err = MCA_PML_CALL(send ((char *) rbuf + rdisps[left] * extent, rcounts[left], rdtype,
124+
left, MCA_COLL_BASE_TAG_ALLTOALLV, MCA_PML_BASE_SEND_STANDARD,
120125
comm));
121126
if (MPI_SUCCESS != err) { goto error_hndl; }
122127

123128
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
124129
if (MPI_SUCCESS != err) { goto error_hndl; }
125130

126131
/* Receive data from the left */
127-
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[left], rcounts[left], rdtype,
128-
left, MCA_COLL_BASE_TAG_ALLTOALLW, comm, &req));
132+
err = MCA_PML_CALL(irecv ((char *) rbuf + rdisps[left] * extent, rcounts[left], rdtype,
133+
left, MCA_COLL_BASE_TAG_ALLTOALLV, comm, &req));
129134
if (MPI_SUCCESS != err) { goto error_hndl; }
130135
}
131136

132137
if( 0 != rcounts[right] ) { /* nothing to exchange with the peer on the right */
133138
/* Send data to the right */
134139
err = MCA_PML_CALL(send ((char *) tmp_buffer, packed_size, MPI_PACKED,
135-
right, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
140+
right, MCA_COLL_BASE_TAG_ALLTOALLV, MCA_PML_BASE_SEND_STANDARD,
136141
comm));
137142
if (MPI_SUCCESS != err) { goto error_hndl; }
138-
139-
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
140-
if (MPI_SUCCESS != err) { goto error_hndl; }
141143
}
144+
145+
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
146+
if (MPI_SUCCESS != err) { goto error_hndl; }
142147
}
143148

144149
error_hndl:

ompi/mca/coll/basic/coll_basic_alltoallw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ mca_coll_basic_alltoallw_intra_inplace(const void *rbuf, const int *rcounts, con
139139
right, MCA_COLL_BASE_TAG_ALLTOALLW, MCA_PML_BASE_SEND_STANDARD,
140140
comm));
141141
if (MPI_SUCCESS != err) { goto error_hndl; }
142-
143-
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
144-
if (MPI_SUCCESS != err) { goto error_hndl; }
145142
}
143+
144+
err = ompi_request_wait (&req, MPI_STATUSES_IGNORE);
145+
if (MPI_SUCCESS != err) { goto error_hndl; }
146146
}
147147

148148
error_hndl:

0 commit comments

Comments
 (0)