42 #ifndef TPETRA_DETAILS_LOCALMAP_HPP
43 #define TPETRA_DETAILS_LOCALMAP_HPP
49 #include "Tpetra_Details_FixedHashTable.hpp"
70 template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
89 KOKKOS_DEFAULTED_FUNCTION
LocalMap() =
default;
91 LocalMap (const ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, device_type>& glMap,
92 const ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, device_type>& lgMap,
93 const GlobalOrdinal indexBase,
94 const GlobalOrdinal myMinGid,
95 const GlobalOrdinal myMaxGid,
96 const GlobalOrdinal firstContiguousGid,
97 const GlobalOrdinal lastContiguousGid,
98 const LocalOrdinal numLocalElements,
99 const bool contiguous) :
102 indexBase_ (indexBase),
103 myMinGid_ (myMinGid),
104 myMaxGid_ (myMaxGid),
105 firstContiguousGid_ (firstContiguousGid),
106 lastContiguousGid_ (lastContiguousGid),
107 numLocalElements_ (numLocalElements),
108 contiguous_ (contiguous)
113 return numLocalElements_;
135 KOKKOS_INLINE_FUNCTION LocalOrdinal
138 if (numLocalElements_ == 0) {
139 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
141 return static_cast<LocalOrdinal
> (numLocalElements_ - 1);
156 KOKKOS_INLINE_FUNCTION LocalOrdinal
160 if (globalIndex < myMinGid_ || globalIndex > myMaxGid_) {
161 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
163 return static_cast<LocalOrdinal
> (globalIndex - myMinGid_);
165 else if (globalIndex >= firstContiguousGid_ &&
166 globalIndex <= lastContiguousGid_) {
167 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGid_);
172 return glMap_.
get (globalIndex);
177 KOKKOS_INLINE_FUNCTION GlobalOrdinal
181 return ::Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
187 return lgMap_(localIndex);
208 ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, device_type> lgMap_;
210 GlobalOrdinal indexBase_ = 0;
211 GlobalOrdinal myMinGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
212 GlobalOrdinal myMaxGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
213 GlobalOrdinal firstContiguousGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
214 GlobalOrdinal lastContiguousGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
215 LocalOrdinal numLocalElements_ = 0;
216 bool contiguous_ =
false;
222 #endif // TPETRA_DETAILS_LOCALMAP_HPP
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMinGlobalIndex() const
The minimum global index on the calling process.
GO global_ordinal_type
The type of global indices.
KOKKOS_INLINE_FUNCTION ValueType get(const KeyType &key) const
Get the value corresponding to the given key.
KOKKOS_DEFAULTED_FUNCTION LocalMap()=default
Default constructor.
KOKKOS_INLINE_FUNCTION LocalOrdinal getLocalElement(const GlobalOrdinal globalIndex) const
Get the local index corresponding to the given global index. (device only)
typename device_type::execution_space execution_space
The Kokkos execution space.
"Local" part of Map suitable for Kokkos kernels.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getGlobalElement(const LocalOrdinal localIndex) const
Get the global index corresponding to the given local index. (device only)
KOKKOS_INLINE_FUNCTION bool isContiguous() const
Whether the Map is (locally) contiguous.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMinLocalIndex() const
The minimum local index.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMaxGlobalIndex() const
The maximum global index on the calling process.
Forward declaration of Tpetra::Details::LocalMap.
KOKKOS_INLINE_FUNCTION LocalOrdinal getLocalNumElements() const
The number of indices that live on the calling process.
DT device_type
The device type.
typename device_type::memory_space memory_space
The Kokkos memory space.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getIndexBase() const
The (global) index base.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMaxLocalIndex() const
The maximum local index.
LO local_ordinal_type
The type of local indices.