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

Modified Files:
        communicator.cpp group.cpp 
Added Files:
        intercommunicator.cpp 
Log Message:
Add support for MPI intercommunicators

--- NEW FILE: intercommunicator.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/intercommunicator.hpp>
#include <boost/mpi/environment.hpp>
#include <boost/mpi/group.hpp>

namespace boost { namespace mpi {

intercommunicator::intercommunicator(const communicator& local, 
                                     int local_leader,
                                     const communicator& peer, 
                                     int remote_leader)
{
  MPI_Comm comm;
  BOOST_MPI_CHECK_RESULT(MPI_Intercomm_create,
                         ((MPI_Comm)local, local_leader,
                          (MPI_Comm)peer, remote_leader,
                          environment::collectives_tag(), &comm));
  comm_ptr.reset(new MPI_Comm(comm), comm_free());
}

boost::mpi::group intercommunicator::local_group() const
{
  return this->group();
}

int intercommunicator::remote_size() const
{
  int size;
  BOOST_MPI_CHECK_RESULT(MPI_Comm_remote_size, ((MPI_Comm)*this, &size));
  return size;
}

boost::mpi::group intercommunicator::remote_group() const
{
  MPI_Group gr;
  BOOST_MPI_CHECK_RESULT(MPI_Comm_remote_group, ((MPI_Comm)*this, &gr));
  return boost::mpi::group(gr, /*adopt=*/true);
}

communicator intercommunicator::merge(bool high) const
{
  MPI_Comm comm;
  BOOST_MPI_CHECK_RESULT(MPI_Intercomm_merge, ((MPI_Comm)*this, high, &comm));
  return communicator(comm, comm_take_ownership);
}

} } // end namespace boost::mpi

Index: communicator.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/mpi/src/communicator.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- communicator.cpp    1 Jun 2007 18:22:00 -0000       1.3
+++ communicator.cpp    4 Jun 2007 14:49:13 -0000       1.4
@@ -5,6 +5,7 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 #include <boost/mpi/communicator.hpp>
 #include <boost/mpi/group.hpp>
+#include <boost/mpi/intercommunicator.hpp>
 #include <boost/mpi/skeleton_and_content.hpp>
 #include <boost/mpi/detail/point_to_point.hpp>
 
@@ -55,7 +56,8 @@
   }
 }
 
-communicator::communicator(const communicator& comm, const group& subgroup)
+communicator::communicator(const communicator& comm, 
+                           const boost::mpi::group& subgroup)
 {
   MPI_Comm newcomm;
   BOOST_MPI_CHECK_RESULT(MPI_Comm_create, 
@@ -77,6 +79,13 @@
   return rank_;
 }
 
+boost::mpi::group communicator::group() const
+{
+  MPI_Group gr;
+  BOOST_MPI_CHECK_RESULT(MPI_Comm_group, ((MPI_Comm)*this, &gr));
+  return boost::mpi::group(gr, /*adopt=*/true);
+}
+
 void communicator::send(int dest, int tag) const
 {
   BOOST_MPI_CHECK_RESULT(MPI_Send,
@@ -141,6 +150,16 @@
   return communicator(newcomm, comm_take_ownership);
 }
 
+optional<intercommunicator> communicator::as_intercommunicator() const
+{
+  int flag;
+  BOOST_MPI_CHECK_RESULT(MPI_Comm_test_inter, ((MPI_Comm)*this, &flag));
+  if (flag)
+    return intercommunicator(comm_ptr);
+  else
+    return optional<intercommunicator>();
+}
+
 bool communicator::has_cartesian_topology() const
 {
   int status;

Index: group.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/mpi/src/group.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- group.cpp   31 May 2007 15:36:48 -0000      1.1
+++ group.cpp   4 Jun 2007 14:49:13 -0000       1.2
@@ -19,15 +19,6 @@
   }
 }
 
-group::group(const communicator& comm)
-{
-  MPI_Group gr;
-  BOOST_MPI_CHECK_RESULT(MPI_Comm_group, ((MPI_Comm)comm, &gr));
-
-  if (gr != MPI_GROUP_EMPTY)
-    group_ptr.reset(new MPI_Group(gr), group_free());
-}
-
 optional<int> group::rank() const
 {
   if (!group_ptr)


-------------------------------------------------------------------------
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