OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MurmurHash3Inl.h File Reference
+ Include dependency graph for MurmurHash3Inl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ROTL32(x, y)   rotl32(x, y)
 

Functions

FORCE_INLINE DEVICE uint32_t rotl32 (uint32_t x, int8_t r)
 
FORCE_INLINE DEVICE uint32_t MurmurHash3Impl (const void *key, int len, uint32_t seed)
 

Macro Definition Documentation

#define ROTL32 (   x,
 
)    rotl32(x, y)

Definition at line 9 of file MurmurHash3Inl.h.

Referenced by MurmurHash3Impl().

Function Documentation

FORCE_INLINE DEVICE uint32_t MurmurHash3Impl ( const void *  key,
int  len,
uint32_t  seed 
)

Definition at line 11 of file MurmurHash3Inl.h.

References ROTL32.

Referenced by MurmurHash3().

11  {
12  const uint8_t* data = (const uint8_t*)key;
13  const int nblocks = len / 4;
14 
15  uint32_t h1 = seed;
16 
17  const uint32_t c1 = 0xcc9e2d51;
18  const uint32_t c2 = 0x1b873593;
19 
20  //----------
21  // body
22 
23  const uint32_t* blocks = (const uint32_t*)(data + nblocks * 4);
24 
25  for (int i = -nblocks; i; i++) {
26  uint32_t k1 = blocks[i];
27 
28  k1 *= c1;
29  k1 = ROTL32(k1, 15);
30  k1 *= c2;
31 
32  h1 ^= k1;
33  h1 = ROTL32(h1, 13);
34  h1 = h1 * 5 + 0xe6546b64;
35  }
36 
37  //----------
38  // tail
39 
40  const uint8_t* tail = (const uint8_t*)(data + nblocks * 4);
41 
42  uint32_t k1 = 0;
43 
44  switch (len & 3) {
45  case 3:
46  k1 ^= tail[2] << 16;
47  case 2:
48  k1 ^= tail[1] << 8;
49  case 1:
50  k1 ^= tail[0];
51  k1 *= c1;
52  k1 = ROTL32(k1, 15);
53  k1 *= c2;
54  h1 ^= k1;
55  };
56 
57  //----------
58  // finalization
59 
60  h1 ^= len;
61 
62  //-----------------------------------------------------------------------------
63  // Finalization mix - force all bits of a hash block to avalanche
64 
65  h1 ^= h1 >> 16;
66  h1 *= 0x85ebca6b;
67  h1 ^= h1 >> 13;
68  h1 *= 0xc2b2ae35;
69  h1 ^= h1 >> 16;
70 
71  return h1;
72 }
#define ROTL32(x, y)
Definition: MurmurHash3Inl.h:9

+ Here is the caller graph for this function:

FORCE_INLINE DEVICE uint32_t rotl32 ( uint32_t  x,
int8_t  r 
)

Definition at line 5 of file MurmurHash3Inl.h.

5  {
6  return (x << r) | (x >> (32 - r));
7 }