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,
99 myMinGid_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
100 myMaxGid_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
101 firstContiguousGid_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
102 lastContiguousGid_ (
Tpetra::
Details::OrdinalTraits<GlobalOrdinal>::invalid ()),
103 numLocalElements_ (0),
106 LocalMap (const ::Tpetra::Details::FixedHashTable<GlobalOrdinal, LocalOrdinal, no_uvm_device_type>& glMap,
107 const ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, no_uvm_device_type>& lgMap,
108 const GlobalOrdinal indexBase,
109 const GlobalOrdinal myMinGid,
110 const GlobalOrdinal myMaxGid,
111 const GlobalOrdinal firstContiguousGid,
112 const GlobalOrdinal lastContiguousGid,
113 const LocalOrdinal numLocalElements,
114 const bool contiguous) :
117 indexBase_ (indexBase),
118 myMinGid_ (myMinGid),
119 myMaxGid_ (myMaxGid),
120 firstContiguousGid_ (firstContiguousGid),
121 lastContiguousGid_ (lastContiguousGid),
122 numLocalElements_ (numLocalElements),
123 contiguous_ (contiguous)
128 return numLocalElements_;
150 KOKKOS_INLINE_FUNCTION LocalOrdinal
153 if (numLocalElements_ == 0) {
154 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
156 return static_cast<LocalOrdinal
> (numLocalElements_ - 1);
171 KOKKOS_INLINE_FUNCTION LocalOrdinal
175 if (globalIndex < myMinGid_ || globalIndex > myMaxGid_) {
176 return ::Tpetra::Details::OrdinalTraits<LocalOrdinal>::invalid ();
178 return static_cast<LocalOrdinal
> (globalIndex - myMinGid_);
180 else if (globalIndex >= firstContiguousGid_ &&
181 globalIndex <= lastContiguousGid_) {
182 return static_cast<LocalOrdinal
> (globalIndex - firstContiguousGid_);
187 return glMap_.
get (globalIndex);
192 KOKKOS_INLINE_FUNCTION GlobalOrdinal
196 return ::Tpetra::Details::OrdinalTraits<GlobalOrdinal>::invalid ();
202 return lgMap_(localIndex);
223 ::Kokkos::View<const GlobalOrdinal*, ::Kokkos::LayoutLeft, no_uvm_device_type> lgMap_;
225 GlobalOrdinal indexBase_;
226 GlobalOrdinal myMinGid_;
227 GlobalOrdinal myMaxGid_;
228 GlobalOrdinal firstContiguousGid_;
229 GlobalOrdinal lastContiguousGid_;
230 LocalOrdinal numLocalElements_;
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 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.
KOKKOS_INLINE_FUNCTION LocalOrdinal getNodeNumElements() const
The number of indices that live 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.
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.