42#ifndef TPETRA_DETAILS_LOCALMAP_HPP
43#define TPETRA_DETAILS_LOCALMAP_HPP
49#include "Tpetra_Details_FixedHashTable.hpp"
70template<
class LocalOrdinal,
class GlobalOrdinal,
class DeviceType>
89#ifdef KOKKOS_ENABLE_CUDA
90 using no_uvm_memory_space =
typename std::conditional<std::is_same<memory_space, Kokkos::CudaUVMSpace>::value,
98 KOKKOS_DEFAULTED_FUNCTION
LocalMap() =
default;
100 LocalMap (const ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, no_uvm_device_type>& glMap,
101 const ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, no_uvm_device_type>& lgMap,
102 const GlobalOrdinal indexBase,
103 const GlobalOrdinal myMinGid,
104 const GlobalOrdinal myMaxGid,
105 const GlobalOrdinal firstContiguousGid,
106 const GlobalOrdinal lastContiguousGid,
107 const LocalOrdinal numLocalElements,
108 const bool contiguous) :
111 indexBase_ (indexBase),
112 myMinGid_ (myMinGid),
113 myMaxGid_ (myMaxGid),
114 firstContiguousGid_ (firstContiguousGid),
115 lastContiguousGid_ (lastContiguousGid),
116 numLocalElements_ (numLocalElements),
117 contiguous_ (contiguous)
122 return numLocalElements_;
144 KOKKOS_INLINE_FUNCTION LocalOrdinal
147 if (numLocalElements_ == 0) {
148 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
150 return static_cast<LocalOrdinal
> (numLocalElements_ - 1);
165 KOKKOS_INLINE_FUNCTION LocalOrdinal
169 if (globalIndex < myMinGid_ || globalIndex > myMaxGid_) {
170 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
172 return static_cast<LocalOrdinal
> (globalIndex - myMinGid_);
174 else if (globalIndex >= firstContiguousGid_ &&
175 globalIndex <= lastContiguousGid_) {
176 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGid_);
181 return glMap_.
get (globalIndex);
186 KOKKOS_INLINE_FUNCTION GlobalOrdinal
190 return ::Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
196 return lgMap_(localIndex);
217 ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, no_uvm_device_type> lgMap_;
219 GlobalOrdinal indexBase_ = 0;
220 GlobalOrdinal myMinGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
221 GlobalOrdinal myMaxGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
222 GlobalOrdinal firstContiguousGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
223 GlobalOrdinal lastContiguousGid_ = Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid();
224 LocalOrdinal numLocalElements_ = 0;
225 bool contiguous_ =
false;
Forward declaration of Tpetra::Details::LocalMap.
KOKKOS_INLINE_FUNCTION ValueType get(const KeyType &key) const
Get the value corresponding to the given key.
"Local" part of Map suitable for Kokkos kernels.
KOKKOS_INLINE_FUNCTION LocalOrdinal getLocalNumElements() const
The number of indices that live on the calling process.
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.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMaxGlobalIndex() const
The maximum global index on the calling process.
LocalOrdinal local_ordinal_type
The type of local indices.
KOKKOS_INLINE_FUNCTION bool isContiguous() const
Whether the Map is (locally) contiguous.
GlobalOrdinal global_ordinal_type
The type of global indices.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMinLocalIndex() const
The minimum local index.
KOKKOS_DEFAULTED_FUNCTION LocalMap()=default
Default constructor.
typename device_type::memory_space memory_space
The Kokkos memory space.
KOKKOS_INLINE_FUNCTION LocalOrdinal getMaxLocalIndex() const
The maximum local index.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getIndexBase() const
The (global) index base.
KOKKOS_INLINE_FUNCTION GlobalOrdinal getGlobalElement(const LocalOrdinal localIndex) const
Get the global index corresponding to the given local index. (device only)
KOKKOS_INLINE_FUNCTION GlobalOrdinal getMinGlobalIndex() const
The minimum global index on the calling process.
device_type no_uvm_device_type
The hash will be CudaSpace, not CudaUVMSpace.
DeviceType device_type
The device type.
Implementation details of Tpetra.
Namespace Tpetra contains the class and methods constituting the Tpetra library.