Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_DirectoryImpl_decl.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
10#ifndef __Tpetra_DirectoryImpl_decl_hpp
11#define __Tpetra_DirectoryImpl_decl_hpp
12
15
16#include "Tpetra_TieBreak.hpp"
17#include "Tpetra_Map_fwd.hpp"
18
19//
20// mfh 13-15 May 2013: HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX governs
21// the fix for Bug 5822. The fix is enabled by default. To disable
22// the fix, uncomment out the three lines below that undefine
23// HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX, and comment out the three
24// lines below them that define that macro.
25//
26// mfh 23 Mar 2014: I want Bug 5822 to stay fixed, so I am removing
27// all references to HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX. I hope no
28// downstream code is using that macro, but just in case, I will leave
29// it defined.
30
31#ifndef HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX
32#define HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX 1
33#endif // HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX
34
35#include "Tpetra_Details_FixedHashTable_decl.hpp"
36
37#ifndef DOXYGEN_SHOULD_SKIP_THIS
38// Forward declaration of Teuchos::Comm
39namespace Teuchos {
40template <class OrdinalType>
41class Comm;
42} // namespace Teuchos
43#endif // DOXYGEN_SHOULD_SKIP_THIS
44
45namespace Tpetra {
46namespace Details {
54template <class LocalOrdinal, class GlobalOrdinal, class NodeType>
55class Directory : public Teuchos::Describable {
56 public:
59 typedef NodeType node_type;
60 typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, NodeType> map_type;
61
69 Directory() = default;
70
71 virtual ~Directory() = default;
72
106 getEntries(const map_type &map,
107 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
108 const Teuchos::ArrayView<int> &nodeIDs,
109 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
110 const bool computeLIDs) const;
111
118 virtual bool isOneToOne(const Teuchos::Comm<int> &comm) const = 0;
119
120 protected:
122 virtual LookupStatus
124 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
125 const Teuchos::ArrayView<int> &nodeIDs,
126 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
127 const bool computeLIDs) const = 0;
128};
129
132template <class LocalOrdinal, class GlobalOrdinal, class NodeType>
133class ReplicatedDirectory : public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
134 public:
136 typedef typename base_type::map_type map_type;
137
140
143
144 ~ReplicatedDirectory() override = default;
145
146 bool isOneToOne(const Teuchos::Comm<int> &comm) const override;
147
149
150
152 std::string description() const override;
154 protected:
158 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
159 const Teuchos::ArrayView<int> &nodeIDs,
160 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
161 const bool computeLIDs) const override;
162
163 private:
165 const int numProcs_ = 0;
166};
167
176template <class LocalOrdinal, class GlobalOrdinal, class NodeType>
177class ContiguousUniformDirectory : public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
178 private:
179 // This friend declaration lets us implement clone().
180 template <class LO, class GO, class N>
181 friend class ContiguousUniformDirectory;
182
183 public:
185 typedef typename base_type::map_type map_type;
186
187 ContiguousUniformDirectory() = default;
189 ~ContiguousUniformDirectory() override = default;
190
191 bool isOneToOne(const Teuchos::Comm<int> &) const override {
192 return true;
193 }
194
196
197
199 std::string description() const override;
201
202 protected:
205 getEntriesImpl(const map_type &map,
206 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
207 const Teuchos::ArrayView<int> &nodeIDs,
208 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
209 const bool computeLIDs) const override;
210};
211
214template <class LocalOrdinal, class GlobalOrdinal, class NodeType>
215class DistributedContiguousDirectory : public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
216 private:
217 template <class LO, class GO, class N>
219
220 public:
222 typedef typename base_type::map_type map_type;
223
226 ~DistributedContiguousDirectory() override = default;
227
228 bool isOneToOne(const Teuchos::Comm<int> &) const override {
229 return true;
230 }
231
233
234
236 std::string description() const override;
238
239 protected:
242 getEntriesImpl(const map_type &map,
243 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
244 const Teuchos::ArrayView<int> &nodeIDs,
245 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
246 const bool computeLIDs) const override;
247
248 private:
274 Teuchos::ArrayRCP<GlobalOrdinal> allMinGIDs_;
275};
276
279template <class LocalOrdinal, class GlobalOrdinal, class NodeType>
280class DistributedNoncontiguousDirectory : public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
281 private:
282 template <class LO, class GO, class N>
284
285 public:
288 using map_type = typename base_type::map_type;
289
291 DistributedNoncontiguousDirectory(const map_type &map);
294 ~DistributedNoncontiguousDirectory() override = default;
295
296 bool isOneToOne(const Teuchos::Comm<int> &comm) const override;
297
299
300
302 std::string description() const override;
304 protected:
307 getEntriesImpl(const map_type &map,
308 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
309 const Teuchos::ArrayView<int> &nodeIDs,
310 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
311 const bool computeLIDs) const override;
312
313 private:
320 void
321 initialize(const map_type &map,
322 Teuchos::Ptr<const tie_break_type> tie_break);
323
336 bool isLocallyOneToOne() const {
337 return locallyOneToOne_;
338 }
339
357 Teuchos::RCP<const map_type> directoryMap_;
358
360
361
367 Teuchos::ArrayRCP<int> PIDs_;
368
374 Teuchos::ArrayRCP<LocalOrdinal> LIDs_;
375
377
379
393 typedef typename Details::FixedHashTable<LocalOrdinal, int,
394 Kokkos::HostSpace::device_type>
396 Teuchos::RCP<lidToPidTable_type> lidToPidTable_;
397
412 Kokkos::HostSpace::device_type>
414 Teuchos::RCP<lidToLidTable_type> lidToLidTable_;
416
423 mutable enum EOneToOneResult {
424 ONE_TO_ONE_NOT_CALLED_YET,
425 ONE_TO_ONE_FALSE,
426 ONE_TO_ONE_TRUE
427 } oneToOneResult_;
428
432 bool locallyOneToOne_;
433
441 bool useHashTables_;
442};
443} // namespace Details
444} // namespace Tpetra
445
446#endif // __Tpetra_DirectoryImpl_decl_hpp
Forward declaration of Tpetra::Map.
Interface for breaking ties in ownership.
Struct that holds views of the contents of a CrsMatrix.
Implementation of Directory for a contiguous, uniformly distributed Map.
std::string description() const override
A one-line human-readable description of this object.
LookupStatus getEntriesImpl(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const override
Find process IDs and (optionally) local IDs for the given global IDs.
bool isOneToOne(const Teuchos::Comm< int > &) const override
Whether the Directory's input Map is (globally) one to one.
Computes the local ID and process ID corresponding to given global IDs.
LookupStatus getEntries(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const
virtual bool isOneToOne(const Teuchos::Comm< int > &comm) const =0
Whether the Directory's input Map is (globally) one to one.
virtual LookupStatus getEntriesImpl(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const =0
Actually do the work of getEntries(), with no input validation.
Directory()=default
Constructor.
Implementation of Directory for a distributed contiguous Map.
bool isOneToOne(const Teuchos::Comm< int > &) const override
Whether the Directory's input Map is (globally) one to one.
LookupStatus getEntriesImpl(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const override
Find process IDs and (optionally) local IDs for the given global IDs.
std::string description() const override
A one-line human-readable description of this object.
Implementation of Directory for a distributed noncontiguous Map.
std::string description() const override
A one-line human-readable description of this object.
bool isOneToOne(const Teuchos::Comm< int > &comm) const override
Whether the Directory's input Map is (globally) one to one.
LookupStatus getEntriesImpl(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const override
Find process IDs and (optionally) local IDs for the given global IDs.
Implementation of Directory for a locally replicated Map.
LookupStatus getEntriesImpl(const map_type &map, const Teuchos::ArrayView< const GlobalOrdinal > &globalIDs, const Teuchos::ArrayView< int > &nodeIDs, const Teuchos::ArrayView< LocalOrdinal > &localIDs, const bool computeLIDs) const override
Find process IDs and (optionally) local IDs for the given global IDs.
bool isOneToOne(const Teuchos::Comm< int > &comm) const override
Whether the Directory's input Map is (globally) one to one.
std::string description() const override
A one-line human-readable description of this object.
ReplicatedDirectory()=default
Constructor (that takes no arguments).
Interface for breaking ties in ownership.
A parallel distribution of indices over processes.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).