From 8cd257f4cbd698e14c15ff819e458b541e8dc42e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 1 Jun 2007 18:22:00 +0000 Subject: [PATCH] Document graph topologies, implement layer over MPI_Topo_test [SVN r37853] --- doc/mpi.qbk | 36 ++++++++++++++++++++-------- include/boost/mpi/communicator.hpp | 15 ++++++++++++ include/boost/mpi/graph_topology.hpp | 8 +++++++ src/communicator.cpp | 16 +++++++++++++ 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/doc/mpi.qbk b/doc/mpi.qbk index 08f7c95..7e45da5 100644 --- a/doc/mpi.qbk +++ b/doc/mpi.qbk @@ -1486,27 +1486,41 @@ Boost.MPI currently provides no support for attribute caching. `MPI_Attr_delete`]] [unsupported]] ] -Boost.MPI currently provides no support for process topologies. +Boost.MPI will provide complete support for creating communicators +with different topologies and later querying those topologies. Support +for graph topologies is provided via an interface to the +[@http://www.boost.org/libs/graph/doc/index.html Boost Graph Library +(BGL)], where a communicator can be created which matches the +structure of any BGL graph, and the graph topology of a communicator +can be viewed as a BGL graph for use in existing, generic graph +algorithms. [table Process topologies [[C Function/Constant] [Boost.MPI Equivalent]] - [[`MPI_GRAPH`] [unsupported]] - [[`MPI_CART`] [unsupported]] - [[`MPI_UNDEFINED`] [unsupported]] + [[`MPI_GRAPH`] [unnecessary; use [memberref boost::mpi::communicator::has_graph_topology `communicator::has_graph_topology`]]] + [[`MPI_CART`] [unnecessary; use [memberref boost::mpi::communicator::has_cartesian_topology `communicator::has_cartesian_topology`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node133.html#Node133 `MPI_Cart_create`]] [unsupported]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node134.html#Node134 `MPI_Dims_create`]] [unsupported]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node135.html#Node135 - `MPI_Graph_create`]] [unsupported]] + `MPI_Graph_create`]] [[memberref + boost::mpi::communicator::with_graph_topology + `communicator::with_graph_topology`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 - `MPI_Topo_test`]] [unsupported]] + `MPI_Topo_test`]] [[memberref + boost::mpi::communicator::has_graph_topology + `communicator::has_graph_topology`], [memberref + boost::mpi::communicator::has_cartesian_topology + `communicator::has_cartesian_topology`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 - `MPI_Graphdims_get`]] [unsupported]] + `MPI_Graphdims_get`]] [[funcref boost::mpi::num_vertices + `num_vertices`], [funcref boost::mpi::num_edges `num_edges`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 - `MPI_Graph_get`]] [unsupported]] + `MPI_Graph_get`]] [[funcref boost::mpi::vertices + `vertices`], [funcref boost::mpi::edges `edges`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 `MPI_Cartdim_get`]] [unsupported]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 @@ -1516,9 +1530,11 @@ Boost.MPI currently provides no support for process topologies. [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 `MPI_Cart_coords`]] [unsupported]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 - `MPI_Graph_neighbors_count`]] [unsupported]] + `MPI_Graph_neighbors_count`]] [[funcref boost::mpi::out_degree + `out_degree`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node136.html#Node136 - `MPI_Graph_neighbors`]] [unsupported]] + `MPI_Graph_neighbors`]] [[funcref boost::mpi::out_edges + `out_edges`], [funcref boost::mpi::adjacent_vertices `adjacent_vertices`]]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node137.html#Node137 `MPI_Cart_shift`]] [unsupported]] [[[@http://www.mpi-forum.org/docs/mpi-11-html/node138.html#Node138 diff --git a/include/boost/mpi/communicator.hpp b/include/boost/mpi/communicator.hpp index 866e447..2a92653 100644 --- a/include/boost/mpi/communicator.hpp +++ b/include/boost/mpi/communicator.hpp @@ -766,6 +766,21 @@ class communicator */ communicator split(int color, int key) const; + /** + * Determines whether this communicator has a Cartesian topology. + */ + bool has_cartesian_topology() const; + + /** + * Determines whether this communicator has a graph topology. If + * the communicator does have a graph topology, the communicator + * itself can be viewed as a graph by the algorithms in the Boost + * Graph Library. The communicator then meets the requirements of + * the @c Graph, @c Incidence Graph, @c Adjacency Graph, @c Vertex + * List Graph, and @c Edge List Graph concepts. + */ + bool has_graph_topology() const; + /** * Create a new communicator whose topology is described by the * given graph. The vertex index map (@p index) gives the mapping diff --git a/include/boost/mpi/graph_topology.hpp b/include/boost/mpi/graph_topology.hpp index 268a0b1..2d1021b 100644 --- a/include/boost/mpi/graph_topology.hpp +++ b/include/boost/mpi/graph_topology.hpp @@ -377,6 +377,10 @@ struct graph_traits { { }; + /** + * @brief Returns a vertex descriptor that can never refer to any + * valid vertex. + */ static vertex_descriptor null_vertex() { return -1; } // Incidence Graph requirements @@ -396,6 +400,10 @@ struct graph_traits { }; // Property Graph requirements + +/** + * INTERNAL ONLY + */ template<> struct property_map { diff --git a/src/communicator.cpp b/src/communicator.cpp index c9f6855..243d0de 100644 --- a/src/communicator.cpp +++ b/src/communicator.cpp @@ -141,6 +141,22 @@ communicator communicator::split(int color, int key) const return communicator(newcomm, comm_take_ownership); } +bool communicator::has_cartesian_topology() const +{ + int status; + BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status)); + + return status == MPI_CART; +} + +bool communicator::has_graph_topology() const +{ + int status; + BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status)); + + return status == MPI_GRAPH; +} + void communicator::abort(int errcode) const { BOOST_MPI_CHECK_RESULT(MPI_Abort, (MPI_Comm(*this), errcode));