Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
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#include "TpetraCore_config.h"
48
49namespace Tpetra {
50namespace Details {
51
57 DISTRIBUTOR_ISEND, // Use MPI_Isend (Teuchos::isend)
58 DISTRIBUTOR_SEND, // Use MPI_Send (Teuchos::send)
59 DISTRIBUTOR_ALLTOALL // Use MPI_Alltoall
60};
61
66std::string
68
74 DISTRIBUTOR_NOT_INITIALIZED, // Not initialized yet
75 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS, // By createFromSends
76 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_RECVS, // By createFromRecvs
77 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS_N_RECVS, // By createFromSendsAndRecvs
78 DISTRIBUTOR_INITIALIZED_BY_REVERSE, // By createReverseDistributor
79 DISTRIBUTOR_INITIALIZED_BY_COPY, // By copy constructor
80};
81
86std::string
88
99class DistributorPlan : public Teuchos::ParameterListAcceptorDefaultBase {
100 static constexpr int DEFAULT_MPI_TAG = 0;
101
102public:
103 DistributorPlan(Teuchos::RCP<const Teuchos::Comm<int>> comm);
105
106 size_t createFromSends(const Teuchos::ArrayView<const int>& exportProcIDs);
107 void createFromRecvs(const Teuchos::ArrayView<const int>& remoteProcIDs);
108 void createFromSendsAndRecvs(const Teuchos::ArrayView<const int>& exportProcIDs,
109 const Teuchos::ArrayView<const int>& remoteProcIDs);
110
111 void setParameterList(const Teuchos::RCP<Teuchos::ParameterList>& plist);
112
113 Teuchos::RCP<DistributorPlan> getReversePlan() const;
114
115 Teuchos::RCP<const Teuchos::Comm<int>> getComm() const { return comm_; }
116 EDistributorSendType getSendType() const { return sendType_; }
117 size_t getNumReceives() const { return numReceives_; }
118 size_t getNumSends() const { return numSendsToOtherProcs_; }
119 bool hasSelfMessage() const { return sendMessageToSelf_; }
120 size_t getMaxSendLength() const { return maxSendLength_; }
121 size_t getTotalReceiveLength() const { return totalReceiveLength_; }
122 Teuchos::ArrayView<const int> getProcsFrom() const { return procsFrom_; }
123 Teuchos::ArrayView<const int> getProcsTo() const { return procIdsToSendTo_; }
124 Teuchos::ArrayView<const size_t> getLengthsFrom() const { return lengthsFrom_; }
125 Teuchos::ArrayView<const size_t> getLengthsTo() const { return lengthsTo_; }
126 Teuchos::ArrayView<const size_t> getStartsTo() const { return startsTo_; }
127 Teuchos::ArrayView<const size_t> getIndicesTo() const { return indicesTo_; }
128 Details::EDistributorHowInitialized howInitialized() const { return howInitialized_; }
129
130private:
131 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
132
133 void createReversePlan() const;
134
145 void computeReceives();
146
147 Teuchos::RCP<const Teuchos::Comm<int>> comm_;
149 mutable Teuchos::RCP<DistributorPlan> reversePlan_;
150
152
153 EDistributorSendType sendType_;
155
156 bool sendMessageToSelf_;
157 size_t numSendsToOtherProcs_;
158 Teuchos::Array<int> procIdsToSendTo_;
159
168 Teuchos::Array<size_t> startsTo_;
169
175 Teuchos::Array<size_t> lengthsTo_;
176
180 size_t maxSendLength_;
181
197 Teuchos::Array<size_t> indicesTo_;
198
208 size_t numReceives_;
209
216 size_t totalReceiveLength_;
217
223 Teuchos::Array<size_t> lengthsFrom_;
224
230 Teuchos::Array<int> procsFrom_;
231
237 Teuchos::Array<size_t> startsFrom_;
238
244 Teuchos::Array<size_t> indicesFrom_;
245};
246
247}
248}
249
250#endif
Struct that holds views of the contents of a CrsMatrix.
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.