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

Merge pull request #20 from aminiussi/nulltopo

MPI_COMM_NULL is not a valid argument for MPI_Topo_test.
But it is used to indicated leftover processes when creating graph communicator or cartesians grids (for exampl, when you create a 2X2 grid from a 5 process communicator).

So we need to deal with it as a special case.
This commit is contained in:
Alain Miniussi
2014-10-07 10:13:37 +02:00

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