mirror of
https://github.com/boostorg/mpi.git
synced 2026-02-26 04:42:23 +00:00
Add support for MPI intercommunicators
[SVN r37882]
This commit is contained in:
@@ -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 MPI_Comm& comm, comm_create_kind kind)
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ int communicator::rank() const
|
||||
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 @@ communicator communicator::split(int color, int key) const
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user