Tpetra parallel linear algebra Version of the Day
Tpetra_Details_DistributorPlan.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// ************************************************************************
38// @HEADER
39
40#ifndef TPETRA_DETAILS_DISTRIBUTOR_PLAN_HPP
41#define TPETRA_DETAILS_DISTRIBUTOR_PLAN_HPP
42
43#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
44#include "Teuchos_Array.hpp"
45#include "Teuchos_Comm.hpp"
46#include "Teuchos_RCP.hpp"
47
48namespace Tpetra {
49namespace Details {
50
51namespace {
52 const bool barrierBetween_default = false;
53 const bool useDistinctTags_default = true;
54}
55
61 DISTRIBUTOR_ISEND, // Use MPI_Isend (Teuchos::isend)
62 DISTRIBUTOR_RSEND, // Use MPI_Rsend (Teuchos::readySend)
63 DISTRIBUTOR_SEND, // Use MPI_Send (Teuchos::send)
64 DISTRIBUTOR_SSEND // Use MPI_Ssend (Teuchos::ssend)
65};
66
71std::string
73
79 DISTRIBUTOR_NOT_INITIALIZED, // Not initialized yet
80 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS, // By createFromSends
81 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_RECVS, // By createFromRecvs
82 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS_N_RECVS, // By createFromSendsAndRecvs
83 DISTRIBUTOR_INITIALIZED_BY_REVERSE, // By createReverseDistributor
84 DISTRIBUTOR_INITIALIZED_BY_COPY, // By copy constructor
85};
86
91std::string
93
109class DistributorPlan : public Teuchos::ParameterListAcceptorDefaultBase {
110public:
111 DistributorPlan(Teuchos::RCP<const Teuchos::Comm<int>> comm);
112 DistributorPlan(const DistributorPlan& otherPlan);
113
118 int getTag(const int pathTag) const;
119
120 size_t createFromSends(const Teuchos::ArrayView<const int>& exportProcIDs);
121 void createFromRecvs(const Teuchos::ArrayView<const int>& remoteProcIDs);
122 void createFromSendsAndRecvs(const Teuchos::ArrayView<const int>& exportProcIDs,
123 const Teuchos::ArrayView<const int>& remoteProcIDs);
124
125 void setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& plist);
126
127 Teuchos::RCP<DistributorPlan> getReversePlan() const;
128
129 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const { return comm_; }
130 EDistributorSendType getSendType() const { return sendType_; }
131 bool barrierBetweenRecvSend() const { return barrierBetweenRecvSend_; }
132 bool useDistinctTags() const { return useDistinctTags_; }
133 size_t getNumReceives() const { return numReceives_; }
134 size_t getNumSends() const { return numSendsToOtherProcs_; }
135 bool hasSelfMessage() const { return sendMessageToSelf_; }
136 size_t getMaxSendLength() const { return maxSendLength_; }
137 size_t getTotalReceiveLength() const { return totalReceiveLength_; }
138 Teuchos::ArrayView<const int> getProcsFrom() const { return procsFrom_; }
139 Teuchos::ArrayView<const int> getProcsTo() const { return procIdsToSendTo_; }
140 Teuchos::ArrayView<const size_t> getLengthsFrom() const { return lengthsFrom_; }
141 Teuchos::ArrayView<const size_t> getLengthsTo() const { return lengthsTo_; }
142 Teuchos::ArrayView<const size_t> getStartsTo() const { return startsTo_; }
143 Teuchos::ArrayView<const size_t> getIndicesTo() const { return indicesTo_; }
144 Details::EDistributorHowInitialized howInitialized() const { return howInitialized_; }
145
146private:
147 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
148
149 void createReversePlan() const;
150
161 void computeReceives();
162
163 Teuchos::RCP<const Teuchos::Comm<int>> comm_;
165 mutable Teuchos::RCP<DistributorPlan> reversePlan_;
166
168
169 EDistributorSendType sendType_;
170 bool barrierBetweenRecvSend_;
171
183 bool useDistinctTags_;
185
186 bool sendMessageToSelf_;
187 size_t numSendsToOtherProcs_;
188 Teuchos::Array<int> procIdsToSendTo_;
189
198 Teuchos::Array<size_t> startsTo_;
199
205 Teuchos::Array<size_t> lengthsTo_;
206
210 size_t maxSendLength_;
211
227 Teuchos::Array<size_t> indicesTo_;
228
238 size_t numReceives_;
239
246 size_t totalReceiveLength_;
247
253 Teuchos::Array<size_t> lengthsFrom_;
254
260 Teuchos::Array<int> procsFrom_;
261
267 Teuchos::Array<size_t> startsFrom_;
268
274 Teuchos::Array<size_t> indicesFrom_;
275};
276
277}
278}
279
280#endif
Implementation details of Tpetra.
std::string DistributorSendTypeEnumToString(EDistributorSendType sendType)
Convert an EDistributorSendType enum value to a string.
EDistributorSendType
The type of MPI send that Distributor should use.
EDistributorHowInitialized
Enum indicating how and whether a Distributor was initialized.
std::string DistributorHowInitializedEnumToString(EDistributorHowInitialized how)
Convert an EDistributorHowInitialized enum value to a string.
Namespace Tpetra contains the class and methods constituting the Tpetra library.