GPU-Accelerated Cuckoo Filter
Loading...
Searching...
No Matches
Functions | Variables
xxhash Namespace Reference

XXHash_64 implementation from. More...

Functions

__host__ __device__ __forceinline__ uint64_t rotl64 (uint64_t x, int8_t r)
 
template<typename T >
__host__ __device__ __forceinline__ T load_chunk (const uint8_t *data, size_t index)
 
__host__ __device__ __forceinline__ uint64_t finalize (uint64_t h)
 
template<typename T >
__host__ __device__ uint64_t xxhash64 (const T &key, uint64_t seed=0)
 

Variables

constexpr uint64_t PRIME64_1 = 11400714785074694791ULL
 
constexpr uint64_t PRIME64_2 = 14029467366897019727ULL
 
constexpr uint64_t PRIME64_3 = 1609587929392839161ULL
 
constexpr uint64_t PRIME64_4 = 9650029242287828579ULL
 
constexpr uint64_t PRIME64_5 = 2870177450012600261ULL
 

Detailed Description

XXHash_64 implementation from.

https://github.com/Cyan4973/xxHash

xxHash - Extremely Fast Hash algorithm Header File Copyright (C) 2012-2021 Yann Collet

BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

You can contact the author at:

Function Documentation

◆ finalize()

__host__ __device__ __forceinline__ uint64_t xxhash::finalize ( uint64_t  h)

Definition at line 61 of file hashutil.cuh.

61 {
62 h ^= h >> 33;
63 h *= PRIME64_2;
64 h ^= h >> 29;
65 h *= PRIME64_3;
66 h ^= h >> 32;
67 return h;
68}
constexpr uint64_t PRIME64_2
Definition hashutil.cuh:45
constexpr uint64_t PRIME64_3
Definition hashutil.cuh:46
Here is the caller graph for this function:

◆ load_chunk()

template<typename T >
__host__ __device__ __forceinline__ T xxhash::load_chunk ( const uint8_t *  data,
size_t  index 
)

Definition at line 55 of file hashutil.cuh.

55 {
56 T chunk;
57 memcpy(&chunk, data + index * sizeof(T), sizeof(T));
58 return chunk;
59}

◆ rotl64()

__host__ __device__ __forceinline__ uint64_t xxhash::rotl64 ( uint64_t  x,
int8_t  r 
)

Definition at line 50 of file hashutil.cuh.

50 {
51 return (x << r) | (x >> (64 - r));
52}
Here is the caller graph for this function:

◆ xxhash64()

template<typename T >
__host__ __device__ uint64_t xxhash::xxhash64 ( const T &  key,
uint64_t  seed = 0 
)
inline

Definition at line 71 of file hashutil.cuh.

