Update of /cvsroot/boost/boost/libs/mpi/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28215/libs/mpi/src

Modified Files:
        communicator.cpp 
Added Files:
        graph_communicator.cpp 
Removed Files:
        graph_topology.cpp 
Log Message:
Create a separate graph_communicator type to handle graph topologies

--- NEW FILE: graph_communicator.cpp ---
// Copyright (C) 2007 Trustees of Indiana University

// Authors: Douglas Gregor
//          Andrew Lumsdaine

// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/mpi/graph_communicator.hpp>

namespace boost { namespace mpi {

// Incidence Graph requirements
std::pair<detail::comm_out_edge_iterator, detail::comm_out_edge_iterator>
out_edges(int vertex, const graph_communicator& comm)
{
  int nneighbors = out_degree(vertex, comm);
  shared_array<int> neighbors(new int[nneighbors]);
  BOOST_MPI_CHECK_RESULT(MPI_Graph_neighbors, 
                         ((MPI_Comm)comm, vertex, nneighbors, neighbors.get()));
  return std::make_pair(detail::comm_out_edge_iterator(vertex, neighbors, 0),
                        detail::comm_out_edge_iterator(vertex, neighbors, 
                                                       nneighbors));
}

int out_degree(int vertex, const graph_communicator& comm)
{
  int nneighbors;
  BOOST_MPI_CHECK_RESULT(MPI_Graph_neighbors_count, 
                         ((MPI_Comm)comm, vertex, &nneighbors));
  return nneighbors;
}

// Adjacency Graph requirements
std::pair<detail::comm_adj_iterator, detail::comm_adj_iterator>
adjacent_vertices(int vertex, const graph_communicator& comm)
{
  int nneighbors = out_degree(vertex, comm);
  shared_array<int> neighbors(new int[nneighbors]);
  BOOST_MPI_CHECK_RESULT(MPI_Graph_neighbors, 
                         ((MPI_Comm)comm, vertex, nneighbors, neighbors.get()));
  return std::make_pair(detail::comm_adj_iterator(neighbors, 0),
                        detail::comm_adj_iterator(neighbors, nneighbors));
}

// Edge List Graph requirements
std::pair<detail::comm_edge_iterator, detail::comm_edge_iterator>
edges(const graph_communicator& comm);

std::pair<detail::comm_edge_iterator, detail::comm_edge_iterator>
edges(const graph_communicator& comm)
{
  int nnodes, nedges;
  BOOST_MPI_CHECK_RESULT(MPI_Graphdims_get, ((MPI_Comm)comm, &nnodes, &nedges));

  shared_array<int> indices(new int[nnodes]);
  shared_array<int> edges(new int[nedges]);
  BOOST_MPI_CHECK_RESULT(MPI_Graph_get,
                         ((MPI_Comm)comm, nnodes, nedges, 
                          indices.get(), edges.get()));
  return std::make_pair(detail::comm_edge_iterator(indices, edges),
                        detail::comm_edge_iterator(nedges));
}


int num_edges(const graph_communicator& comm)
{
  int nnodes, nedges;
  BOOST_MPI_CHECK_RESULT(MPI_Graphdims_get, ((MPI_Comm)comm, &nnodes, &nedges));
  return nedges;
}

} } // end namespace boost::mpi

Index: communicator.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/mpi/src/communicator.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- communicator.cpp    4 Jun 2007 14:49:13 -0000       1.4
+++ communicator.cpp    5 Jun 2007 00:54:56 -0000       1.5
@@ -6,6 +6,7 @@
 #include <boost/mpi/communicator.hpp>
 #include <boost/mpi/group.hpp>
 #include <boost/mpi/intercommunicator.hpp>
+#include <boost/mpi/graph_communicator.hpp>
 #include <boost/mpi/skeleton_and_content.hpp>
 #include <boost/mpi/detail/point_to_point.hpp>
 
@@ -160,20 +161,22 @@
     return optional<intercommunicator>();
 }
 
-bool communicator::has_cartesian_topology() const
+optional<graph_communicator> communicator::as_graph_communicator() const
 {
   int status;
   BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
-
-  return status == MPI_CART;
+  if (status == MPI_GRAPH)
+    return graph_communicator(comm_ptr);
+  else
+    return optional<graph_communicator>();
 }
 
-bool communicator::has_graph_topology() const
+bool communicator::has_cartesian_topology() const
 {
   int status;
   BOOST_MPI_CHECK_RESULT(MPI_Topo_test, ((MPI_Comm)*this, &status));
 
-  return status == MPI_GRAPH;
+  return status == MPI_CART;
 }
 
 void communicator::abort(int errcode) const

--- graph_topology.cpp DELETED ---


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to