Skip to content

Commit cad4c03

Browse files
authored
Merge pull request #2812 from jjhursey/fix/ibm/basic-neighbor
coll/basic: Expand check for negative input values
2 parents be26152 + 383330a commit cad4c03

11 files changed

+252
-0
lines changed

ompi/mca/coll/basic/coll_basic_neighbor_alltoallw.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* reserved.
1515
* Copyright (c) 2014-2016 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -187,6 +188,7 @@ mca_coll_basic_neighbor_alltoallw_dist_graph(const void *sbuf, const int scounts
187188

188189
indegree = dist_graph->indegree;
189190
outdegree = dist_graph->outdegree;
191+
if( 0 == (indegree + outdegree) ) return OMPI_SUCCESS;
190192

191193
inedges = dist_graph->in;
192194
outedges = dist_graph->out;

ompi/mpi/c/ineighbor_allgather.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -92,6 +95,28 @@ int MPI_Ineighbor_allgather(const void *sendbuf, int sendcount, MPI_Datatype sen
9295
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
9396
}
9497
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
98+
99+
if( OMPI_COMM_IS_CART(comm) ) {
100+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
101+
if( 0 > cart->ndims ) {
102+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
103+
}
104+
}
105+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
106+
int degree;
107+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
108+
if( 0 > degree ) {
109+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
110+
}
111+
}
112+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
113+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
114+
int indegree = dist_graph->indegree;
115+
int outdegree = dist_graph->outdegree;
116+
if( indegree < 0 || outdegree < 0 ) {
117+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
118+
}
119+
}
95120
}
96121

97122
OPAL_CR_ENTER_LIBRARY();

ompi/mpi/c/ineighbor_allgatherv.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -114,6 +117,28 @@ int MPI_Ineighbor_allgatherv(const void *sendbuf, int sendcount, MPI_Datatype se
114117
if (NULL == displs) {
115118
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, FUNC_NAME);
116119
}
120+
121+
if( OMPI_COMM_IS_CART(comm) ) {
122+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
123+
if( 0 > cart->ndims ) {
124+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
125+
}
126+
}
127+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
128+
int degree;
129+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
130+
if( 0 > degree ) {
131+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
132+
}
133+
}
134+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
135+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
136+
int indegree = dist_graph->indegree;
137+
int outdegree = dist_graph->outdegree;
138+
if( indegree < 0 || outdegree < 0 ) {
139+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
140+
}
141+
}
117142
}
118143

119144
OPAL_CR_ENTER_LIBRARY();

ompi/mpi/c/ineighbor_alltoall.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2014-2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -88,6 +91,28 @@ int MPI_Ineighbor_alltoall(const void *sendbuf, int sendcount, MPI_Datatype send
8891
if ((sendtype_size*sendcount) != (recvtype_size*recvcount)) {
8992
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
9093
}
94+
95+
if( OMPI_COMM_IS_CART(comm) ) {
96+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
97+
if( 0 > cart->ndims ) {
98+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
99+
}
100+
}
101+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
102+
int degree;
103+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
104+
if( 0 > degree ) {
105+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
106+
}
107+
}
108+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
109+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
110+
int indegree = dist_graph->indegree;
111+
int outdegree = dist_graph->outdegree;
112+
if( indegree < 0 || outdegree < 0 ) {
113+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
114+
}
115+
}
91116
}
92117

93118
OPAL_CR_ENTER_LIBRARY();

ompi/mpi/c/ineighbor_alltoallv.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2014-2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -112,6 +115,28 @@ int MPI_Ineighbor_alltoallv(const void *sendbuf, const int sendcounts[], const i
112115
OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtype, recvcounts[i]);
113116
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
114117
}
118+
119+
if( OMPI_COMM_IS_CART(comm) ) {
120+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
121+
if( 0 > cart->ndims ) {
122+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
123+
}
124+
}
125+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
126+
int degree;
127+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
128+
if( 0 > degree ) {
129+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
130+
}
131+
}
132+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
133+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
134+
indegree = dist_graph->indegree;
135+
outdegree = dist_graph->outdegree;
136+
if( indegree < 0 || outdegree < 0 ) {
137+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
138+
}
139+
}
115140
}
116141

117142
OPAL_CR_ENTER_LIBRARY();

