10 #ifndef TPETRA_DETAILS_HASH_HPP
11 #define TPETRA_DETAILS_HASH_HPP
13 #include "Tpetra_ConfigDefs.hpp"
14 #ifdef TPETRA_USE_MURMUR_HASH
15 # include <Kokkos_Functional.hpp>
16 #endif // TPETRA_USE_MURMUR_HASH
17 #include <type_traits>
25 int getRecommendedSizeInt (
const int size);
37 template<
class KeyType,
39 class OffsetType =
typename std::make_signed<typename Kokkos::View<KeyType*, DeviceType>::size_type>::type,
40 class ResultType =
int>
63 static_assert (! std::is_same<result_type, int>::value,
64 "Not yet implemented for ResultType != int");
79 static_assert (! std::is_same<result_type, int>::value,
80 "Not yet implemented for ResultType != int");
97 template<
class KeyType,
class DeviceType,
class OffsetType>
98 struct Hash<KeyType, DeviceType, OffsetType, int> {
121 #ifdef TPETRA_USE_MURMUR_HASH
122 Kokkos::pod_hash<argument_type> hash;
123 const uint32_t k = hash (key);
131 const unsigned int seed = (2654435761U);
132 const int intkey = (int) ((key & 0x000000007fffffffLL) +
133 ((key & 0x7fffffff80000000LL) >> 31));
134 return static_cast<result_type> ((seed ^ intkey) % static_cast<int> (size));
146 return Impl::getRecommendedSizeInt (static_cast<int> (size));
153 #endif // TPETRA_DETAILS_HASH_HPP
static KOKKOS_INLINE_FUNCTION result_type hashFunc(const argument_type &, const offset_type &)
The hash function.
static result_type getRecommendedSize(const offset_type size)
Number of "buckets" that the constructor of FixedHashTable should allocate.
ResultType result_type
Type of the return value of the hash function.
KeyType argument_type
Type of the hash function's input.
OffsetType offset_type
Type of offsets into the hash table's array of (key,value) pairs.
static KOKKOS_INLINE_FUNCTION result_type hashFunc(const argument_type &key, const offset_type &size)
The hash function.
int result_type
Type of the return value of the hash function.
The hash function for FixedHashTable.
KeyType argument_type
Type of the hash function's input.
OffsetType offset_type
Type of offsets into the hash table's array of (key,value) pairs.
static result_type getRecommendedSize(const offset_type)
Number of "buckets" that the constructor of FixedHashTable should allocate.