annotate DEPENDENCIES/generic/include/boost/mpi/intercommunicator.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (C) 2007 The Trustees of Indiana University.
Chris@16 2
Chris@16 3 // Authors: Douglas Gregor
Chris@16 4 // Andrew Lumsdaine
Chris@16 5
Chris@16 6 // Use, modification and distribution is subject to the Boost Software
Chris@16 7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 8 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9
Chris@16 10 /** @file intercommunicator.hpp
Chris@16 11 *
Chris@16 12 * This header defines the @c intercommunicator class, which permits
Chris@16 13 * communication between different process groups.
Chris@16 14 */
Chris@16 15 #ifndef BOOST_MPI_INTERCOMMUNICATOR_HPP
Chris@16 16 #define BOOST_MPI_INTERCOMMUNICATOR_HPP
Chris@16 17
Chris@16 18 #include <boost/mpi/communicator.hpp>
Chris@16 19
Chris@16 20 namespace boost { namespace mpi {
Chris@16 21
Chris@16 22 /**
Chris@16 23 * INTERNAL ONLY
Chris@16 24 *
Chris@16 25 * Forward declaration of the MPI "group" representation, for use in
Chris@16 26 * the description of the @c intercommunicator class.
Chris@16 27 */
Chris@16 28 class group;
Chris@16 29
Chris@16 30 /**
Chris@16 31 * @brief Communication facilities among processes in different
Chris@16 32 * groups.
Chris@16 33 *
Chris@16 34 * The @c intercommunicator class provides communication facilities
Chris@16 35 * among processes from different groups. An intercommunicator is
Chris@16 36 * always associated with two process groups: one "local" process
Chris@16 37 * group, containing the process that initiates an MPI operation
Chris@16 38 * (e.g., the sender in a @c send operation), and one "remote" process
Chris@16 39 * group, containing the process that is the target of the MPI
Chris@16 40 * operation.
Chris@16 41 *
Chris@16 42 * While intercommunicators have essentially the same point-to-point
Chris@16 43 * operations as intracommunicators (the latter communicate only
Chris@16 44 * within a single process group), all communication with
Chris@16 45 * intercommunicators occurs between the processes in the local group
Chris@16 46 * and the processes in the remote group; communication within a group
Chris@16 47 * must use a different (intra-)communicator.
Chris@16 48 *
Chris@16 49 */
Chris@16 50 class BOOST_MPI_DECL intercommunicator : public communicator
Chris@16 51 {
Chris@16 52 private:
Chris@16 53 friend class communicator;
Chris@16 54
Chris@16 55 /**
Chris@16 56 * INTERNAL ONLY
Chris@16 57 *
Chris@16 58 * Construct an intercommunicator given a shared pointer to the
Chris@16 59 * underlying MPI_Comm. This operation is used for "casting" from a
Chris@16 60 * communicator to an intercommunicator.
Chris@16 61 */
Chris@16 62 explicit intercommunicator(const shared_ptr<MPI_Comm>& cp)
Chris@16 63 {
Chris@16 64 this->comm_ptr = cp;
Chris@16 65 }
Chris@16 66
Chris@16 67 public:
Chris@16 68 /**
Chris@16 69 * Build a new Boost.MPI intercommunicator based on the MPI
Chris@16 70 * intercommunicator @p comm.
Chris@16 71 *
Chris@16 72 * @p comm may be any valid MPI intercommunicator. If @p comm is
Chris@16 73 * MPI_COMM_NULL, an empty communicator (that cannot be used for
Chris@16 74 * communication) is created and the @p kind parameter is
Chris@16 75 * ignored. Otherwise, the @p kind parameter determines how the
Chris@16 76 * Boost.MPI communicator will be related to @p comm:
Chris@16 77 *
Chris@16 78 * - If @p kind is @c comm_duplicate, duplicate @c comm to create
Chris@16 79 * a new communicator. This new communicator will be freed when
Chris@16 80 * the Boost.MPI communicator (and all copies of it) is
Chris@16 81 * destroyed. This option is only permitted if the underlying MPI
Chris@16 82 * implementation supports MPI 2.0; duplication of
Chris@16 83 * intercommunicators is not available in MPI 1.x.
Chris@16 84 *
Chris@16 85 * - If @p kind is @c comm_take_ownership, take ownership of @c
Chris@16 86 * comm. It will be freed automatically when all of the Boost.MPI
Chris@16 87 * communicators go out of scope.
Chris@16 88 *
Chris@16 89 * - If @p kind is @c comm_attach, this Boost.MPI communicator
Chris@16 90 * will reference the existing MPI communicator @p comm but will
Chris@16 91 * not free @p comm when the Boost.MPI communicator goes out of
Chris@16 92 * scope. This option should only be used when the communicator is
Chris@16 93 * managed by the user.
Chris@16 94 */
Chris@16 95 intercommunicator(const MPI_Comm& comm, comm_create_kind kind)
Chris@16 96 : communicator(comm, kind) { }
Chris@16 97
Chris@16 98 /**
Chris@16 99 * Constructs a new intercommunicator whose local group is @p local
Chris@16 100 * and whose remote group is @p peer. The intercommunicator can then
Chris@16 101 * be used to communicate between processes in the two groups. This
Chris@16 102 * constructor is equivalent to a call to @c MPI_Intercomm_create.
Chris@16 103 *
Chris@16 104 * @param local The intracommunicator containing all of the
Chris@16 105 * processes that will go into the local group.
Chris@16 106 *
Chris@16 107 * @param local_leader The rank within the @p local
Chris@16 108 * intracommunicator that will serve as its leader.
Chris@16 109 *
Chris@16 110 * @param peer The intracommunicator containing all of the processes
Chris@16 111 * that will go into the remote group.
Chris@16 112 *
Chris@16 113 * @param remote_leader The rank within the @p peer group that will
Chris@16 114 * serve as its leader.
Chris@16 115 */
Chris@16 116 intercommunicator(const communicator& local, int local_leader,
Chris@16 117 const communicator& peer, int remote_leader);
Chris@16 118
Chris@16 119 /**
Chris@16 120 * Returns the size of the local group, i.e., the number of local
Chris@16 121 * processes that are part of the group.
Chris@16 122 */
Chris@16 123 int local_size() const { return this->size(); }
Chris@16 124
Chris@16 125 /**
Chris@16 126 * Returns the local group, containing all of the local processes in
Chris@16 127 * this intercommunicator.
Chris@16 128 */
Chris@16 129 boost::mpi::group local_group() const;
Chris@16 130
Chris@16 131 /**
Chris@16 132 * Returns the rank of this process within the local group.
Chris@16 133 */
Chris@16 134 int local_rank() const { return this->rank(); }
Chris@16 135
Chris@16 136 /**
Chris@16 137 * Returns the size of the remote group, i.e., the number of
Chris@16 138 * processes that are part of the remote group.
Chris@16 139 */
Chris@16 140 int remote_size() const;
Chris@16 141
Chris@16 142 /**
Chris@16 143 * Returns the remote group, containing all of the remote processes
Chris@16 144 * in this intercommunicator.
Chris@16 145 */
Chris@16 146 boost::mpi::group remote_group() const;
Chris@16 147
Chris@16 148 /**
Chris@16 149 * Merge the local and remote groups in this intercommunicator into
Chris@16 150 * a new intracommunicator containing the union of the processes in
Chris@16 151 * both groups. This method is equivalent to @c MPI_Intercomm_merge.
Chris@16 152 *
Chris@16 153 * @param high Whether the processes in this group should have the
Chris@16 154 * higher rank numbers than the processes in the other group. Each
Chris@16 155 * of the processes within a particular group shall have the same
Chris@16 156 * "high" value.
Chris@16 157 *
Chris@16 158 * @returns the new, merged intracommunicator
Chris@16 159 */
Chris@16 160 communicator merge(bool high) const;
Chris@16 161 };
Chris@16 162
Chris@16 163 } } // end namespace boost::mpi
Chris@16 164
Chris@16 165 #endif // BOOST_MPI_INTERCOMMUNICATOR_HPP