ompi/mpi/c/ineighbor_alltoallw.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2014-2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -112,6 +115,28 @@ int MPI_Ineighbor_alltoallw(const void *sendbuf, const int sendcounts[], const M
112115
OMPI_CHECK_DATATYPE_FOR_RECV(err, recvtypes[i], recvcounts[i]);
113116
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
114117
}
118+
119+
if( OMPI_COMM_IS_CART(comm) ) {
120+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
121+
if( 0 > cart->ndims ) {
122+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
123+
}
124+
}
125+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
126+
int degree;
127+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
128+
if( 0 > degree ) {
129+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
130+
}
131+
}
132+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
133+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
134+
indegree = dist_graph->indegree;
135+
outdegree = dist_graph->outdegree;
136+
if( indegree < 0 || outdegree < 0 ) {
137+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
138+
}
139+
}
115140
}
116141

117142
OPAL_CR_ENTER_LIBRARY();

ompi/mpi/c/neighbor_allgather.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -92,6 +95,28 @@ int MPI_Neighbor_allgather(const void *sendbuf, int sendcount, MPI_Datatype send
9295
OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount);
9396
}
9497
OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
98+
99+
if( OMPI_COMM_IS_CART(comm) ) {
100+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
101+
if( 0 > cart->ndims ) {
102+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
103+
}
104+
}
105+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
106+
int degree;
107+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
108+
if( 0 > degree ) {
109+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
110+
}
111+
}
112+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
113+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
114+
int indegree = dist_graph->indegree;
115+
int outdegree = dist_graph->outdegree;
116+
if( indegree < 0 || outdegree < 0 ) {
117+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
118+
}
119+
}
95120
}
96121

97122
/* Do we need to do anything? Everyone had to give the same send

ompi/mpi/c/neighbor_allgatherv.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* reserved.
1717
* Copyright (c) 2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -32,6 +33,8 @@
3233
#include "ompi/errhandler/errhandler.h"
3334
#include "ompi/datatype/ompi_datatype.h"
3435
#include "ompi/memchecker.h"
36+
#include "ompi/mca/topo/topo.h"
37+
#include "ompi/mca/topo/base/base.h"
3538

3639
#if OMPI_BUILD_MPI_PROFILING
3740
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -114,6 +117,28 @@ int MPI_Neighbor_allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sen
114117
if (NULL == displs) {
115118
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_BUFFER, FUNC_NAME);
116119
}
120+
121+
if( OMPI_COMM_IS_CART(comm) ) {
122+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
123+
if( 0 > cart->ndims ) {
124+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
125+
}
126+
}
127+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
128+
int degree;
129+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
130+
if( 0 > degree ) {
131+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
132+
}
133+
}
134+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
135+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
136+
int indegree = dist_graph->indegree;
137+
int outdegree = dist_graph->outdegree;
138+
if( indegree < 0 || outdegree < 0 ) {
139+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
140+
}
141+
}
117142
}
118143

119144
/* Do we need to do anything? Everyone had to give the same

ompi/mpi/c/neighbor_alltoall.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2014-2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -31,6 +32,8 @@
3132
#include "ompi/errhandler/errhandler.h"
3233
#include "ompi/datatype/ompi_datatype.h"
3334
#include "ompi/memchecker.h"
35+
#include "ompi/mca/topo/topo.h"
36+
#include "ompi/mca/topo/base/base.h"
3437

3538
#if OMPI_BUILD_MPI_PROFILING
3639
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -87,6 +90,28 @@ int MPI_Neighbor_alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendt
8790
if ((sendtype_size*sendcount) != (recvtype_size*recvcount)) {
8891
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TRUNCATE, FUNC_NAME);
8992
}
93+
94+
if( OMPI_COMM_IS_CART(comm) ) {
95+
const mca_topo_base_comm_cart_2_2_0_t *cart = comm->c_topo->mtc.cart;
96+
if( 0 > cart->ndims ) {
97+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
98+
}
99+
}
100+
else if( OMPI_COMM_IS_GRAPH(comm) ) {
101+
int degree;
102+
mca_topo_base_graph_neighbors_count(comm, ompi_comm_rank(comm), &degree);
103+
if( 0 > degree ) {
104+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
105+
}
106+
}
107+
else if( OMPI_COMM_IS_DIST_GRAPH(comm) ) {
108+
const mca_topo_base_comm_dist_graph_2_2_0_t *dist_graph = comm->c_topo->mtc.dist_graph;
109+
int indegree = dist_graph->indegree;
110+
int outdegree = dist_graph->outdegree;
111+
if( indegree < 0 || outdegree < 0 ) {
112+
return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
113+
}
114+
}
90115
}
91116

92117
/* Do we need to do anything? */

0 commit comments

Comments
 (0)