3 #include "CombBLAS/hash.hpp" 7 uint64_t
inline _rotl64(uint64_t value, int8_t amount) {
8 return ((value) << (amount)) | ((value) >> (64 - (amount)));
12 uint32_t
hash = len, tmp;
15 if (len <= 0 || data == NULL)
return 0;
21 for (;len > 0; len--) {
22 hash += get16bits (data);
23 tmp = (get16bits (data+2) << 11) ^ hash;
24 hash = (hash << 16) ^ tmp;
25 data += 2*
sizeof (uint16_t);
31 case 3: hash += get16bits (data);
33 hash ^= data[
sizeof (uint16_t)] << 18;
36 case 2: hash += get16bits (data);
40 case 1: hash += *data;
63 inline uint64_t
getblock (
const uint64_t * p,
int i )
71 inline void bmix64 ( uint64_t & h1, uint64_t & h2, uint64_t & k1, uint64_t & k2, uint64_t & c1, uint64_t & c2 )
97 inline uint64_t
fmix64 ( uint64_t k )
100 k *= 0xff51afd7ed558ccd;
102 k *= 0xc4ceb9fe1a85ec53;
110 const uint8_t * data = (
const uint8_t*)key;
111 const int nblocks = len / 16;
113 uint64_t h1 = 0x9368e53c2f6af274 ^ seed;
114 uint64_t h2 = 0x586dcd208f7cd3fd ^ seed;
116 uint64_t c1 = 0x87c37b91114253d5;
117 uint64_t c2 = 0x4cf5ad432745937f;
122 const uint64_t * blocks = (
const uint64_t *)(data);
124 for(
int i = 0; i < nblocks; i++)
126 uint64_t k1 =
getblock(blocks,i*2+0);
127 uint64_t k2 =
getblock(blocks,i*2+1);
129 bmix64(h1,h2,k1,k2,c1,c2);
135 const uint8_t * tail = (
const uint8_t*)(data + nblocks*16);
142 case 15: k2 ^= uint64_t(tail[14]) << 48;
143 case 14: k2 ^= uint64_t(tail[13]) << 40;
144 case 13: k2 ^= uint64_t(tail[12]) << 32;
145 case 12: k2 ^= uint64_t(tail[11]) << 24;
146 case 11: k2 ^= uint64_t(tail[10]) << 16;
147 case 10: k2 ^= uint64_t(tail[ 9]) << 8;
148 case 9: k2 ^= uint64_t(tail[ 8]) << 0;
150 case 8: k1 ^= uint64_t(tail[ 7]) << 56;
151 case 7: k1 ^= uint64_t(tail[ 6]) << 48;
152 case 6: k1 ^= uint64_t(tail[ 5]) << 40;
153 case 5: k1 ^= uint64_t(tail[ 4]) << 32;
154 case 4: k1 ^= uint64_t(tail[ 3]) << 24;
155 case 3: k1 ^= uint64_t(tail[ 2]) << 16;
156 case 2: k1 ^= uint64_t(tail[ 1]) << 8;
157 case 1: k1 ^= uint64_t(tail[ 0]) << 0;
158 bmix64(h1,h2,k1,k2,c1,c2);
175 ((uint64_t*)out)[0] = h1;
176 ((uint64_t*)out)[1] = h2;
189 *(uint32_t*)out = temp[0];
200 *(uint64_t*)out = temp[0];
void bmix64(uint64_t &h1, uint64_t &h2, uint64_t &k1, uint64_t &k2, uint64_t &c1, uint64_t &c2)
uint32_t SuperFastHash(const char *data, int len)
uint64_t getblock(const uint64_t *p, int i)
uint64_t fmix64(uint64_t k)
void MurmurHash3_x64_32(const void *key, int len, uint32_t seed, void *out)
void MurmurHash3_x64_128(const void *key, const int len, const uint32_t seed, void *out)
uint64_t _rotl64(uint64_t value, int8_t amount)
void MurmurHash3_x64_64(const void *key, int len, uint32_t seed, void *out)
unsigned int hash(unsigned int a)