Browse Source

update to newest sylvan version

main
dehnert 8 years ago
parent
commit
0135793c44
  1. 26
      resources/3rdparty/sylvan/src/sylvan_table.c
  2. 3
      resources/3rdparty/sylvan/src/sylvan_table.h

26
resources/3rdparty/sylvan/src/sylvan_table.c

@ -120,28 +120,15 @@ is_custom_bucket(const llmsset_t dbs, uint64_t index)
return (*ptr & mask) ? 1 : 0; return (*ptr & mask) ? 1 : 0;
} }
#ifndef rotl64
static inline uint64_t
rotl64(uint64_t x, int8_t r)
{
return ((x<<r) | (x>>(64-r)));
}
#endif
uint64_t uint64_t
llmsset_hash(const uint64_t a, const uint64_t b, const uint64_t seed) llmsset_hash(const uint64_t a, const uint64_t b, const uint64_t seed)
{ {
// The FNV-1a hash for 64 bits
const uint64_t prime = 1099511628211; const uint64_t prime = 1099511628211;
uint64_t hash = seed; uint64_t hash = seed;
hash = hash ^ a; hash = (hash ^ a) * prime;
hash = rotl64(hash, 47); hash = (hash ^ b) * prime;
hash = hash * prime; return hash;
hash = hash ^ b;
hash = rotl64(hash, 31);
hash = hash * prime;
return hash ^ (hash >> 32);
} }
/* /*
@ -163,6 +150,7 @@ llmsset_lookup2(const llmsset_t dbs, uint64_t a, uint64_t b, int* created, const
if (custom) hash_rehash = dbs->hash_cb(a, b, hash_rehash); if (custom) hash_rehash = dbs->hash_cb(a, b, hash_rehash);
else hash_rehash = llmsset_hash(a, b, hash_rehash); else hash_rehash = llmsset_hash(a, b, hash_rehash);
const uint64_t step = (((hash_rehash >> 20) | 1) << 3);
const uint64_t hash = hash_rehash & MASK_HASH; const uint64_t hash = hash_rehash & MASK_HASH;
uint64_t idx, last, cidx = 0; uint64_t idx, last, cidx = 0;
int i=0; int i=0;
@ -179,6 +167,7 @@ llmsset_lookup2(const llmsset_t dbs, uint64_t a, uint64_t b, int* created, const
if (v == 0) { if (v == 0) {
if (cidx == 0) { if (cidx == 0) {
// Claim data bucket and write data
cidx = claim_data_bucket(dbs); cidx = claim_data_bucket(dbs);
if (cidx == (uint64_t)-1) return 0; // failed to claim a data bucket if (cidx == (uint64_t)-1) return 0; // failed to claim a data bucket
if (custom) dbs->create_cb(&a, &b); if (custom) dbs->create_cb(&a, &b);
@ -224,8 +213,7 @@ llmsset_lookup2(const llmsset_t dbs, uint64_t a, uint64_t b, int* created, const
if (++i == dbs->threshold) return 0; // failed to find empty spot in probe sequence if (++i == dbs->threshold) return 0; // failed to find empty spot in probe sequence
// go to next cache line in probe sequence // go to next cache line in probe sequence
if (custom) hash_rehash = dbs->hash_cb(a, b, hash_rehash); hash_rehash += step;
else hash_rehash = llmsset_hash(a, b, hash_rehash);
#if LLMSSET_MASK #if LLMSSET_MASK
last = idx = hash_rehash & dbs->mask; last = idx = hash_rehash & dbs->mask;

3
resources/3rdparty/sylvan/src/sylvan_table.h

@ -132,7 +132,8 @@ llmsset_set_size(llmsset_t dbs, size_t size)
/* Warning: if size is not a power of two, you will get interesting behavior */ /* Warning: if size is not a power of two, you will get interesting behavior */
dbs->mask = dbs->table_size - 1; dbs->mask = dbs->table_size - 1;
#endif #endif
dbs->threshold = (64 - __builtin_clzll(dbs->table_size)) + 4; // doubling table_size increases threshold by 1 /* Set threshold: number of cache lines to probe before giving up on node insertion */
dbs->threshold = 192 - 2 * __builtin_clzll(dbs->table_size);
} }
} }

|||||||
100:0
Loading…
Cancel
Save