xxHash
0.8.0
Extremely fast non-cryptographic hash function
|
Macros | |
#define | XXH_RESTRICT /* disable */ |
#define | XXH_likely(x) (x) |
#define | XXH_unlikely(x) (x) |
#define | XXH_SEC_ALIGN XXH_ACC_ALIGN |
#define | XXH_SPLIT_IN_PLACE(in, outLo, outHi) |
#define | XXH_VSX_BE 0 |
#define | XXH_PREFETCH(ptr) (void)(ptr) /* disabled */ |
#define | XXH_SECRET_DEFAULT_SIZE 192 /* minimum XXH3_SECRET_SIZE_MIN */ |
#define | XXH3_MIDSIZE_MAX 240 |
#define | XXH_STRIPE_LEN 64 |
#define | XXH_SECRET_CONSUME_RATE 8 /* nb of secret bytes consumed at each accumulation */ |
#define | XXH_ACC_NB (XXH_STRIPE_LEN / sizeof(xxh_u64)) |
#define | XXH3_accumulate_512 XXH3_accumulate_512_avx512 |
#define | XXH3_scrambleAcc XXH3_scrambleAcc_avx512 |
#define | XXH3_initCustomSecret XXH3_initCustomSecret_avx512 |
#define | XXH_PREFETCH_DIST 512 |
#define | XXH3_INIT_ACC |
#define | XXH3_STREAM_USE_STACK 1 |
#define | XXH_MIN(x, y) (((x) > (y)) ? (y) : (x)) |
Typedefs | |
typedef __vector unsigned long long | xxh_u64x2 |
typedef __vector unsigned char | xxh_u8x16 |
typedef __vector unsigned | xxh_u32x4 |
typedef long long | xxh_i64 |
typedef void(* | XXH3_f_accumulate_512) (void *restrict, const void *, const void *) |
typedef void(* | XXH3_f_scrambleAcc) (void *restrict, const void *) |
typedef void(* | XXH3_f_initCustomSecret) (void *restrict, xxh_u64) |
typedef XXH64_hash_t(* | XXH3_hashLong64_f) (const void *restrict, size_t, XXH64_hash_t, const xxh_u8 *restrict, size_t) |
typedef XXH128_hash_t(* | XXH3_hashLong128_f) (const void *restrict, size_t, XXH64_hash_t, const void *restrict, size_t) |
Functions | |
static xxh_u64x2 | XXH_vec_loadu (const void *ptr) |
static xxh_u64x2 | XXH_vec_mulo (xxh_u32x4 a, xxh_u32x4 b) |
static xxh_u64x2 | XXH_vec_mule (xxh_u32x4 a, xxh_u32x4 b) |
static xxh_u64 | XXH_mult32to64 (xxh_u64 x, xxh_u64 y) |
Calculates a 32-bit to 64-bit long multiply. More... | |
static XXH128_hash_t | XXH_mult64to128 (xxh_u64 lhs, xxh_u64 rhs) |
Calculates a 64->128-bit long multiply. More... | |
static xxh_u64 | XXH3_mul128_fold64 (xxh_u64 lhs, xxh_u64 rhs) |
Calculates a 64-bit to 128-bit multiply, then XOR folds it. More... | |
static xxh_u64 | XXH_xorshift64 (xxh_u64 v64, int shift) |
static XXH64_hash_t | XXH3_avalanche (xxh_u64 h64) |
static XXH64_hash_t | XXH3_rrmxmx (xxh_u64 h64, xxh_u64 len) |
static XXH64_hash_t | XXH3_len_1to3_64b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH64_hash_t | XXH3_len_4to8_64b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH64_hash_t | XXH3_len_9to16_64b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH64_hash_t | XXH3_len_0to16_64b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static xxh_u64 | XXH3_mix16B (const xxh_u8 *restrict input, const xxh_u8 *restrict secret, xxh_u64 seed64) |
static XXH64_hash_t | XXH3_len_17to128_64b (const xxh_u8 *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH64_hash_t seed) |
static XXH64_hash_t | XXH3_len_129to240_64b (const xxh_u8 *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH64_hash_t seed) |
static void | XXH_writeLE64 (void *dst, xxh_u64 v64) |
static XXH_TARGET_AVX512 void | XXH3_accumulate_512_avx512 (void *restrict acc, const void *restrict input, const void *restrict secret) |
static XXH_TARGET_AVX512 void | XXH3_scrambleAcc_avx512 (void *restrict acc, const void *restrict secret) |
static XXH_TARGET_AVX512 void | XXH3_initCustomSecret_avx512 (void *restrict customSecret, xxh_u64 seed64) |
static XXH_TARGET_AVX2 void | XXH3_accumulate_512_avx2 (void *restrict acc, const void *restrict input, const void *restrict secret) |
static XXH_TARGET_AVX2 void | XXH3_scrambleAcc_avx2 (void *restrict acc, const void *restrict secret) |
static XXH_TARGET_AVX2 void | XXH3_initCustomSecret_avx2 (void *restrict customSecret, xxh_u64 seed64) |
static XXH_TARGET_SSE2 void | XXH3_accumulate_512_sse2 (void *restrict acc, const void *restrict input, const void *restrict secret) |
static XXH_TARGET_SSE2 void | XXH3_scrambleAcc_sse2 (void *restrict acc, const void *restrict secret) |
static XXH_TARGET_SSE2 void | XXH3_initCustomSecret_sse2 (void *restrict customSecret, xxh_u64 seed64) |
static void | XXH3_accumulate_512_neon (void *restrict acc, const void *restrict input, const void *restrict secret) |
static void | XXH3_scrambleAcc_neon (void *restrict acc, const void *restrict secret) |
static void | XXH3_accumulate_512_vsx (void *restrict acc, const void *restrict input, const void *restrict secret) |
static void | XXH3_scrambleAcc_vsx (void *restrict acc, const void *restrict secret) |
static void | XXH3_accumulate_512_scalar (void *restrict acc, const void *restrict input, const void *restrict secret) |
static void | XXH3_scrambleAcc_scalar (void *restrict acc, const void *restrict secret) |
static void | XXH3_initCustomSecret_scalar (void *restrict customSecret, xxh_u64 seed64) |
static void | XXH3_accumulate (xxh_u64 *restrict acc, const xxh_u8 *restrict input, const xxh_u8 *restrict secret, size_t nbStripes, XXH3_f_accumulate_512 f_acc512) |
static void | XXH3_hashLong_internal_loop (xxh_u64 *restrict acc, const xxh_u8 *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) |
static xxh_u64 | XXH3_mix2Accs (const xxh_u64 *restrict acc, const xxh_u8 *restrict secret) |
static XXH64_hash_t | XXH3_mergeAccs (const xxh_u64 *restrict acc, const xxh_u8 *restrict secret, xxh_u64 start) |
static XXH64_hash_t | XXH3_hashLong_64b_internal (const void *restrict input, size_t len, const void *restrict secret, size_t secretSize, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) |
static XXH64_hash_t | XXH3_hashLong_64b_withSecret (const void *restrict input, size_t len, XXH64_hash_t seed64, const xxh_u8 *restrict secret, size_t secretLen) |
static XXH64_hash_t | XXH3_hashLong_64b_default (const void *restrict input, size_t len, XXH64_hash_t seed64, const xxh_u8 *restrict secret, size_t secretLen) |
static XXH64_hash_t | XXH3_hashLong_64b_withSeed_internal (const void *input, size_t len, XXH64_hash_t seed, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble, XXH3_f_initCustomSecret f_initSec) |
static XXH64_hash_t | XXH3_hashLong_64b_withSeed (const void *input, size_t len, XXH64_hash_t seed, const xxh_u8 *secret, size_t secretLen) |
static XXH64_hash_t | XXH3_64bits_internal (const void *restrict input, size_t len, XXH64_hash_t seed64, const void *restrict secret, size_t secretLen, XXH3_hashLong64_f f_hashLong) |
XXH64_hash_t | XXH3_64bits_withSecretandSeed (const void *data, size_t len, const void *secret, size_t secretSize, XXH64_hash_t seed) |
static void * | XXH_alignedMalloc (size_t s, size_t align) |
static void | XXH_alignedFree (void *p) |
static void | XXH3_reset_internal (XXH3_state_t *statePtr, XXH64_hash_t seed, const void *secret, size_t secretSize) |
static void | XXH3_consumeStripes (xxh_u64 *restrict acc, size_t *restrict nbStripesSoFarPtr, size_t nbStripesPerBlock, const xxh_u8 *restrict input, size_t nbStripes, const xxh_u8 *restrict secret, size_t secretLimit, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) |
static XXH_errorcode | XXH3_update (XXH3_state_t *restrict const state, const xxh_u8 *restrict input, size_t len, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) |
static void | XXH3_digest_long (XXH64_hash_t *acc, const XXH3_state_t *state, const unsigned char *secret) |
static XXH128_hash_t | XXH3_len_1to3_128b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_len_4to8_128b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_len_9to16_128b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_len_0to16_128b (const xxh_u8 *input, size_t len, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH128_hash_t | XXH128_mix32B (XXH128_hash_t acc, const xxh_u8 *input_1, const xxh_u8 *input_2, const xxh_u8 *secret, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_len_17to128_128b (const xxh_u8 *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_len_129to240_128b (const xxh_u8 *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH64_hash_t seed) |
static XXH128_hash_t | XXH3_hashLong_128b_internal (const void *restrict input, size_t len, const xxh_u8 *restrict secret, size_t secretSize, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) |
static XXH128_hash_t | XXH3_hashLong_128b_default (const void *restrict input, size_t len, XXH64_hash_t seed64, const void *restrict secret, size_t secretLen) |
static XXH128_hash_t | XXH3_hashLong_128b_withSecret (const void *restrict input, size_t len, XXH64_hash_t seed64, const void *restrict secret, size_t secretLen) |
static XXH128_hash_t | XXH3_hashLong_128b_withSeed_internal (const void *restrict input, size_t len, XXH64_hash_t seed64, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble, XXH3_f_initCustomSecret f_initSec) |
static XXH128_hash_t | XXH3_hashLong_128b_withSeed (const void *input, size_t len, XXH64_hash_t seed64, const void *restrict secret, size_t secretLen) |
static XXH128_hash_t | XXH3_128bits_internal (const void *input, size_t len, XXH64_hash_t seed64, const void *restrict secret, size_t secretLen, XXH3_hashLong128_f f_hl128) |
static void | XXH3_combine16 (void *dst, XXH128_hash_t h128) |
Variables | |
static const xxh_u8 | XXH3_kSecret [XXH_SECRET_DEFAULT_SIZE] |
#define XXH_SPLIT_IN_PLACE | ( | in, | |
outLo, | |||
outHi | |||
) |
Function-like macro: void XXH_SPLIT_IN_PLACE(uint64x2_t &in, uint32x2_t &outLo, uint32x2_t &outHi) { outLo = (uint32x2_t)(in & 0xFFFFFFFF); outHi = (uint32x2_t)(in >> 32); in = UNDEFINED; }
#define XXH3_INIT_ACC |
|
inlinestatic |
Performs an unaligned vector load and byte swaps it on big endian.
|
inlinestatic |
Calculates a 32-bit to 64-bit long multiply.
Implemented as a macro.
Wraps __emulu
on MSVC x86 because it tends to call __allmul
when it doesn't need to (but it shouldn't need to anyways, it is about 7 instructions to do a 64x64 multiply...). Since we know that this will always emit MULL
, we use that instead of the normal method.
If you are compiling for platforms like Thumb-1 and don't have a better option, you may also want to write your own long multiply routine here.
x,y | Numbers to be multiplied |
x
and y
.
|
static |
Calculates a 64->128-bit long multiply.
Uses __uint128_t
and _umul128
if available, otherwise uses a scalar version.
lhs,rhs | The 64-bit integers to be multiplied |
|
static |
Calculates a 64-bit to 128-bit multiply, then XOR folds it.
The reason for the separate function is to prevent passing too many structs around by value. This will hopefully inline the multiply, but we don't force it.
lhs,rhs | The 64-bit integers to multiply |
|
inlinestatic |
Seems to produce slightly better code on GCC for some reason.
|
static |
Pseudorandom secret taken directly from FARSH.