Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
39 namespace Teuchos {
40  template<class OrdinalType>
41  class Comm;
42 } // namespace Teuchos
43 #endif // DOXYGEN_SHOULD_SKIP_THIS
44 
45 namespace Tpetra {
46  namespace Details {
54  template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
55  class Directory : public Teuchos::Describable {
56  public:
57  typedef LocalOrdinal local_ordinal_type;
58  typedef GlobalOrdinal global_ordinal_type;
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
123  getEntriesImpl (const map_type& map,
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 
132  template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
134  public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
135  public:
137  typedef typename base_type::map_type map_type;
138 
140  ReplicatedDirectory () = default;
141 
143  ReplicatedDirectory (const map_type& map);
144 
145  ~ReplicatedDirectory () override = default;
146 
147  bool isOneToOne (const Teuchos::Comm<int>& comm) const override;
148 
150 
151 
153  std::string description () const override;
155  protected:
158  getEntriesImpl (const map_type& map,
159  const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
160  const Teuchos::ArrayView<int> &nodeIDs,
161  const Teuchos::ArrayView<LocalOrdinal> &localIDs,
162  const bool computeLIDs) const override;
163 
164  private:
166  const int numProcs_ = 0;
167  };
168 
169 
178  template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
180  public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
181  private:
182  // This friend declaration lets us implement clone().
183  template <class LO, class GO, class N> friend class ContiguousUniformDirectory;
184 
185  public:
187  typedef typename base_type::map_type map_type;
188 
189  ContiguousUniformDirectory () = default;
191  ~ContiguousUniformDirectory () override = default;
192 
193  bool isOneToOne (const Teuchos::Comm<int>&) const override {
194  return true;
195  }
196 
198 
199 
201  std::string description () const override;
203 
204  protected:
207  getEntriesImpl (const map_type& map,
208  const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
209  const Teuchos::ArrayView<int> &nodeIDs,
210  const Teuchos::ArrayView<LocalOrdinal> &localIDs,
211  const bool computeLIDs) const override;
212  };
213 
214 
217  template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
219  public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
220  private:
221  template <class LO, class GO, class N> friend class DistributedContiguousDirectory;
222 
223  public:
225  typedef typename base_type::map_type map_type;
226 
227  DistributedContiguousDirectory () = default;
229  ~DistributedContiguousDirectory () override = default;
230 
231  bool isOneToOne (const Teuchos::Comm<int>&) const override {
232  return true;
233  }
234 
236 
237 
239  std::string description () const override;
241 
242  protected:
245  getEntriesImpl (const map_type& map,
246  const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
247  const Teuchos::ArrayView<int> &nodeIDs,
248  const Teuchos::ArrayView<LocalOrdinal> &localIDs,
249  const bool computeLIDs) const override;
250 
251  private:
277  Teuchos::ArrayRCP<GlobalOrdinal> allMinGIDs_;
278  };
279 
282  template<class LocalOrdinal, class GlobalOrdinal, class NodeType>
284  public Directory<LocalOrdinal, GlobalOrdinal, NodeType> {
285  private:
286  template <class LO, class GO, class N>
288 
289  public:
292  using map_type = typename base_type::map_type;
293 
295  DistributedNoncontiguousDirectory (const map_type& map);
296  DistributedNoncontiguousDirectory (const map_type& map,
297  const tie_break_type& tie_break);
298  ~DistributedNoncontiguousDirectory () override = default;
299 
300  bool isOneToOne (const Teuchos::Comm<int>& comm) const override;
301 
303 
304 
306  std::string description () const override;
308  protected:
311  getEntriesImpl (const map_type& map,
312  const Teuchos::ArrayView<const GlobalOrdinal> &globalIDs,
313  const Teuchos::ArrayView<int> &nodeIDs,
314  const Teuchos::ArrayView<LocalOrdinal> &localIDs,
315  const bool computeLIDs) const override;
316  private:
323  void
324  initialize (const map_type& map,
325  Teuchos::Ptr<const tie_break_type> tie_break);
326 
339  bool isLocallyOneToOne () const {
340  return locallyOneToOne_;
341  }
342 
360  Teuchos::RCP<const map_type> directoryMap_;
361 
363 
364 
370  Teuchos::ArrayRCP<int> PIDs_;
371 
377  Teuchos::ArrayRCP<LocalOrdinal> LIDs_;
378 
380 
382 
396  typedef typename Details::FixedHashTable<LocalOrdinal, int,
397  Kokkos::HostSpace::device_type>
399  Teuchos::RCP<lidToPidTable_type> lidToPidTable_;
400 
414  typedef typename Details::FixedHashTable<LocalOrdinal, LocalOrdinal,
415  Kokkos::HostSpace::device_type>
417  Teuchos::RCP<lidToLidTable_type> lidToLidTable_;
419 
426  mutable enum EOneToOneResult {
427  ONE_TO_ONE_NOT_CALLED_YET,
428  ONE_TO_ONE_FALSE,
429  ONE_TO_ONE_TRUE
430  } oneToOneResult_;
431 
435  bool locallyOneToOne_;
436 
444  bool useHashTables_;
445  };
446  } // namespace Details
447 } // namespace Tpetra
448 
449 #endif // __Tpetra_DirectoryImpl_decl_hpp
Interface for breaking ties in ownership.
Implementation of Directory for a locally replicated Map.
std::string description() const override
A one-line human-readable description of this object.
Interface for breaking ties in ownership.
LookupStatus
Return status of Map remote index lookup (getRemoteIndexList()).
std::string description() const override
A one-line human-readable description of this object.
Implementation of Directory for a distributed noncontiguous Map.
bool isOneToOne(const Teuchos::Comm< int > &) const override
Whether the Directory&#39;s input Map is (globally) one to one.
Directory()=default
Constructor.
bool isOneToOne(const Teuchos::Comm< int > &comm) const override
Whether the Directory&#39;s input Map is (globally) one to one.
Implementation of Directory for a distributed contiguous 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&#39;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.
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.
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
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.
A parallel distribution of indices over processes.
ReplicatedDirectory()=default
Constructor (that takes no arguments).
Computes the local ID and process ID corresponding to given global IDs.
virtual bool isOneToOne(const Teuchos::Comm< int > &comm) const =0
Whether the Directory&#39;s input Map is (globally) one to one.
bool isOneToOne(const Teuchos::Comm< int > &) const override
Whether the Directory&#39;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 contiguous, uniformly distributed Map.
std::string description() const override
A one-line human-readable description of this object.
Forward declaration of Tpetra::Map.