Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Details_DistributorPlan.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
22#ifndef TPETRA_DETAILS_DISTRIBUTOR_PLAN_HPP
23#define TPETRA_DETAILS_DISTRIBUTOR_PLAN_HPP
24
25#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
26#include "Teuchos_Array.hpp"
27#include "Teuchos_Comm.hpp"
28#include "Teuchos_RCP.hpp"
29#include "TpetraCore_config.h"
30
31#if defined(HAVE_TPETRACORE_MPI_ADVANCE)
32#include <mpi_advance.h>
33#endif
34
35namespace Tpetra {
36namespace Details {
37
43 DISTRIBUTOR_ISEND, // Use MPI_Isend (Teuchos::isend)
44 DISTRIBUTOR_SEND, // Use MPI_Send (Teuchos::send)
45 DISTRIBUTOR_ALLTOALL // Use MPI_Alltoall
46#if defined(HAVE_TPETRA_MPI)
47 ,
49#endif
50#if defined(HAVE_TPETRACORE_MPI_ADVANCE)
51 ,
54#endif
55};
56
61std::string
63
66DistributorSendTypeStringToEnum(const std::string_view s);
67
69Teuchos::Array<std::string> distributorSendTypes();
70
72Teuchos::Array<EDistributorSendType> distributorSendTypeEnums();
73
75Teuchos::Array<std::string> distributorSendTypes();
76
78const std::string& validSendTypeOrThrow(const std::string& s);
79
85 DISTRIBUTOR_NOT_INITIALIZED, // Not initialized yet
86 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS, // By createFromSends
87 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_RECVS, // By createFromRecvs
88 DISTRIBUTOR_INITIALIZED_BY_CREATE_FROM_SENDS_N_RECVS, // By createFromSendsAndRecvs
89 DISTRIBUTOR_INITIALIZED_BY_REVERSE, // By createReverseDistributor
90 DISTRIBUTOR_INITIALIZED_BY_COPY, // By copy constructor
91};
92
97std::string
99
110class DistributorPlan : public Teuchos::ParameterListAcceptorDefaultBase {
111 static constexpr int DEFAULT_MPI_TAG = 0;
112
113 public:
114 using IndexView = std::vector<size_t>;
115 using SubViewLimits = std::pair<IndexView, IndexView>;
116
117 DistributorPlan(Teuchos::RCP<const Teuchos::Comm<int>> comm);
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#if defined(HAVE_TPETRACORE_MPI_ADVANCE)
131 Teuchos::RCP<MPIX_Comm*> getMPIXComm() const { return mpixComm_; }
132#endif
133 EDistributorSendType getSendType() const { return sendType_; }
134 size_t getNumReceives() const { return numReceives_; }
135 size_t getNumSends() const { return numSendsToOtherProcs_; }
136 bool hasSelfMessage() const { return sendMessageToSelf_; }
137 size_t getMaxSendLength() const { return maxSendLength_; }
138 size_t getTotalReceiveLength() const { return totalReceiveLength_; }
139 Teuchos::ArrayView<const int> getProcsFrom() const { return procsFrom_; }
140 Teuchos::ArrayView<const int> getProcsTo() const { return procIdsToSendTo_; }
141 Teuchos::ArrayView<const size_t> getLengthsFrom() const { return lengthsFrom_; }
142 Teuchos::ArrayView<const size_t> getLengthsTo() const { return lengthsTo_; }
143 Teuchos::ArrayView<const size_t> getStartsTo() const { return startsTo_; }
144 Teuchos::ArrayView<const size_t> getIndicesTo() const { return indicesTo_; }
145 Details::EDistributorHowInitialized howInitialized() const { return howInitialized_; }
146
147 SubViewLimits getImportViewLimits(size_t numPackets) const;
148 SubViewLimits getImportViewLimits(const Teuchos::ArrayView<const size_t>& numImportPacketsPerLID) const;
149 SubViewLimits getExportViewLimits(size_t numPackets) const;
150 SubViewLimits getExportViewLimits(const Teuchos::ArrayView<const size_t>& numExportPacketsPerLID) const;
151
152#if defined(HAVE_TPETRA_MPI)
153 const std::vector<int> getRoots() const {
154 return roots_;
155 }
156#endif
157 private:
158 // after the plan has been created we have the info we need to initialize the MPI advance communicator
159#if defined(HAVE_TPETRACORE_MPI_ADVANCE)
161#endif
162
163#if defined(HAVE_TPETRA_MPI)
165#endif
166
167 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
168
169 void createReversePlan() const;
170
181 void computeReceives();
182
183 Teuchos::RCP<const Teuchos::Comm<int>> comm_;
184#if defined(HAVE_TPETRACORE_MPI_ADVANCE)
185 Teuchos::RCP<MPIX_Comm*> mpixComm_;
186#endif
187
189 mutable Teuchos::RCP<DistributorPlan> reversePlan_;
190
192
193 EDistributorSendType sendType_;
195
196 bool sendMessageToSelf_;
197 size_t numSendsToOtherProcs_;
198 Teuchos::Array<int> procIdsToSendTo_;
199
208 Teuchos::Array<size_t> startsTo_;
209
215 Teuchos::Array<size_t> lengthsTo_;
216
220 size_t maxSendLength_;
221
237 Teuchos::Array<size_t> indicesTo_;
238
248 size_t numReceives_;
249
256 size_t totalReceiveLength_;
257
263 Teuchos::Array<size_t> lengthsFrom_;
264
270 Teuchos::Array<int> procsFrom_;
271
277 Teuchos::Array<size_t> startsFrom_;
278
284 Teuchos::Array<size_t> indicesFrom_;
285
286#if defined(HAVE_TPETRA_MPI)
291 std::vector<int> roots_;
292
293#endif
294};
295
296} // namespace Details
297} // namespace Tpetra
298
299#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.
Teuchos::Array< EDistributorSendType > distributorSendTypeEnums()
Valid enum values of distributor send types.
Teuchos::Array< std::string > distributorSendTypes()
Valid string values for Distributor's "Send type" parameter.
EDistributorSendType DistributorSendTypeStringToEnum(const std::string_view s)
Convert a string to an EDistributorSendType. Throw on error.
const std::string & validSendTypeOrThrow(const std::string &s)
Valid enum values of distributor send types.
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.