71 {
72 const auto* bytes = reinterpret_cast<const uint8_t*>(&key);
73 size_t size = sizeof(T);
74 size_t offset = 0;
75 uint64_t h64;
76
77 // Process 32-byte chunks
78 if (size >= 32) {
79 size_t limit = size - 32;
80 uint64_t v1 = seed + PRIME64_1 + PRIME64_2;
81 uint64_t v2 = seed + PRIME64_2;
82 uint64_t v3 = seed;
83 uint64_t v4 = seed - PRIME64_1;
84
85 do {
86 const size_t pipeline_offset = offset / 8;
87 v1 += load_chunk<uint64_t>(bytes, pipeline_offset + 0) * PRIME64_2;
88 v1 = rotl64(v1, 31);
89 v1 *= PRIME64_1;
90 v2 += load_chunk<uint64_t>(bytes, pipeline_offset + 1) * PRIME64_2;
91 v2 = rotl64(v2, 31);
92 v2 *= PRIME64_1;
93 v3 += load_chunk<uint64_t>(bytes, pipeline_offset + 2) * PRIME64_2;
94 v3 = rotl64(v3, 31);
95 v3 *= PRIME64_1;
96 v4 += load_chunk<uint64_t>(bytes, pipeline_offset + 3) * PRIME64_2;
97 v4 = rotl64(v4, 31);
98 v4 *= PRIME64_1;
99 offset += 32;
100 } while (offset <= limit);
101
102 h64 = rotl64(v1, 1) + rotl64(v2, 7) + rotl64(v3, 12) + rotl64(v4, 18);
103
104 v1 *= PRIME64_2;
105 v1 = rotl64(v1, 31);
106 v1 *= PRIME64_1;
107 h64 ^= v1;
108 h64 = h64 * PRIME64_1 + PRIME64_4;
109
110 v2 *= PRIME64_2;
111 v2 = rotl64(v2, 31);
112 v2 *= PRIME64_1;
113 h64 ^= v2;
114 h64 = h64 * PRIME64_1 + PRIME64_4;
115
116 v3 *= PRIME64_2;
117 v3 = rotl64(v3, 31);
118 v3 *= PRIME64_1;
119 h64 ^= v3;
120 h64 = h64 * PRIME64_1 + PRIME64_4;
121
122 v4 *= PRIME64_2;
123 v4 = rotl64(v4, 31);
124 v4 *= PRIME64_1;
125 h64 ^= v4;
126 h64 = h64 * PRIME64_1 + PRIME64_4;
127 } else {
128 h64 = seed + PRIME64_5;
129 }
130
131 h64 += size;
132
133 // Process remaining 8-byte chunks
134 if ((size % 32) >= 8) {
135 for (; offset <= size - 8; offset += 8) {
136 uint64_t k1 = load_chunk<uint64_t>(bytes, offset / 8) * PRIME64_2;
137 k1 = rotl64(k1, 31) * PRIME64_1;
138 h64 ^= k1;
139 h64 = rotl64(h64, 27) * PRIME64_1 + PRIME64_4;
140 }
141 }
142
143 // Process remaining 4-byte chunks
144 if ((size % 8) >= 4) {
145 for (; offset <= size - 4; offset += 4) {
146 h64 ^= (load_chunk<uint32_t>(bytes, offset / 4) & 0xffffffffULL) * PRIME64_1;
147 h64 = rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
148 }
149 }
150
151 // Process remaining bytes
152 if (size % 4) {
153 while (offset < size) {
154 h64 ^= (bytes[offset] & 0xff) * PRIME64_5;
155 h64 = rotl64(h64, 11) * PRIME64_1;
156 ++offset;
157 }
158 }
159
160 return finalize(h64);
161}
constexpr uint64_t PRIME64_5
Definition hashutil.cuh:48
__host__ __device__ __forceinline__ uint64_t finalize(uint64_t h)
Definition hashutil.cuh:61
constexpr uint64_t PRIME64_1
Definition hashutil.cuh:44
__host__ __device__ __forceinline__ uint64_t rotl64(uint64_t x, int8_t r)
Definition hashutil.cuh:50
constexpr uint64_t PRIME64_4
Definition hashutil.cuh:47
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ PRIME64_1

constexpr uint64_t xxhash::PRIME64_1 = 11400714785074694791ULL
constexpr

Definition at line 44 of file hashutil.cuh.

◆ PRIME64_2

constexpr uint64_t xxhash::PRIME64_2 = 14029467366897019727ULL
constexpr

Definition at line 45 of file hashutil.cuh.

◆ PRIME64_3

constexpr uint64_t xxhash::PRIME64_3 = 1609587929392839161ULL
constexpr

Definition at line 46 of file hashutil.cuh.

◆ PRIME64_4

constexpr uint64_t xxhash::PRIME64_4 = 9650029242287828579ULL
constexpr

Definition at line 47 of file hashutil.cuh.

◆ PRIME64_5

constexpr uint64_t xxhash::PRIME64_5 = 2870177450012600261ULL
constexpr

Definition at line 48 of file hashutil.cuh.