Skip to content

Commit 7005e46

Browse files
authored
Merge pull request #6782 from ggouaillardet/topic/neighbor_alltoallv
mpi/c: fix param checks in [I]Neighbor_alltoall{v,w}
2 parents 5cb3932 + 5655d64 commit 7005e46

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
*
@@ -101,14 +101,15 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
101101
} else if (! OMPI_COMM_IS_TOPO(comm)) {
102102
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_TOPOLOGY,
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/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
*
@@ -101,14 +101,13 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
101101
FUNC_NAME);
102102
}
103103

104-
if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) ||
105-
(NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes) ||
104+
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
105+
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
106+
if (((0 < outdegree) && ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes))) ||
107+
((0 < indegree) && ((NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes))) ||
106108
MPI_IN_PLACE == sendbuf || MPI_IN_PLACE == recvbuf) {
107109
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
108110
}
109-
110-
err = mca_topo_base_neighbor_count (comm, &indegree, &outdegree);
111-
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
112111
for (i = 0; i < outdegree; ++i) {
113112
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]);
114113
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)