44 #ifndef TPETRA_DETAILS_HASH_HPP
45 #define TPETRA_DETAILS_HASH_HPP
47 #include "Tpetra_ConfigDefs.hpp"
48 #ifdef TPETRA_USE_MURMUR_HASH
49 # include <Kokkos_Functional.hpp>
50 #endif // TPETRA_USE_MURMUR_HASH
51 #include <type_traits>
59 int getRecommendedSizeInt (
const int size);
71 template<
class KeyType,
73 class OffsetType =
typename std::make_signed<typename Kokkos::View<KeyType*, DeviceType>::size_type>::type,
74 class ResultType =
int>
97 static_assert (! std::is_same<result_type, int>::value,
98 "Not yet implemented for ResultType != int");
113 static_assert (! std::is_same<result_type, int>::value,
114 "Not yet implemented for ResultType != int");
131 template<
class KeyType,
class DeviceType,
class OffsetType>
132 struct Hash<KeyType, DeviceType, OffsetType, int> {
155 #ifdef TPETRA_USE_MURMUR_HASH
156 Kokkos::pod_hash<argument_type> hash;
157 const uint32_t k = hash (key);
165 const unsigned int seed = (2654435761U);
166 const int intkey = (int) ((key & 0x000000007fffffffLL) +
167 ((key & 0x7fffffff80000000LL) >> 31));
168 return static_cast<result_type> ((seed ^ intkey) % static_cast<int> (size));
180 return Impl::getRecommendedSizeInt (static_cast<int> (size));
187 #endif // TPETRA_DETAILS_HASH_HPP
static result_type getRecommendedSize(const offset_type size)
Number of "buckets" that the constructor of FixedHashTable should allocate.
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 KOKKOS_INLINE_FUNCTION result_type hashFunc(const argument_type &key, const offset_type &size)
The hash function.