]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (C) 2007 Trustees of Indiana University |
2 | ||
3 | // Authors: Douglas Gregor | |
4 | // Andrew Lumsdaine | |
5 | ||
6 | // Use, modification and distribution is subject to the Boost Software | |
7 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt) | |
9 | #include <boost/mpi/intercommunicator.hpp> | |
10 | #include <boost/mpi/environment.hpp> | |
11 | #include <boost/mpi/group.hpp> | |
12 | ||
13 | namespace boost { namespace mpi { | |
14 | ||
15 | intercommunicator::intercommunicator(const communicator& local, | |
16 | int local_leader, | |
17 | const communicator& peer, | |
18 | int remote_leader) | |
19 | { | |
20 | MPI_Comm comm; | |
21 | BOOST_MPI_CHECK_RESULT(MPI_Intercomm_create, | |
22 | ((MPI_Comm)local, local_leader, | |
23 | (MPI_Comm)peer, remote_leader, | |
24 | environment::collectives_tag(), &comm)); | |
25 | comm_ptr.reset(new MPI_Comm(comm), comm_free()); | |
26 | } | |
27 | ||
28 | boost::mpi::group intercommunicator::local_group() const | |
29 | { | |
30 | return this->group(); | |
31 | } | |
32 | ||
33 | int intercommunicator::remote_size() const | |
34 | { | |
35 | int size; | |
36 | BOOST_MPI_CHECK_RESULT(MPI_Comm_remote_size, ((MPI_Comm)*this, &size)); | |
37 | return size; | |
38 | } | |
39 | ||
40 | boost::mpi::group intercommunicator::remote_group() const | |
41 | { | |
42 | MPI_Group gr; | |
43 | BOOST_MPI_CHECK_RESULT(MPI_Comm_remote_group, ((MPI_Comm)*this, &gr)); | |
44 | return boost::mpi::group(gr, /*adopt=*/true); | |
45 | } | |
46 | ||
47 | communicator intercommunicator::merge(bool high) const | |
48 | { | |
49 | MPI_Comm comm; | |
50 | BOOST_MPI_CHECK_RESULT(MPI_Intercomm_merge, ((MPI_Comm)*this, high, &comm)); | |
51 | return communicator(comm, comm_take_ownership); | |
52 | } | |
53 | ||
54 | } } // end namespace boost::mpi |