2
0
mirror of https://github.com/boostorg/mpi.git synced 2026-02-25 04:22:17 +00:00

Deal with null communicator when testing topology.

When calling MPI_Topo_test, explicitly deal with MPI_COMM_NULL as it is not a legal value.
Although it is what is return for leftovers process when creating cartesian or graph
communicators.
This commit is contained in:
Alain Miniussi
2015-04-21 16:51:33 +02:00
parent ebae825102
commit 27d0fcff20

View File

@@ -162,20 +162,27 @@ optional<intercommunicator> communicator::as_intercommunicator() const
optional<graph_communicator> communicator::as_graph_communicator() const
{
int status;
BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
if (status == MPI_GRAPH)
return graph_communicator(comm_ptr);
else
return optional<graph_communicator>();
optional<graph_communicator> graph;
// topology test not allowed on MPI_NULL_COMM
if (bool(*this)) {
int status;
BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
if (status == MPI_GRAPH)
graph = graph_communicator(comm_ptr);
}
return graph;
}
bool communicator::has_cartesian_topology() const
{
int status;
BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
return status == MPI_CART;
// topology test not allowed on MPI_NULL_COM
if (!bool(*this)) {
return false;
} else {
int status;
BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
return status == MPI_CART;
}
}
void communicator::abort(int errcode) const