Skip to content

Commit 0d1af43

Browse files
authored
Merge pull request #7924 from hkuno/hkuno/cherry-pick_5655d64b
mpi/c: fix param checks in [I]Neighbor_alltoall{v,w}
2 parents 4fd3cdc + 79a737c commit 0d1af43

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

ompi/mpi/c/ineighbor_alltoallv.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2018 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2014-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -102,14 +102,15 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
102102
} else if (! OMPI_COMM_IS_TOPO(comm)) {
103103
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
104104
FUNC_NAME);
105-
} else if ((NULL == sendcounts) || (NULL == sdispls) ||
106-
(NULL == recvcounts) || (NULL == rdispls) ||
107-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
108-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
109105
}
110106

111107
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
112108
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
109+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls))) ||
110+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls))) ||
111+
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
112+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
113+
}
113114
for (i = 0; i < outdegree; ++i) {
114115
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
115116
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

ompi/mpi/c/ineighbor_alltoallw.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2018 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2014-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -102,14 +102,13 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
102102
FUNC_NAME);
103103
}
104104

105-
if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
106-
(NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
105+
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
106+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
107+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) ||
108+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) ||
107109
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
108110
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
109111
}
110-
111-
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
112-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
113112
for (i = 0; i < outdegree; ++i) {
114113
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
115114
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

ompi/mpi/c/neighbor_alltoallv.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2015 Research Organization for Information Science
16+
* Copyright (c) 2014-2019 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
@@ -101,14 +101,15 @@ int MPI_Neighbor_alltoallv(const void *sendbuf, const int sendcounts[], const in
101101
} else if (! OMPI_COMM_IS_TOPO(comm)) {
102102
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
103103
FUNC_NAME);
104-
} else if ((NULL == sendcounts) || (NULL == sdispls) ||
105-
(NULL == recvcounts) || (NULL == rdispls) ||
106-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
107-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
108104
}
109105

110106
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
111107
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
108+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls))) ||
109+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls))) ||
110+
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
111+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
112+
}
112113
for (i = 0; i < outdegree; ++i) {
113114
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]);
114115
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

ompi/mpi/c/neighbor_alltoallw.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2015 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2014-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -97,14 +97,15 @@ int MPI_Neighbor_alltoallw(const void *sendbuf, const int sendcounts[], const MP
9797
} else if (! OMPI_COMM_IS_TOPO(comm)) {
9898
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
9999
FUNC_NAME);
100-
} else if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
101-
(NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
102-
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
103-
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
104100
}
105101

106102
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
107103
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
104+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) ||
105+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) ||
106+
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
107+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
108+
}
108109
for (i = 0; i < outdegree; ++i) {
109110
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
110111
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);

0 commit comments

Comments
 (0)