44#ifndef TPETRA_DETAILS_FIXEDHASHTABLE_DECL_HPP
45#define TPETRA_DETAILS_FIXEDHASHTABLE_DECL_HPP
47#include "Tpetra_Details_Hash.hpp"
50#include "Teuchos_Describable.hpp"
51#include "Teuchos_FancyOStream.hpp"
52#include "Teuchos_VerbosityLevel.hpp"
53#include "Kokkos_Core.hpp"
83template<
class KeyType,
88 typedef typename DeviceType::execution_space execution_space;
89 typedef typename DeviceType::memory_space memory_space;
90 typedef Kokkos::Device<execution_space, memory_space> device_type;
93 typedef typename hash_type::offset_type offset_type;
102 typedef typename Kokkos::View<
const offset_type*, Kokkos::LayoutLeft,
103 device_type> ptr_type;
110 typedef typename Kokkos::View<const Kokkos::pair<KeyType, ValueType>*,
111 Kokkos::LayoutLeft, device_type> val_type;
120 return contiguousValues_;
127 typedef Kokkos::View<const KeyType*, Kokkos::LayoutLeft, device_type>
keys_type;
234 const Teuchos::ArrayView<const ValueType>&
vals);
236 template<
class K,
class V,
class D>
244 template<
class InDeviceType>
246 typename std::enable_if<! std::is_same<DeviceType, InDeviceType>::value,
int>::type* =
NULL)
248 using Kokkos::ViewAllocateWithoutInitializing;
261 src.ptr_.extent (0));
264 src.val_.extent (0));
267 Kokkos::deep_copy (
val, src.val_);
271 this->minKey_ = src.minKey_;
272 this->maxKey_ = src.maxKey_;
273 this->minVal_ = src.minVal_;
274 this->maxVal_ = src.maxVal_;
275 this->firstContigKey_ = src.firstContigKey_;
276 this->lastContigKey_ = src.lastContigKey_;
277 this->contiguousValues_ = src.contiguousValues_;
278 this->checkedForDuplicateKeys_ = src.checkedForDuplicateKeys_;
279 this->hasDuplicateKeys_ = src.hasDuplicateKeys_;
284 const offset_type
size = this->getSize ();
288 return Tpetra::Details::OrdinalTraits<ValueType>::invalid ();
293 if (this->hasContiguousValues () &&
294 key >= firstContigKey_ &&
key <= lastContigKey_) {
298 const typename hash_type::result_type
hashVal =
299 hash_type::hashFunc (
key,
size);
305 return val_[
k].second;
311 return Tpetra::Details::OrdinalTraits<ValueType>::invalid ();
323 if (this->hasContiguousValues ()) {
324 return val_.extent (0) +
static_cast<offset_type
> (lastContigKey_ - firstContigKey_);
327 return val_.extent (0);
403 const Teuchos::EVerbosityLevel
verbLevel=
404 Teuchos::Describable::verbLevel_default)
const;
459 bool contiguousValues_;
466 bool checkedForDuplicateKeys_;
471 bool hasDuplicateKeys_;
477 bool checkForDuplicateKeys ()
const;
481 return ptr_.extent (0) == 0 ?
482 static_cast<offset_type
> (0) :
486 typedef Kokkos::View<
const KeyType*,
487 typename ptr_type::HostMirror::array_layout,
488 typename ptr_type::HostMirror::execution_space,
489 Kokkos::MemoryUnmanaged> host_input_keys_type;
492 typename ptr_type::HostMirror::array_layout,
493 typename ptr_type::HostMirror::execution_space,
494 Kokkos::MemoryUnmanaged> host_input_vals_type;
518 init (
const host_input_keys_type&
keys,
519 const host_input_vals_type&
vals,
Import KokkosSparse::OrdinalTraits, a traits class for "invalid" (flag) values of integer types,...
Declare and define Tpetra::Details::copyOffsets, an implementation detail of Tpetra (in particular,...
Struct that holds views of the contents of a CrsMatrix.
KOKKOS_INLINE_FUNCTION ValueType minVal() const
The minimum value in the table.
std::string description() const
Implementation of Teuchos::Describable interface.
bool hasDuplicateKeys()
Whether the table has any duplicate keys.
FixedHashTable(const FixedHashTable< KeyType, ValueType, InDeviceType > &src, typename std::enable_if<! std::is_same< DeviceType, InDeviceType >::value, int >::type *=NULL)
"Copy" constructor that takes a FixedHashTable with the same KeyType and ValueType,...
KOKKOS_INLINE_FUNCTION offset_type numPairs() const
Number of (key, value) pairs in the table.
Kokkos::View< const KeyType *, Kokkos::LayoutLeft, device_type > keys_type
Type of a 1-D Kokkos::View (array) used to store keys.
KOKKOS_INLINE_FUNCTION KeyType maxKey() const
The maximum key in the table.
KOKKOS_INLINE_FUNCTION ValueType maxVal() const
The maximum value in the table.
KOKKOS_INLINE_FUNCTION KeyType minKey() const
The minimum key in the table.
KOKKOS_INLINE_FUNCTION ValueType get(const KeyType &key) const
Get the value corresponding to the given key.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print this object with the given verbosity to the output stream.
Implementation details of Tpetra.
void copyOffsets(const OutputViewType &dst, const InputViewType &src)
Copy row offsets (in a sparse graph or matrix) from src to dst. The offsets may have different types.
Namespace Tpetra contains the class and methods constituting the Tpetra library.