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//
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_DirectoryImpl_decl_hpp
41#define __Tpetra_DirectoryImpl_decl_hpp
42
45
46#include "Tpetra_TieBreak.hpp"
47#include "Tpetra_Map_fwd.hpp"
48
49//
50// mfh 13-15 May 2013: HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX governs
51// the fix for Bug 5822. The fix is enabled by default. To disable
52// the fix, uncomment out the three lines below that undefine
53// HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX, and comment out the three
54// lines below them that define that macro.
55//
56// mfh 23 Mar 2014: I want Bug 5822 to stay fixed, so I am removing
57// all references to HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX. I hope no
58// downstream code is using that macro, but just in case, I will leave
59// it defined.
60
61#ifndef HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX
62# define HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX 1
63#endif // HAVE_TPETRA_DIRECTORY_SPARSE_MAP_FIX
64
65#include "Tpetra_Details_FixedHashTable_decl.hpp"
66
67#ifndef DOXYGEN_SHOULD_SKIP_THIS
68// Forward declaration of Teuchos::Comm
69namespace Teuchos {
70 template<class OrdinalType>
71 class Comm;
72} // namespace Teuchos
73#endif // DOXYGEN_SHOULD_SKIP_THIS
74
75namespace Tpetra {
76 namespace Details {
84 template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
85 class Directory : public Teuchos::Describable {
86 public:
89 typedef NodeType node_type;
90 typedef ::Tpetra::Map<LocalOrdinal, GlobalOrdinal, NodeType> map_type;
91
99 Directory () = default;
100
101 virtual ~Directory () = default;
102
136 getEntries (const map_type& map,
137 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
138 const Teuchos::ArrayView<int> &nodeIDs,
139 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
140 const bool computeLIDs) const;
141
148 virtual bool isOneToOne (const Teuchos::Comm<int>& comm) const = 0;
149
150 protected:
152 virtual LookupStatus
154 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
155 const Teuchos::ArrayView<int> &nodeIDs,
156 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
157 const bool computeLIDs) const = 0;
158 };
159
162 template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
164 public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
165 public:
167 typedef typename base_type::map_type map_type;
168
171
174
175 ~ReplicatedDirectory () override = default;
176
177 bool isOneToOne (const Teuchos::Comm<int>& comm) const override;
178
180
181
183 std::string description () const override;
185 protected:
189 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
190 const Teuchos::ArrayView<int> &nodeIDs,
191 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
192 const bool computeLIDs) const override;
193
194 private:
196 const int numProcs_ = 0;
197 };
198
199
208 template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
210 public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
211 private:
212 // This friend declaration lets us implement clone().
213 template <class LO, class GO, class N> friend class ContiguousUniformDirectory;
214
215 public:
217 typedef typename base_type::map_type map_type;
218
219 ContiguousUniformDirectory () = default;
221 ~ContiguousUniformDirectory () override = default;
222
223 bool isOneToOne (const Teuchos::Comm<int>&) const override {
224 return true;
225 }
226
228
229
231 std::string description () const override;
233
234 protected:
237 getEntriesImpl (const map_type& map,
238 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
239 const Teuchos::ArrayView<int> &nodeIDs,
240 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
241 const bool computeLIDs) const override;
242 };
243
244
247 template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
249 public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
250 private:
251 template <class LO, class GO, class N> friend class DistributedContiguousDirectory;
252
253 public:
255 typedef typename base_type::map_type map_type;
256
259 ~DistributedContiguousDirectory () override = default;
260
261 bool isOneToOne (const Teuchos::Comm<int>&) const override {
262 return true;
263 }
264
266
267
269 std::string description () const override;
271
272 protected:
275 getEntriesImpl (const map_type& map,
276 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
277 const Teuchos::ArrayView<int> &nodeIDs,
278 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
279 const bool computeLIDs) const override;
280
281 private:
307 Teuchos::ArrayRCP<GlobalOrdinal> allMinGIDs_;
308 };
309
312 template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
314 public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
315 private:
316 template <class LO, class GO, class N>
318
319 public:
322 using map_type = typename base_type::map_type;
323
325 DistributedNoncontiguousDirectory (const map_type& map);
326 DistributedNoncontiguousDirectory (const map_type& map,
328 ~DistributedNoncontiguousDirectory () override = default;
329
330 bool isOneToOne (const Teuchos::Comm<int>& comm) const override;
331
333
334
336 std::string description () const override;
338 protected:
341 getEntriesImpl (const map_type& map,
342 const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
343 const Teuchos::ArrayView<int> &nodeIDs,
344 const Teuchos::ArrayView<LocalOrdinal> &localIDs,
345 const bool computeLIDs) const override;
346 private:
353 void
354 initialize (const map_type& map,
355 Teuchos::Ptr<const tie_break_type> tie_break);
356
369 bool isLocallyOneToOne () const {
370 return locallyOneToOne_;
371 }
372
390 Teuchos::RCP<const map_type> directoryMap_;
391
393
394
400 Teuchos::ArrayRCP<int> PIDs_;
401
407 Teuchos::ArrayRCP<LocalOrdinal> LIDs_;
408
410
412
426 typedef typename Details::FixedHashTable<LocalOrdinal, int,
427 Kokkos::HostSpace::device_type>
429 Teuchos::RCP<lidToPidTable_type> lidToPidTable_;
430
445 Kokkos::HostSpace::device_type>
447 Teuchos::RCP<lidToLidTable_type> lidToLidTable_;
449
456 mutable enum EOneToOneResult {
457 ONE_TO_ONE_NOT_CALLED_YET,
458 ONE_TO_ONE_FALSE,
459 ONE_TO_ONE_TRUE
460 } oneToOneResult_;
461
465 bool locallyOneToOne_;
466
474 bool useHashTables_;
475 };
476 } // namespace Details
477} // namespace Tpetra
478
479#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()).