Skip to content

Commit dfaf2c7

Browse files
authored
Merge pull request #2339 from ggouaillardet/topic/v2.x/ialltoallx_mpi_param_check
v2.x: mpi/ialltoall*: allow MPI_IN_PLACE as the send buffer for intra-commu…
2 parents b604553 + fa8b85a commit dfaf2c7

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

ompi/mpi/c/ialltoall.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ int MPI_Ialltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
7070
if (ompi_comm_invalid(comm)) {
7171
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
7272
FUNC_NAME);
73-
} else if (MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
73+
} else if ((MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
74+
MPI_IN_PLACE == recvbuf) {
7475
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
7576
FUNC_NAME);
7677
} else {
77-
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
78-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
78+
if (MPI_IN_PLACE != sendbuf) {
79+
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
80+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
81+
}
7982
OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcount);
8083
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
8184
}

ompi/mpi/c/ialltoallv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl
4848
MPI_Request *request)
4949
{
5050
int i, size, err;
51-
size_t sendtype_size, recvtype_size;
5251

5352
MEMCHECKER(
5453
ptrdiff_t recv_ext;
@@ -98,7 +97,8 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl
9897

9998
if ((NULL == sendcounts) || (NULL == sdispls) ||
10099
(NULL == recvcounts) || (NULL == rdispls) ||
101-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
100+
(MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
101+
MPI_IN_PLACE == recvbuf) {
102102
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
103103
}
104104

@@ -112,6 +112,7 @@ int MPI_Ialltoallv(const void *sendbuf, const int sendcounts[], const int sdispl
112112

113113
if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
114114
int me = ompi_comm_rank(comm);
115+
size_t sendtype_size, recvtype_size;
115116
ompi_datatype_type_size(sendtype, &sendtype_size);
116117
ompi_datatype_type_size(recvtype, &recvtype_size);
117118
if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {

ompi/mpi/c/ialltoallw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl
4848
MPI_Request *request)
4949
{
5050
int i, size, err;
51-
size_t sendtype_size, recvtype_size;
5251

5352
MEMCHECKER(
5453
ptrdiff_t recv_ext;
@@ -94,7 +93,8 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl
9493

9594
if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
9695
(NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
97-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
96+
(MPI_IN_PLACE == sendbuf && OMPI_COMM_IS_INTER(comm)) ||
97+
MPI_IN_PLACE == recvbuf) {
9898
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
9999
}
100100

@@ -108,6 +108,7 @@ int MPI_Ialltoallw(const void *sendbuf, const int sendcounts[], const int sdispl
108108

109109
if (MPI_IN_PLACE != sendbuf && !OMPI_COMM_IS_INTER(comm)) {
110110
int me = ompi_comm_rank(comm);
111+
size_t sendtype_size, recvtype_size;
111112
ompi_datatype_type_size(sendtypes[me], &sendtype_size);
112113
ompi_datatype_type_size(recvtypes[me], &recvtype_size);
113114
if ((sendtype_size*sendcounts[me]) != (recvtype_size*recvcounts[me])) {

0 commit comments

Comments
 (0)