Experiment with some really dumb hash functions
This commit is contained in:
parent
b0ec92798a
commit
f0b1d691ea
45
treetrie.c
45
treetrie.c
|
@ -8,17 +8,50 @@
|
|||
#include "treetrie.h"
|
||||
#include "fasthash.h"
|
||||
|
||||
/* /\* Customized special-purpose fasthash variation *\/ */
|
||||
/* #define mix(h) ({ \ */
|
||||
/* (h) ^= (h) >> 23; \ */
|
||||
/* (h) *= 0x2127599bf4325c37ULL; \ */
|
||||
/* (h) ^= (h) >> 47; }) */
|
||||
/* static inline uint64_t fasthash_4_ints(uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) { */
|
||||
/* const uint64_t m = 0x880355f21e6d1965ULL; */
|
||||
/* uint64_t h = (16 * m); */
|
||||
/* uint64_t v; */
|
||||
/* v = (((uint64_t) v2) << 32) | v1; */
|
||||
/* h ^= mix(v); */
|
||||
/* h *= m; */
|
||||
/* v = (((uint64_t) v4) << 32) | v3; */
|
||||
/* h ^= mix(v); */
|
||||
/* h *= m; */
|
||||
/* return mix(h); */
|
||||
/* } */
|
||||
|
||||
static inline tt_hash_t hash(uint32_t tag,
|
||||
uint32_t index,
|
||||
tt_node_idx_t a,
|
||||
tt_node_idx_t b)
|
||||
{
|
||||
uint32_t keyblock[4] = { tag,
|
||||
index,
|
||||
a,
|
||||
b };
|
||||
assert(sizeof(keyblock) == 4 * sizeof(uint32_t));
|
||||
return (tt_hash_t) fasthash32(keyblock, sizeof(keyblock), 0);
|
||||
/* uint64_t x = fasthash_4_ints(tag, index, a, b); */
|
||||
/* return x - (x >> 32); */
|
||||
|
||||
/* uint32_t keyblock[4] = { tag, */
|
||||
/* index, */
|
||||
/* a, */
|
||||
/* b }; */
|
||||
/* assert(sizeof(keyblock) == 4 * sizeof(uint32_t)); */
|
||||
/* return (tt_hash_t) fasthash32(keyblock, sizeof(keyblock), 0); */
|
||||
|
||||
/* uint64_t x = tag; */
|
||||
/* x = (x << 8) ^ index; */
|
||||
/* x = (x << 8) ^ a; */
|
||||
/* x = (x << 8) ^ b; */
|
||||
/* return x - (x >> 32); */
|
||||
|
||||
uint64_t x = tag;
|
||||
x ^= index * 11;
|
||||
x ^= a * 11;
|
||||
x ^= b * 11;
|
||||
return x - (x >> 32);
|
||||
}
|
||||
|
||||
inline tt_hash_t tt_hash_node(tt_arena_t *a, tt_node_idx_t i) {
|
||||
|
|
Loading…
Reference in New Issue