From bb094a09adf11d3f6706eec5ad73556c49bb8a0d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 17 Jun 2020 16:10:20 -0700 Subject: [PATCH 1/9] fixed demerphq avalanche tests for len [0-3] consequence : changes result of XXH3() for len [0-3] --- xxh3.h | 40 ++++++++++++++++++++++++---------------- xxhsum.c | 3 ++- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/xxh3.h b/xxh3.h index 9dc7f2ec..76ff4290 100644 --- a/xxh3.h +++ b/xxh3.h @@ -651,9 +651,8 @@ XXH_FORCE_INLINE xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) } /* - * We don't need to (or want to) mix as much as XXH64. - * - * Short hashes are more evenly distributed, so it isn't necessary. + * This is a fast avalanche stage, + * suitable when input bits are already partially mixed */ static XXH64_hash_t XXH3_avalanche(xxh_u64 h64) { @@ -663,6 +662,21 @@ static XXH64_hash_t XXH3_avalanche(xxh_u64 h64) return h64; } +/* + * This is a stronger avalanche, + * inspired by Pelle Evensen's rrmxmx + * preferable when input has not been previously mixed + */ +static XXH64_hash_t XXH3_rrmxmx(xxh_u64 h64, xxh_u64 len) +{ + /* this mix is inspired by Pelle Evensen's rrmxmx */ + h64 ^= XXH_rotl64(h64, 49) ^ XXH_rotl64(h64, 24); + h64 *= 0x9FB21C651E98DF25ULL; + h64 ^= (h64 >> 35) + len ; + h64 *= 0x9FB21C651E98DF25ULL; + return XXH_xorshift64(h64, 28); +} + /* ========================================== * Short keys @@ -708,15 +722,14 @@ XXH3_len_1to3_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h * len = 2: combined = { input[1], 0x02, input[0], input[1] } * len = 3: combined = { input[2], 0x03, input[0], input[1] } */ - { xxh_u8 const c1 = input[0]; - xxh_u8 const c2 = input[len >> 1]; - xxh_u8 const c3 = input[len - 1]; + { xxh_u8 const c1 = input[0]; + xxh_u8 const c2 = input[len >> 1]; + xxh_u8 const c3 = input[len - 1]; xxh_u32 const combined = ((xxh_u32)c1 << 16) | ((xxh_u32)c2 << 24) | ((xxh_u32)c3 << 0) | ((xxh_u32)len << 8); xxh_u64 const bitflip = (XXH_readLE32(secret) ^ XXH_readLE32(secret+4)) + seed; xxh_u64 const keyed = (xxh_u64)combined ^ bitflip; - xxh_u64 const mixed = keyed * XXH_PRIME64_1; - return XXH3_avalanche(mixed); + return XXH3_rrmxmx(keyed, 0); } } @@ -731,13 +744,8 @@ XXH3_len_4to8_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h xxh_u32 const input2 = XXH_readLE32(input + len - 4); xxh_u64 const bitflip = (XXH_readLE64(secret+8) ^ XXH_readLE64(secret+16)) - seed; xxh_u64 const input64 = input2 + (((xxh_u64)input1) << 32); - xxh_u64 x = input64 ^ bitflip; - /* this mix is inspired by Pelle Evensen's rrmxmx */ - x ^= XXH_rotl64(x, 49) ^ XXH_rotl64(x, 24); - x *= 0x9FB21C651E98DF25ULL; - x ^= (x >> 35) + len ; - x *= 0x9FB21C651E98DF25ULL; - return XXH_xorshift64(x, 28); + xxh_u64 const keyed = input64 ^ bitflip; + return XXH3_rrmxmx(keyed, len); } } @@ -765,7 +773,7 @@ XXH3_len_0to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ { if (XXH_likely(len > 8)) return XXH3_len_9to16_64b(input, len, secret, seed); if (XXH_likely(len >= 4)) return XXH3_len_4to8_64b(input, len, secret, seed); if (len) return XXH3_len_1to3_64b(input, len, secret, seed); - return XXH3_avalanche((XXH_PRIME64_1 + seed) ^ (XXH_readLE64(secret+56) ^ XXH_readLE64(secret+64))); + return XXH3_rrmxmx(seed ^ (XXH_readLE64(secret+56) ^ XXH_readLE64(secret+64)), 0); } } diff --git a/xxhsum.c b/xxhsum.c index 5450b4a7..6c40237d 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1181,6 +1181,7 @@ static void BMK_sanityCheck(void) BMK_testXXH64(sanityBuffer,222, 0, 0xB641AE8CB691C174ULL); BMK_testXXH64(sanityBuffer,222, PRIME32, 0x20CB8AB7AE10C14AULL); +#if 0 BMK_testXXH3(NULL, 0, 0, 0x776EDDFB6BFD9195ULL); /* empty string */ BMK_testXXH3(NULL, 0, PRIME64, 0x6AFCE90814C488CBULL); BMK_testXXH3(sanityBuffer, 1, 0, 0xB936EBAE24CB01C5ULL); /* 1 - 3 */ @@ -1307,7 +1308,7 @@ static void BMK_sanityCheck(void) { XXH128_hash_t const expected = { 0x6F5360AE69C2F406ULL, 0xD23AAE4B76C31ECBULL }; BMK_testXXH128(sanityBuffer,2367, PRIME32, expected); /* two blocks, last stripe is overlapping */ } - +#endif /* secret generator */ { verifSample_t const expected = { { 0xB8, 0x26, 0x83, 0x7E } }; From 6e1ba913bb8f04b8b0a2eb0e210d5ea09a82dc7e Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Jun 2020 00:17:03 -0700 Subject: [PATCH 2/9] fixed XXH128 seed avalanche for inputs of len [0-3] --- xxh3.h | 14 ++++++-------- xxhsum.c | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/xxh3.h b/xxh3.h index 76ff4290..2bf45d78 100644 --- a/xxh3.h +++ b/xxh3.h @@ -729,7 +729,7 @@ XXH3_len_1to3_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h | ((xxh_u32)c3 << 0) | ((xxh_u32)len << 8); xxh_u64 const bitflip = (XXH_readLE32(secret) ^ XXH_readLE32(secret+4)) + seed; xxh_u64 const keyed = (xxh_u64)combined ^ bitflip; - return XXH3_rrmxmx(keyed, 0); + return XXH64_avalanche(keyed); } } @@ -773,7 +773,7 @@ XXH3_len_0to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ { if (XXH_likely(len > 8)) return XXH3_len_9to16_64b(input, len, secret, seed); if (XXH_likely(len >= 4)) return XXH3_len_4to8_64b(input, len, secret, seed); if (len) return XXH3_len_1to3_64b(input, len, secret, seed); - return XXH3_rrmxmx(seed ^ (XXH_readLE64(secret+56) ^ XXH_readLE64(secret+64)), 0); + return XXH64_avalanche(seed ^ (XXH_readLE64(secret+56) ^ XXH_readLE64(secret+64))); } } @@ -2243,11 +2243,9 @@ XXH3_len_1to3_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ xxh_u64 const bitfliph = (XXH_readLE32(secret+8) ^ XXH_readLE32(secret+12)) - seed; xxh_u64 const keyed_lo = (xxh_u64)combinedl ^ bitflipl; xxh_u64 const keyed_hi = (xxh_u64)combinedh ^ bitfliph; - xxh_u64 const mixedl = keyed_lo * XXH_PRIME64_1; - xxh_u64 const mixedh = keyed_hi * XXH_PRIME64_5; XXH128_hash_t h128; - h128.low64 = XXH3_avalanche(mixedl); - h128.high64 = XXH3_avalanche(mixedh); + h128.low64 = XXH64_avalanche(keyed_lo); + h128.high64 = XXH64_avalanche(keyed_hi); return h128; } } @@ -2364,8 +2362,8 @@ XXH3_len_0to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64 { XXH128_hash_t h128; xxh_u64 const bitflipl = XXH_readLE64(secret+64) ^ XXH_readLE64(secret+72); xxh_u64 const bitfliph = XXH_readLE64(secret+80) ^ XXH_readLE64(secret+88); - h128.low64 = XXH3_avalanche((XXH_PRIME64_1 + seed) ^ bitflipl); - h128.high64 = XXH3_avalanche((XXH_PRIME64_2 - seed) ^ bitfliph); + h128.low64 = XXH64_avalanche(seed ^ bitflipl); + h128.high64 = XXH64_avalanche( seed ^ bitfliph); return h128; } } } diff --git a/xxhsum.c b/xxhsum.c index 6c40237d..ace5f0c7 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1308,7 +1308,6 @@ static void BMK_sanityCheck(void) { XXH128_hash_t const expected = { 0x6F5360AE69C2F406ULL, 0xD23AAE4B76C31ECBULL }; BMK_testXXH128(sanityBuffer,2367, PRIME32, expected); /* two blocks, last stripe is overlapping */ } -#endif /* secret generator */ { verifSample_t const expected = { { 0xB8, 0x26, 0x83, 0x7E } }; @@ -1326,6 +1325,7 @@ static void BMK_sanityCheck(void) { verifSample_t const expected = { { 0x7E, 0x48, 0x0C, 0xA7 } }; BMK_testSecretGenerator(sanityBuffer, XXH3_SECRET_DEFAULT_SIZE + 500, expected); } +#endif DISPLAYLEVEL(3, "\r%70s\r", ""); /* Clean display line */ From 469274ab6726d8b622d819b10261e90561cdbb54 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 22 Jun 2020 15:48:50 -0700 Subject: [PATCH 3/9] replaced the default kSecret by decimals of Pi should be random enough --- xxh3.h | 27 +++++++++++++-------------- xxhsum.c | 3 ++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xxh3.h b/xxh3.h index 8e9ba183..da980dd0 100644 --- a/xxh3.h +++ b/xxh3.h @@ -465,21 +465,20 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) # error "default keyset is not large enough" #endif -/* Pseudorandom secret taken directly from FARSH */ +/* Pseudorandom secret, represented by the decimals of Pi */ XXH_ALIGN(64) static const xxh_u8 XXH3_kSecret[XXH_SECRET_DEFAULT_SIZE] = { - 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, - 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, - 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, - 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, - 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, - 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, - 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d, - 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64, - - 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, - 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, - 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, - 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, + 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, + 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89, + 0x45, 0x28, 0x21, 0xE6, 0x38, 0xD0, 0x13, 0x77, 0xBE, 0x54, 0x66, 0xCF, 0x34, 0xE9, 0x0C, 0x6C, + 0xC0, 0xAC, 0x29, 0xB7, 0xC9, 0x7C, 0x50, 0xDD, 0x3F, 0x84, 0xD5, 0xB5, 0xB5, 0x47, 0x09, 0x17, + 0x92, 0x16, 0xD5, 0xD9, 0x89, 0x79, 0xFB, 0x1B, 0xD1, 0x31, 0x0B, 0xA6, 0x98, 0xDF, 0xB5, 0xAC, + 0x2F, 0xFD, 0x72, 0xDB, 0xD0, 0x1A, 0xDF, 0xB7, 0xB8, 0xE1, 0xAF, 0xED, 0x6A, 0x26, 0x7E, 0x96, + 0xBA, 0x7C, 0x90, 0x45, 0xF1, 0x2C, 0x7F, 0x99, 0x24, 0xA1, 0x99, 0x47, 0xB3, 0x91, 0x6C, 0xF7, + 0x08, 0x01, 0xF2, 0xE2, 0x85, 0x8E, 0xFC, 0x16, 0x63, 0x69, 0x20, 0xD8, 0x71, 0x57, 0x4E, 0x69, + 0xA4, 0x58, 0xFE, 0xA3, 0xF4, 0x93, 0x3D, 0x7E, 0x0D, 0x95, 0x74, 0x8F, 0x72, 0x8E, 0xB6, 0x58, + 0x71, 0x8B, 0xCD, 0x58, 0x82, 0x15, 0x4A, 0xEE, 0x7B, 0x54, 0xA4, 0x1D, 0xC2, 0x5A, 0x59, 0xB5, + 0x9C, 0x30, 0xD5, 0x39, 0x2A, 0xF2, 0x60, 0x13, 0xC5, 0xD1, 0xB0, 0x23, 0x28, 0x60, 0x85, 0xF0, + 0xCA, 0x41, 0x79, 0x18, 0xB8, 0xDB, 0x38, 0xEF, 0x8E, 0x79, 0xDC, 0xB0, 0x60, 0x3A, 0x18, 0x0E, }; #ifdef XXH_OLD_NAMES diff --git a/xxhsum.c b/xxhsum.c index 6dcdf739..1320cec8 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1220,6 +1220,7 @@ static void BMK_sanityCheck(void) BMK_testXXH64(sanityBuffer,222, 0, 0xB641AE8CB691C174ULL); BMK_testXXH64(sanityBuffer,222, PRIME32, 0x20CB8AB7AE10C14AULL); +#if 0 BMK_testXXH3(NULL, 0, 0, 0x776EDDFB6BFD9195ULL); /* empty string */ BMK_testXXH3(NULL, 0, PRIME64, 0x6AFCE90814C488CBULL); BMK_testXXH3(sanityBuffer, 1, 0, 0xB936EBAE24CB01C5ULL); /* 1 - 3 */ @@ -1385,7 +1386,7 @@ static void BMK_sanityCheck(void) { verifSample_t const expected = { { 0x7E, 0x48, 0x0C, 0xA7 } }; BMK_testSecretGenerator(sanityBuffer, XXH3_SECRET_DEFAULT_SIZE + 500, expected); } - +#endif DISPLAYLEVEL(3, "\r%70s\r", ""); /* Clean display line */ DISPLAYLEVEL(3, "Sanity check -- all tests ok\n"); From 6e5d5d766800fc4134a3623ca49a48151d283c0d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 22 Jun 2020 21:40:07 -0700 Subject: [PATCH 4/9] do not scramble when input len is multiple of block size also : always use "last secret" for last stripe changes suggested by @gzm55 --- xxh3.h | 71 ++++++++++++++++++++++++++++---------------------------- xxhsum.c | 7 ++++++ 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/xxh3.h b/xxh3.h index da980dd0..366f6216 100644 --- a/xxh3.h +++ b/xxh3.h @@ -1673,30 +1673,28 @@ XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) { - size_t const nb_rounds = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; - size_t const block_len = XXH_STRIPE_LEN * nb_rounds; - size_t const nb_blocks = len / block_len; + size_t const nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; + size_t const block_len = XXH_STRIPE_LEN * nbStripesPerBlock; + size_t const nb_blocks = (len - 1) / block_len; size_t n; XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); for (n = 0; n < nb_blocks; n++) { - XXH3_accumulate(acc, input + n*block_len, secret, nb_rounds, accWidth, f_acc512); + XXH3_accumulate(acc, input + n*block_len, secret, nbStripesPerBlock, accWidth, f_acc512); f_scramble(acc, secret + secretSize - XXH_STRIPE_LEN); } /* last partial block */ XXH_ASSERT(len > XXH_STRIPE_LEN); - { size_t const nbStripes = (len - (block_len * nb_blocks)) / XXH_STRIPE_LEN; + { size_t const nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; XXH_ASSERT(nbStripes <= (secretSize / XXH_SECRET_CONSUME_RATE)); XXH3_accumulate(acc, input + nb_blocks*block_len, secret, nbStripes, accWidth, f_acc512); /* last stripe */ - if (len & (XXH_STRIPE_LEN - 1)) { - const xxh_u8* const p = input + len - XXH_STRIPE_LEN; - /* Do not align on 8, so that the secret is different from the scrambler */ -#define XXH_SECRET_LASTACC_START 7 + { const xxh_u8* const p = input + len - XXH_STRIPE_LEN; +#define XXH_SECRET_LASTACC_START 7 /* not aligned on 8, last secret is different from acc & scrambler */ f_acc512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START, accWidth); } } } @@ -2006,6 +2004,9 @@ XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed) return XXH_OK; } +/* Note : when XXH3_consumeStripes() is invoked, + * there must be a guarantee that at least one more byte must be consumed from input + * so that the function can blindly consume all stripes using the "normal" secret segment */ XXH_FORCE_INLINE void XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, size_t* XXH_RESTRICT nbStripesSoFarPtr, size_t nbStripesPerBlock, @@ -2058,14 +2059,14 @@ XXH3_update(XXH3_state_t* state, state->bufferedSize += (XXH32_hash_t)len; return XXH_OK; } - /* input is now > XXH3_INTERNALBUFFER_SIZE */ + /* total input is now > XXH3_INTERNALBUFFER_SIZE */ #define XXH3_INTERNALBUFFER_STRIPES (XXH3_INTERNALBUFFER_SIZE / XXH_STRIPE_LEN) XXH_STATIC_ASSERT(XXH3_INTERNALBUFFER_SIZE % XXH_STRIPE_LEN == 0); /* clean multiple */ /* - * There is some input left inside the internal buffer. - * Fill it, then consume it. + * Internal buffer is partially filled (always, except at beginning) + * Complete it, then consume it. */ if (state->bufferedSize) { size_t const loadSize = XXH3_INTERNALBUFFER_SIZE - state->bufferedSize; @@ -2078,9 +2079,10 @@ XXH3_update(XXH3_state_t* state, accWidth, f_acc512, f_scramble); state->bufferedSize = 0; } + XXH_ASSERT(input < bEnd); /* Consume input by a multiple of internal buffer size */ - if (input+XXH3_INTERNALBUFFER_SIZE <= bEnd) { + if (input+XXH3_INTERNALBUFFER_SIZE < bEnd) { const xxh_u8* const limit = bEnd - XXH3_INTERNALBUFFER_SIZE; do { XXH3_consumeStripes(state->acc, @@ -2089,15 +2091,15 @@ XXH3_update(XXH3_state_t* state, secret, state->secretLimit, accWidth, f_acc512, f_scramble); input += XXH3_INTERNALBUFFER_SIZE; - } while (input<=limit); + } while (inputbuffer + sizeof(state->buffer) - XXH_STRIPE_LEN, input - XXH_STRIPE_LEN, XXH_STRIPE_LEN); } + XXH_ASSERT(input < bEnd); - if (input < bEnd) { /* Some remaining input: buffer it */ - XXH_memcpy(state->buffer, input, (size_t)(bEnd-input)); - state->bufferedSize = (XXH32_hash_t)(bEnd-input); - } + /* Some remaining input (always) : buffer it */ + XXH_memcpy(state->buffer, input, (size_t)(bEnd-input)); + state->bufferedSize = (XXH32_hash_t)(bEnd-input); } return XXH_OK; @@ -2123,30 +2125,29 @@ XXH3_digest_long (XXH64_hash_t* acc, */ memcpy(acc, state->acc, sizeof(state->acc)); if (state->bufferedSize >= XXH_STRIPE_LEN) { - size_t const nbStripes = state->bufferedSize / XXH_STRIPE_LEN; + size_t const nbStripes = (state->bufferedSize - 1) / XXH_STRIPE_LEN; size_t nbStripesSoFar = state->nbStripesSoFar; XXH3_consumeStripes(acc, &nbStripesSoFar, state->nbStripesPerBlock, state->buffer, nbStripes, secret, state->secretLimit, accWidth, XXH3_accumulate_512, XXH3_scrambleAcc); - if (state->bufferedSize % XXH_STRIPE_LEN) { /* one last partial stripe */ - XXH3_accumulate_512(acc, - state->buffer + state->bufferedSize - XXH_STRIPE_LEN, - secret + state->secretLimit - XXH_SECRET_LASTACC_START, - accWidth); - } + /* last stripe */ + XXH3_accumulate_512(acc, + state->buffer + state->bufferedSize - XXH_STRIPE_LEN, + secret + state->secretLimit - XXH_SECRET_LASTACC_START, + accWidth); } else { /* bufferedSize < XXH_STRIPE_LEN */ - if (state->bufferedSize) { /* one last stripe */ - xxh_u8 lastStripe[XXH_STRIPE_LEN]; - size_t const catchupSize = XXH_STRIPE_LEN - state->bufferedSize; - memcpy(lastStripe, state->buffer + sizeof(state->buffer) - catchupSize, catchupSize); - memcpy(lastStripe + catchupSize, state->buffer, state->bufferedSize); - XXH3_accumulate_512(acc, - lastStripe, - secret + state->secretLimit - XXH_SECRET_LASTACC_START, - accWidth); - } } + xxh_u8 lastStripe[XXH_STRIPE_LEN]; + size_t const catchupSize = XXH_STRIPE_LEN - state->bufferedSize; + XXH_ASSERT(state->bufferedSize > 0); /* there is always some input buffered */ + memcpy(lastStripe, state->buffer + sizeof(state->buffer) - catchupSize, catchupSize); + memcpy(lastStripe + catchupSize, state->buffer, state->bufferedSize); + XXH3_accumulate_512(acc, + lastStripe, + secret + state->secretLimit - XXH_SECRET_LASTACC_START, + accWidth); + } } XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state) diff --git a/xxhsum.c b/xxhsum.c index 1320cec8..4a60874b 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1220,6 +1220,13 @@ static void BMK_sanityCheck(void) BMK_testXXH64(sanityBuffer,222, 0, 0xB641AE8CB691C174ULL); BMK_testXXH64(sanityBuffer,222, PRIME32, 0x20CB8AB7AE10C14AULL); + BMK_testXXH3(sanityBuffer, 403, 0, 0x1C03A3D9C038A896ULL); /* one block, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer, 403, PRIME64, 0x4849612208F3A069ULL); /* one block, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer, 512, 0, 0x88BE504C335A7BF0ULL); /* one block, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer, 512, PRIME64, 0x2FFFA17063B595DEULL); /* one block, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer,2048, 0, 0xFB37C3C889A504DFULL); /* 2 blocks, finishing at block boundary */ + BMK_testXXH3(sanityBuffer,2048, PRIME64, 0x42F89143D4C087B6ULL); /* 2 blocks, finishing at block boundary */ + #if 0 BMK_testXXH3(NULL, 0, 0, 0x776EDDFB6BFD9195ULL); /* empty string */ BMK_testXXH3(NULL, 0, PRIME64, 0x6AFCE90814C488CBULL); From be32411fcc672dfad1216dc555eb44d8d9ff8fda Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 23 Jun 2020 14:46:48 -0700 Subject: [PATCH 5/9] reverted default secret to Farsh --- xxh3.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/xxh3.h b/xxh3.h index 3c23acae..17c65aa6 100644 --- a/xxh3.h +++ b/xxh3.h @@ -465,22 +465,23 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) # error "default keyset is not large enough" #endif -/* Pseudorandom secret, represented by the decimals of Pi */ +/* Pseudorandom secret taken directly from FARSH */ XXH_ALIGN(64) static const xxh_u8 XXH3_kSecret[XXH_SECRET_DEFAULT_SIZE] = { - 0x24, 0x3F, 0x6A, 0x88, 0x85, 0xA3, 0x08, 0xD3, 0x13, 0x19, 0x8A, 0x2E, 0x03, 0x70, 0x73, 0x44, - 0xA4, 0x09, 0x38, 0x22, 0x29, 0x9F, 0x31, 0xD0, 0x08, 0x2E, 0xFA, 0x98, 0xEC, 0x4E, 0x6C, 0x89, - 0x45, 0x28, 0x21, 0xE6, 0x38, 0xD0, 0x13, 0x77, 0xBE, 0x54, 0x66, 0xCF, 0x34, 0xE9, 0x0C, 0x6C, - 0xC0, 0xAC, 0x29, 0xB7, 0xC9, 0x7C, 0x50, 0xDD, 0x3F, 0x84, 0xD5, 0xB5, 0xB5, 0x47, 0x09, 0x17, - 0x92, 0x16, 0xD5, 0xD9, 0x89, 0x79, 0xFB, 0x1B, 0xD1, 0x31, 0x0B, 0xA6, 0x98, 0xDF, 0xB5, 0xAC, - 0x2F, 0xFD, 0x72, 0xDB, 0xD0, 0x1A, 0xDF, 0xB7, 0xB8, 0xE1, 0xAF, 0xED, 0x6A, 0x26, 0x7E, 0x96, - 0xBA, 0x7C, 0x90, 0x45, 0xF1, 0x2C, 0x7F, 0x99, 0x24, 0xA1, 0x99, 0x47, 0xB3, 0x91, 0x6C, 0xF7, - 0x08, 0x01, 0xF2, 0xE2, 0x85, 0x8E, 0xFC, 0x16, 0x63, 0x69, 0x20, 0xD8, 0x71, 0x57, 0x4E, 0x69, - 0xA4, 0x58, 0xFE, 0xA3, 0xF4, 0x93, 0x3D, 0x7E, 0x0D, 0x95, 0x74, 0x8F, 0x72, 0x8E, 0xB6, 0x58, - 0x71, 0x8B, 0xCD, 0x58, 0x82, 0x15, 0x4A, 0xEE, 0x7B, 0x54, 0xA4, 0x1D, 0xC2, 0x5A, 0x59, 0xB5, - 0x9C, 0x30, 0xD5, 0x39, 0x2A, 0xF2, 0x60, 0x13, 0xC5, 0xD1, 0xB0, 0x23, 0x28, 0x60, 0x85, 0xF0, - 0xCA, 0x41, 0x79, 0x18, 0xB8, 0xDB, 0x38, 0xEF, 0x8E, 0x79, 0xDC, 0xB0, 0x60, 0x3A, 0x18, 0x0E, + 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c, + 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f, + 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21, + 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c, + 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3, + 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8, + 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d, + 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64, + 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb, + 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e, + 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce, + 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, }; + #ifdef XXH_OLD_NAMES # define kSecret XXH3_kSecret #endif From 3cc3e490141789bc8275617878c0884a7ded821d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 23 Jun 2020 15:00:34 -0700 Subject: [PATCH 6/9] removed extraneous tests necessarily wrong, due to ongoing changes to default secret --- xxhsum.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/xxhsum.c b/xxhsum.c index 1b04e061..3e596db9 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1220,13 +1220,6 @@ static void BMK_sanityCheck(void) BMK_testXXH64(sanityBuffer,222, 0, 0xB641AE8CB691C174ULL); BMK_testXXH64(sanityBuffer,222, PRIME32, 0x20CB8AB7AE10C14AULL); - BMK_testXXH3(sanityBuffer, 403, 0, 0x1C03A3D9C038A896ULL); /* one block, last stripe is overlapping */ - BMK_testXXH3(sanityBuffer, 403, PRIME64, 0x4849612208F3A069ULL); /* one block, last stripe is overlapping */ - BMK_testXXH3(sanityBuffer, 512, 0, 0x88BE504C335A7BF0ULL); /* one block, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer, 512, PRIME64, 0x2FFFA17063B595DEULL); /* one block, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer,2048, 0, 0xFB37C3C889A504DFULL); /* 2 blocks, finishing at block boundary */ - BMK_testXXH3(sanityBuffer,2048, PRIME64, 0x42F89143D4C087B6ULL); /* 2 blocks, finishing at block boundary */ - #if 0 BMK_testXXH3(NULL, 0, 0, 0x776EDDFB6BFD9195ULL); /* empty string */ BMK_testXXH3(NULL, 0, PRIME64, 0x6AFCE90814C488CBULL); From 954843658240dcadf58789c928761240faf362a7 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 24 Jun 2020 00:41:16 -0700 Subject: [PATCH 7/9] use 128-bit mixing even in 64-bit mode --- xxh3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xxh3.h b/xxh3.h index 17c65aa6..ed27ffb2 100644 --- a/xxh3.h +++ b/xxh3.h @@ -1754,7 +1754,7 @@ XXH3_hashLong_64b_internal(const xxh_u8* XXH_RESTRICT input, size_t len, { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; - XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_64bits, f_acc512, f_scramble); + XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_128bits, f_acc512, f_scramble); /* converge into final hash */ XXH_STATIC_ASSERT(sizeof(acc) == 64); From 6ab5932983efd1e1a4dba3b553322c5d6f3be40a Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 24 Jun 2020 13:07:31 -0700 Subject: [PATCH 8/9] XXH3 mixer is now the same as XXH128 Simplify code --- xxh3.h | 151 +++++++++++++++------------------------------- xxh_x86dispatch.c | 16 ++--- 2 files changed, 58 insertions(+), 109 deletions(-) diff --git a/xxh3.h b/xxh3.h index ed27ffb2..07cd911f 100644 --- a/xxh3.h +++ b/xxh3.h @@ -931,8 +931,6 @@ XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len, # define ACC_NB XXH_ACC_NB #endif -typedef enum { XXH3_acc_64bits, XXH3_acc_128bits } XXH3_accWidth_e; - XXH_FORCE_INLINE void XXH_writeLE64(void* dst, xxh_u64 v64) { if (!XXH_CPU_LITTLE_ENDIAN) v64 = XXH_swap64(v64); @@ -985,8 +983,7 @@ XXH_FORCE_INLINE void XXH_writeLE64(void* dst, xxh_u64 v64) XXH_FORCE_INLINE XXH_TARGET_AVX512 void XXH3_accumulate_512_avx512(void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { XXH_ALIGN(64) __m512i* const xacc = (__m512i *) acc; XXH_ASSERT((((size_t)acc) & 63) == 0); @@ -1003,18 +1000,11 @@ XXH3_accumulate_512_avx512(void* XXH_RESTRICT acc, __m512i const data_key_lo = _mm512_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */ __m512i const product = _mm512_mul_epu32 (data_key, data_key_lo); - if (accWidth == XXH3_acc_128bits) { - /* xacc[0] += swap(data_vec); */ - __m512i const data_swap = _mm512_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); - __m512i const sum = _mm512_add_epi64(*xacc, data_swap); - /* xacc[0] += product; */ - *xacc = _mm512_add_epi64(product, sum); - } else { /* XXH3_acc_64bits */ - /* xacc[0] += data_vec; */ - __m512i const sum = _mm512_add_epi64(*xacc, data_vec); - /* xacc[0] += product; */ - *xacc = _mm512_add_epi64(product, sum); - } + /* xacc[0] += swap(data_vec); */ + __m512i const data_swap = _mm512_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); + __m512i const sum = _mm512_add_epi64(*xacc, data_swap); + /* xacc[0] += product; */ + *xacc = _mm512_add_epi64(product, sum); } } @@ -1098,8 +1088,7 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64) XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_accumulate_512_avx2( void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { XXH_ASSERT((((size_t)acc) & 31) == 0); { XXH_ALIGN(32) __m256i* const xacc = (__m256i *) acc; @@ -1122,18 +1111,11 @@ XXH3_accumulate_512_avx2( void* XXH_RESTRICT acc, __m256i const data_key_lo = _mm256_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */ __m256i const product = _mm256_mul_epu32 (data_key, data_key_lo); - if (accWidth == XXH3_acc_128bits) { - /* xacc[i] += swap(data_vec); */ - __m256i const data_swap = _mm256_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); - __m256i const sum = _mm256_add_epi64(xacc[i], data_swap); - /* xacc[i] += product; */ - xacc[i] = _mm256_add_epi64(product, sum); - } else { /* XXH3_acc_64bits */ - /* xacc[i] += data_vec; */ - __m256i const sum = _mm256_add_epi64(xacc[i], data_vec); - /* xacc[i] += product; */ - xacc[i] = _mm256_add_epi64(product, sum); - } + /* xacc[i] += swap(data_vec); */ + __m256i const data_swap = _mm256_shuffle_epi32(data_vec, _MM_SHUFFLE(1, 0, 3, 2)); + __m256i const sum = _mm256_add_epi64(xacc[i], data_swap); + /* xacc[i] += product; */ + xacc[i] = _mm256_add_epi64(product, sum); } } } @@ -1212,8 +1194,7 @@ XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_initCustomSecret_avx2(void* XXH_RESTR XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_accumulate_512_sse2( void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { /* SSE2 is just a half-scale version of the AVX2 version. */ XXH_ASSERT((((size_t)acc) & 15) == 0); @@ -1237,18 +1218,11 @@ XXH3_accumulate_512_sse2( void* XXH_RESTRICT acc, __m128i const data_key_lo = _mm_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */ __m128i const product = _mm_mul_epu32 (data_key, data_key_lo); - if (accWidth == XXH3_acc_128bits) { - /* xacc[i] += swap(data_vec); */ - __m128i const data_swap = _mm_shuffle_epi32(data_vec, _MM_SHUFFLE(1,0,3,2)); - __m128i const sum = _mm_add_epi64(xacc[i], data_swap); - /* xacc[i] += product; */ - xacc[i] = _mm_add_epi64(product, sum); - } else { /* XXH3_acc_64bits */ - /* xacc[i] += data_vec; */ - __m128i const sum = _mm_add_epi64(xacc[i], data_vec); - /* xacc[i] += product; */ - xacc[i] = _mm_add_epi64(product, sum); - } + /* xacc[i] += swap(data_vec); */ + __m128i const data_swap = _mm_shuffle_epi32(data_vec, _MM_SHUFFLE(1,0,3,2)); + __m128i const sum = _mm_add_epi64(xacc[i], data_swap); + /* xacc[i] += product; */ + xacc[i] = _mm_add_epi64(product, sum); } } } @@ -1319,8 +1293,7 @@ XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_initCustomSecret_sse2(void* XXH_RESTR XXH_FORCE_INLINE void XXH3_accumulate_512_neon( void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { XXH_ASSERT((((size_t)acc) & 15) == 0); { @@ -1337,15 +1310,10 @@ XXH3_accumulate_512_neon( void* XXH_RESTRICT acc, uint8x16_t key_vec = vld1q_u8(xsecret + (i * 16)); uint64x2_t data_key; uint32x2_t data_key_lo, data_key_hi; - if (accWidth == XXH3_acc_64bits) { - /* xacc[i] += data_vec; */ - xacc[i] = vaddq_u64 (xacc[i], vreinterpretq_u64_u8(data_vec)); - } else { /* XXH3_acc_128bits */ - /* xacc[i] += swap(data_vec); */ - uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec); - uint64x2_t const swapped = vextq_u64(data64, data64, 1); - xacc[i] = vaddq_u64 (xacc[i], swapped); - } + /* xacc[i] += swap(data_vec); */ + uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec); + uint64x2_t const swapped = vextq_u64(data64, data64, 1); + xacc[i] = vaddq_u64 (xacc[i], swapped); /* data_key = data_vec ^ key_vec; */ data_key = vreinterpretq_u64_u8(veorq_u8(data_vec, key_vec)); /* data_key_lo = (uint32x2_t) (data_key & 0xFFFFFFFF); @@ -1419,8 +1387,7 @@ XXH3_scrambleAcc_neon(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) XXH_FORCE_INLINE void XXH3_accumulate_512_vsx( void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { xxh_u64x2* const xacc = (xxh_u64x2*) acc; /* presumed aligned */ xxh_u64x2 const* const xinput = (xxh_u64x2 const*) input; /* no alignment restriction */ @@ -1439,17 +1406,13 @@ XXH3_accumulate_512_vsx( void* XXH_RESTRICT acc, xxh_u64x2 const product = XXH_vec_mulo((xxh_u32x4)data_key, shuffled); xacc[i] += product; - if (accWidth == XXH3_acc_64bits) { - xacc[i] += data_vec; - } else { /* XXH3_acc_128bits */ - /* swap high and low halves */ + /* swap high and low halves */ #ifdef __s390x__ - xxh_u64x2 const data_swapped = vec_permi(data_vec, data_vec, 2); + xxh_u64x2 const data_swapped = vec_permi(data_vec, data_vec, 2); #else - xxh_u64x2 const data_swapped = vec_xxpermdi(data_vec, data_vec, 2); + xxh_u64x2 const data_swapped = vec_xxpermdi(data_vec, data_vec, 2); #endif - xacc[i] += data_swapped; - } + xacc[i] += data_swapped; } } @@ -1490,8 +1453,7 @@ XXH3_scrambleAcc_vsx(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) XXH_FORCE_INLINE void XXH3_accumulate_512_scalar(void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, - const void* XXH_RESTRICT secret, - XXH3_accWidth_e accWidth) + const void* XXH_RESTRICT secret) { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned */ const xxh_u8* const xinput = (const xxh_u8*) input; /* no alignment restriction */ @@ -1501,12 +1463,7 @@ XXH3_accumulate_512_scalar(void* XXH_RESTRICT acc, for (i=0; i < XXH_ACC_NB; i++) { xxh_u64 const data_val = XXH_readLE64(xinput + 8*i); xxh_u64 const data_key = data_val ^ XXH_readLE64(xsecret + i*8); - - if (accWidth == XXH3_acc_64bits) { - xacc[i] += data_val; - } else { - xacc[i ^ 1] += data_val; /* swap adjacent lanes */ - } + xacc[i ^ 1] += data_val; /* swap adjacent lanes */ xacc[i] += XXH_mult32to64(data_key & 0xFFFFFFFF, data_key >> 32); } } @@ -1593,7 +1550,7 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64) } -typedef void (*XXH3_f_accumulate_512)(void* XXH_RESTRICT, const void*, const void*, XXH3_accWidth_e); +typedef void (*XXH3_f_accumulate_512)(void* XXH_RESTRICT, const void*, const void*); typedef void (*XXH3_f_scrambleAcc)(void* XXH_RESTRICT, const void*); typedef void (*XXH3_f_initCustomSecret)(void* XXH_RESTRICT, xxh_u64); @@ -1660,7 +1617,6 @@ XXH3_accumulate( xxh_u64* XXH_RESTRICT acc, const xxh_u8* XXH_RESTRICT input, const xxh_u8* XXH_RESTRICT secret, size_t nbStripes, - XXH3_accWidth_e accWidth, XXH3_f_accumulate_512 f_acc512) { size_t n; @@ -1669,8 +1625,7 @@ XXH3_accumulate( xxh_u64* XXH_RESTRICT acc, XXH_PREFETCH(in + XXH_PREFETCH_DIST); f_acc512(acc, in, - secret + n*XXH_SECRET_CONSUME_RATE, - accWidth); + secret + n*XXH_SECRET_CONSUME_RATE); } } @@ -1678,7 +1633,6 @@ XXH_FORCE_INLINE void XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, - XXH3_accWidth_e accWidth, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) { @@ -1691,7 +1645,7 @@ XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); for (n = 0; n < nb_blocks; n++) { - XXH3_accumulate(acc, input + n*block_len, secret, nbStripesPerBlock, accWidth, f_acc512); + XXH3_accumulate(acc, input + n*block_len, secret, nbStripesPerBlock, f_acc512); f_scramble(acc, secret + secretSize - XXH_STRIPE_LEN); } @@ -1699,12 +1653,12 @@ XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, XXH_ASSERT(len > XXH_STRIPE_LEN); { size_t const nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; XXH_ASSERT(nbStripes <= (secretSize / XXH_SECRET_CONSUME_RATE)); - XXH3_accumulate(acc, input + nb_blocks*block_len, secret, nbStripes, accWidth, f_acc512); + XXH3_accumulate(acc, input + nb_blocks*block_len, secret, nbStripes, f_acc512); /* last stripe */ { const xxh_u8* const p = input + len - XXH_STRIPE_LEN; #define XXH_SECRET_LASTACC_START 7 /* not aligned on 8, last secret is different from acc & scrambler */ - f_acc512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START, accWidth); + f_acc512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); } } } @@ -1754,7 +1708,7 @@ XXH3_hashLong_64b_internal(const xxh_u8* XXH_RESTRICT input, size_t len, { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; - XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_128bits, f_acc512, f_scramble); + XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, f_acc512, f_scramble); /* converge into final hash */ XXH_STATIC_ASSERT(sizeof(acc) == 64); @@ -2021,7 +1975,6 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, size_t* XXH_RESTRICT nbStripesSoFarPtr, size_t nbStripesPerBlock, const xxh_u8* XXH_RESTRICT input, size_t nbStripes, const xxh_u8* XXH_RESTRICT secret, size_t secretLimit, - XXH3_accWidth_e accWidth, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) { @@ -2031,12 +1984,12 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, /* need a scrambling operation */ size_t const nbStripesToEndofBlock = nbStripesPerBlock - *nbStripesSoFarPtr; size_t const nbStripesAfterBlock = nbStripes - nbStripesToEndofBlock; - XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripesToEndofBlock, accWidth, f_acc512); + XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripesToEndofBlock, f_acc512); f_scramble(acc, secret + secretLimit); - XXH3_accumulate(acc, input + nbStripesToEndofBlock * XXH_STRIPE_LEN, secret, nbStripesAfterBlock, accWidth, f_acc512); + XXH3_accumulate(acc, input + nbStripesToEndofBlock * XXH_STRIPE_LEN, secret, nbStripesAfterBlock, f_acc512); *nbStripesSoFarPtr = nbStripesAfterBlock; } else { - XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripes, accWidth, f_acc512); + XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripes, f_acc512); *nbStripesSoFarPtr += nbStripes; } } @@ -2047,7 +2000,6 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, XXH_FORCE_INLINE XXH_errorcode XXH3_update(XXH3_state_t* state, const xxh_u8* input, size_t len, - XXH3_accWidth_e accWidth, XXH3_f_accumulate_512 f_acc512, XXH3_f_scrambleAcc f_scramble) { @@ -2085,7 +2037,7 @@ XXH3_update(XXH3_state_t* state, &state->nbStripesSoFar, state->nbStripesPerBlock, state->buffer, XXH3_INTERNALBUFFER_STRIPES, secret, state->secretLimit, - accWidth, f_acc512, f_scramble); + f_acc512, f_scramble); state->bufferedSize = 0; } XXH_ASSERT(input < bEnd); @@ -2098,7 +2050,7 @@ XXH3_update(XXH3_state_t* state, &state->nbStripesSoFar, state->nbStripesPerBlock, input, XXH3_INTERNALBUFFER_STRIPES, secret, state->secretLimit, - accWidth, f_acc512, f_scramble); + f_acc512, f_scramble); input += XXH3_INTERNALBUFFER_SIZE; } while (inputnbStripesPerBlock, state->buffer, nbStripes, secret, state->secretLimit, - accWidth, XXH3_accumulate_512, XXH3_scrambleAcc); + XXH3_accumulate_512, XXH3_scrambleAcc); /* last stripe */ XXH3_accumulate_512(acc, state->buffer + state->bufferedSize - XXH_STRIPE_LEN, - secret + state->secretLimit - XXH_SECRET_LASTACC_START, - accWidth); + secret + state->secretLimit - XXH_SECRET_LASTACC_START); } else { /* bufferedSize < XXH_STRIPE_LEN */ xxh_u8 lastStripe[XXH_STRIPE_LEN]; size_t const catchupSize = XXH_STRIPE_LEN - state->bufferedSize; @@ -2154,8 +2104,7 @@ XXH3_digest_long (XXH64_hash_t* acc, memcpy(lastStripe + catchupSize, state->buffer, state->bufferedSize); XXH3_accumulate_512(acc, lastStripe, - secret + state->secretLimit - XXH_SECRET_LASTACC_START, - accWidth); + secret + state->secretLimit - XXH_SECRET_LASTACC_START); } } @@ -2164,7 +2113,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state) const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; if (state->totalLen > XXH3_MIDSIZE_MAX) { XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB]; - XXH3_digest_long(acc, state, secret, XXH3_acc_64bits); + XXH3_digest_long(acc, state, secret); return XXH3_mergeAccs(acc, secret + XXH_SECRET_MERGEACCS_START, (xxh_u64)state->totalLen * XXH_PRIME64_1); @@ -2491,7 +2440,7 @@ XXH3_hashLong_128b_internal(const xxh_u8* XXH_RESTRICT input, size_t len, { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; - XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, XXH3_acc_128bits, f_acc512, f_scramble); + XXH3_hashLong_internal_loop(acc, input, len, secret, secretSize, f_acc512, f_scramble); /* converge into final hash */ XXH_STATIC_ASSERT(sizeof(acc) == 64); @@ -2668,7 +2617,7 @@ XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_128bits, XXH3_accumulate_512, XXH3_scrambleAcc); + XXH3_accumulate_512, XXH3_scrambleAcc); } XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state) @@ -2676,7 +2625,7 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state) const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; if (state->totalLen > XXH3_MIDSIZE_MAX) { XXH_ALIGN(XXH_ACC_ALIGN) XXH64_hash_t acc[XXH_ACC_NB]; - XXH3_digest_long(acc, state, secret, XXH3_acc_128bits); + XXH3_digest_long(acc, state, secret); XXH_ASSERT(state->secretLimit + XXH_STRIPE_LEN >= sizeof(acc) + XXH_SECRET_MERGEACCS_START); { XXH128_hash_t h128; h128.low64 = XXH3_mergeAccs(acc, diff --git a/xxh_x86dispatch.c b/xxh_x86dispatch.c index 4cb37d73..8c29c468 100644 --- a/xxh_x86dispatch.c +++ b/xxh_x86dispatch.c @@ -389,28 +389,28 @@ XXH_NO_INLINE XXH_errorcode XXH3_64bits_update_scalar(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_64bits, XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar); + XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar); } XXH_NO_INLINE XXH_TARGET_SSE2 XXH_errorcode XXH3_64bits_update_sse2(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_64bits, XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2); + XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2); } XXH_NO_INLINE XXH_TARGET_AVX2 XXH_errorcode XXH3_64bits_update_avx2(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_64bits, XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2); + XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2); } XXH_NO_INLINE XXH_TARGET_AVX512 XXH_errorcode XXH3_64bits_update_avx512(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_64bits, XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512); + XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512); } @@ -512,28 +512,28 @@ XXH_NO_INLINE XXH_errorcode XXH3_128bits_update_scalar(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_128bits, XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar); + XXH3_accumulate_512_scalar, XXH3_scrambleAcc_scalar); } XXH_NO_INLINE XXH_TARGET_SSE2 XXH_errorcode XXH3_128bits_update_sse2(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_128bits, XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2); + XXH3_accumulate_512_sse2, XXH3_scrambleAcc_sse2); } XXH_NO_INLINE XXH_TARGET_AVX2 XXH_errorcode XXH3_128bits_update_avx2(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_128bits, XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2); + XXH3_accumulate_512_avx2, XXH3_scrambleAcc_avx2); } XXH_NO_INLINE XXH_TARGET_AVX512 XXH_errorcode XXH3_128bits_update_avx512(XXH3_state_t* state, const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_acc_128bits, XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512); + XXH3_accumulate_512_avx512, XXH3_scrambleAcc_avx512); } /* ==== Dispatchers ==== */ From 999e5c363e2879d37f966faf32f8f1dd068088a3 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 24 Jun 2020 16:06:06 -0700 Subject: [PATCH 9/9] fixed and restored self-tests --- xxhsum.c | 70 +++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/xxhsum.c b/xxhsum.c index 3e596db9..8e8890a8 100644 --- a/xxhsum.c +++ b/xxhsum.c @@ -1220,11 +1220,10 @@ static void BMK_sanityCheck(void) BMK_testXXH64(sanityBuffer,222, 0, 0xB641AE8CB691C174ULL); BMK_testXXH64(sanityBuffer,222, PRIME32, 0x20CB8AB7AE10C14AULL); -#if 0 - BMK_testXXH3(NULL, 0, 0, 0x776EDDFB6BFD9195ULL); /* empty string */ - BMK_testXXH3(NULL, 0, PRIME64, 0x6AFCE90814C488CBULL); - BMK_testXXH3(sanityBuffer, 1, 0, 0xB936EBAE24CB01C5ULL); /* 1 - 3 */ - BMK_testXXH3(sanityBuffer, 1, PRIME64, 0xF541B1905037FC39ULL); /* 1 - 3 */ + BMK_testXXH3(NULL, 0, 0, 0x2D06800538D394C2ULL); /* empty string */ + BMK_testXXH3(NULL, 0, PRIME64, 0xA8A6B918B2F0364AULL); + BMK_testXXH3(sanityBuffer, 1, 0, 0xC44BDFF4074EECDBULL); /* 1 - 3 */ + BMK_testXXH3(sanityBuffer, 1, PRIME64, 0x032BE332DD766EF8ULL); /* 1 - 3 */ BMK_testXXH3(sanityBuffer, 6, 0, 0x27B56A84CD2D7325ULL); /* 4 - 8 */ BMK_testXXH3(sanityBuffer, 6, PRIME64, 0x84589C116AB59AB9ULL); /* 4 - 8 */ BMK_testXXH3(sanityBuffer, 12, 0, 0xA713DAF0DFBB77E7ULL); /* 9 - 16 */ @@ -1238,23 +1237,23 @@ static void BMK_sanityCheck(void) BMK_testXXH3(sanityBuffer, 195, 0, 0xCD94217EE362EC3AULL); /* 129-240 */ BMK_testXXH3(sanityBuffer, 195, PRIME64, 0xBA68003D370CB3D9ULL); /* 129-240 */ - BMK_testXXH3(sanityBuffer, 403, 0, 0x1B2AFF3B46C74648ULL); /* one block, last stripe is overlapping */ - BMK_testXXH3(sanityBuffer, 403, PRIME64, 0xB654F6FFF42AD787ULL); /* one block, last stripe is overlapping */ - BMK_testXXH3(sanityBuffer, 512, 0, 0x43E368661808A9E8ULL); /* one block, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer, 512, PRIME64, 0x3A865148E584E5B9ULL); /* one block, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer,2048, 0, 0xC7169244BBDA8BD4ULL); /* 2 blocks, finishing at block boundary */ - BMK_testXXH3(sanityBuffer,2048, PRIME64, 0x74BF9A802BBDFBAEULL); /* 2 blocks, finishing at block boundary */ - BMK_testXXH3(sanityBuffer,2240, 0, 0x30FEB637E114C0C7ULL); /* 3 blocks, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer,2240, PRIME64, 0xEEF78A36185EB61FULL); /* 3 blocks, finishing at stripe boundary */ - BMK_testXXH3(sanityBuffer,2367, 0, 0x2EB8FEEDD2D1EF5DULL); /* 3 blocks, last stripe is overlapping */ - BMK_testXXH3(sanityBuffer,2367, PRIME64, 0xCE1A757AD2D25057ULL); /* 3 blocks, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer, 403, 0, 0xCDEB804D65C6DEA4ULL); /* one block, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer, 403, PRIME64, 0x6259F6ECFD6443FDULL); /* one block, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer, 512, 0, 0x617E49599013CB6BULL); /* one block, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer, 512, PRIME64, 0x3CE457DE14C27708ULL); /* one block, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer,2048, 0, 0xDD59E2C3A5F038E0ULL); /* 2 blocks, finishing at block boundary */ + BMK_testXXH3(sanityBuffer,2048, PRIME64, 0x66F81670669ABABCULL); /* 2 blocks, finishing at block boundary */ + BMK_testXXH3(sanityBuffer,2240, 0, 0x6E73A90539CF2948ULL); /* 3 blocks, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer,2240, PRIME64, 0x757BA8487D1B5247ULL); /* 3 blocks, finishing at stripe boundary */ + BMK_testXXH3(sanityBuffer,2367, 0, 0xCB37AEB9E5D361EDULL); /* 3 blocks, last stripe is overlapping */ + BMK_testXXH3(sanityBuffer,2367, PRIME64, 0xD2DB3415B942B42AULL); /* 3 blocks, last stripe is overlapping */ /* XXH3 with Custom Secret */ { const void* const secret = sanityBuffer + 7; const size_t secretSize = XXH3_SECRET_SIZE_MIN + 11; assert(sizeof(sanityBuffer) >= 7 + secretSize); - BMK_testXXH3_withSecret(NULL, 0, secret, secretSize, 0x6775FD10343C92C3ULL); /* empty string */ - BMK_testXXH3_withSecret(sanityBuffer, 1, secret, secretSize, 0xC3382C326E24E3CDULL); /* 1 - 3 */ + BMK_testXXH3_withSecret(NULL, 0, secret, secretSize, 0x3559D64878C5C66CULL); /* empty string */ + BMK_testXXH3_withSecret(sanityBuffer, 1, secret, secretSize, 0x8A52451418B2DA4DULL); /* 1 - 3 */ BMK_testXXH3_withSecret(sanityBuffer, 6, secret, secretSize, 0x82C90AB0519369ADULL); /* 4 - 8 */ BMK_testXXH3_withSecret(sanityBuffer, 12, secret, secretSize, 0x14631E773B78EC57ULL); /* 9 - 16 */ BMK_testXXH3_withSecret(sanityBuffer, 24, secret, secretSize, 0xCDD5542E4A9D9FE8ULL); /* 17 - 32 */ @@ -1262,25 +1261,25 @@ static void BMK_sanityCheck(void) BMK_testXXH3_withSecret(sanityBuffer, 80, secret, secretSize, 0xE687BA1684965297ULL); /* 65 - 96 */ BMK_testXXH3_withSecret(sanityBuffer, 195, secret, secretSize, 0xA057273F5EECFB20ULL); /* 129-240 */ - BMK_testXXH3_withSecret(sanityBuffer, 403, secret, secretSize, 0xF9C0BA5BA3AF70B8ULL); /* one block, last stripe is overlapping */ - BMK_testXXH3_withSecret(sanityBuffer, 512, secret, secretSize, 0x7896E65DCFA09071ULL); /* one block, finishing at stripe boundary */ - BMK_testXXH3_withSecret(sanityBuffer,2048, secret, secretSize, 0xD6545DB87ECFD98CULL); /* >= 2 blocks, at least one scrambling */ - BMK_testXXH3_withSecret(sanityBuffer,2367, secret, secretSize, 0x857320340D953686ULL); /* >= 2 blocks, at least one scrambling, last stripe unaligned */ + BMK_testXXH3_withSecret(sanityBuffer, 403, secret, secretSize, 0x14546019124D43B8ULL); /* one block, last stripe is overlapping */ + BMK_testXXH3_withSecret(sanityBuffer, 512, secret, secretSize, 0x7564693DD526E28DULL); /* one block, finishing at stripe boundary */ + BMK_testXXH3_withSecret(sanityBuffer,2048, secret, secretSize, 0xD32E975821D6519FULL); /* >= 2 blocks, at least one scrambling */ + BMK_testXXH3_withSecret(sanityBuffer,2367, secret, secretSize, 0x293FA8E5173BB5E7ULL); /* >= 2 blocks, at least one scrambling, last stripe unaligned */ - BMK_testXXH3_withSecret(sanityBuffer,64*10*3, secret, secretSize, 0xD4989A002E9850ABULL); /* exactly 3 full blocks, not a multiple of 256 */ + BMK_testXXH3_withSecret(sanityBuffer,64*10*3, secret, secretSize, 0x751D2EC54BC6038BULL); /* exactly 3 full blocks, not a multiple of 256 */ } /* XXH128 */ - { XXH128_hash_t const expected = { 0x1F17545BCE1061F1ULL, 0x07FD4E968E916AE1ULL }; + { XXH128_hash_t const expected = { 0x6001C324468D497FULL, 0x99AA06D3014798D8ULL }; BMK_testXXH128(NULL, 0, 0, expected); /* empty string */ } - { XXH128_hash_t const expected = { 0x7282E631387D51ACULL, 0x8743B0A8131AB9E6ULL }; + { XXH128_hash_t const expected = { 0x5444F7869C671AB0ULL, 0x92220AE55E14AB50ULL }; BMK_testXXH128(NULL, 0, PRIME32, expected); } - { XXH128_hash_t const expected = { 0xB936EBAE24CB01C5ULL, 0x2554B05763A71A05ULL }; + { XXH128_hash_t const expected = { 0xC44BDFF4074EECDBULL, 0xA6CD5E9392000F6AULL }; BMK_testXXH128(sanityBuffer, 1, 0, expected); /* 1-3 */ } - { XXH128_hash_t const expected = { 0xCA57C628C04B45B8ULL, 0x916831F4DCD21CF9ULL }; + { XXH128_hash_t const expected = { 0xB53D5557E7F76F8DULL, 0x89B99554BA22467CULL }; BMK_testXXH128(sanityBuffer, 1, PRIME32, expected); /* 1-3 */ } { XXH128_hash_t const expected = { 0x3E7039BDDA43CFC6ULL, 0x082AFE0B8162D12AULL }; @@ -1325,22 +1324,22 @@ static void BMK_sanityCheck(void) { XXH128_hash_t const expected = { 0x6259F6ECFD6443FDULL, 0xBED311971E0BE8F2ULL }; BMK_testXXH128(sanityBuffer, 403, PRIME64, expected); /* one block, last stripe is overlapping */ } - { XXH128_hash_t const expected = { 0x1443B8153EBEE367ULL, 0x98EC7E48CD872997ULL }; + { XXH128_hash_t const expected = { 0x617E49599013CB6BULL, 0x18D2D110DCC9BCA1ULL }; BMK_testXXH128(sanityBuffer, 512, 0, expected); /* one block, finishing at stripe boundary */ } - { XXH128_hash_t const expected = { 0x43FDC6823A52F1F2ULL, 0x2F748A4F194E1EF0ULL }; + { XXH128_hash_t const expected = { 0x3CE457DE14C27708ULL, 0x925D06B8EC5B8040ULL }; BMK_testXXH128(sanityBuffer, 512, PRIME64, expected); /* one block, finishing at stripe boundary */ } - { XXH128_hash_t const expected = { 0xF4258501BE8E0623ULL, 0x6930A2267A755B20ULL }; + { XXH128_hash_t const expected = { 0xDD59E2C3A5F038E0ULL, 0xF736557FD47073A5ULL }; BMK_testXXH128(sanityBuffer,2048, 0, expected); /* two blocks, finishing at block boundary */ } - { XXH128_hash_t const expected = { 0x10CC56C2FA0AD9ACULL, 0xD0D7A3C2EEF2D892ULL }; + { XXH128_hash_t const expected = { 0x230D43F30206260BULL, 0x7FB03F7E7186C3EAULL }; BMK_testXXH128(sanityBuffer,2048, PRIME32, expected); /* two blocks, finishing at block boundary */ } - { XXH128_hash_t const expected = { 0x5890AE7ACBB84A7EULL, 0x85C327B377AA7E62ULL }; + { XXH128_hash_t const expected = { 0x6E73A90539CF2948ULL, 0xCCB134FBFA7CE49DULL }; BMK_testXXH128(sanityBuffer,2240, 0, expected); /* two blocks, ends at stripe boundary */ } - { XXH128_hash_t const expected = { 0x205E6D72DCCBD2AAULL, 0x62B70214DB075235ULL }; + { XXH128_hash_t const expected = { 0xED385111126FBA6FULL, 0x50A1FE17B338995FULL }; BMK_testXXH128(sanityBuffer,2240, PRIME32, expected); /* two blocks, ends at stripe boundary */ } { XXH128_hash_t const expected = { 0xCB37AEB9E5D361EDULL, 0xE89C0F6FF369B427ULL }; @@ -1355,10 +1354,10 @@ static void BMK_sanityCheck(void) const size_t secretSize = XXH3_SECRET_SIZE_MIN + 11; assert(sizeof(sanityBuffer) >= 7 + secretSize); - { XXH128_hash_t const expected = { 0x58607A62EE3D62F5ULL, 0x339965195B2942D1ULL }; + { XXH128_hash_t const expected = { 0x005923CCEECBE8AEULL, 0x5F70F4EA232F1D38ULL }; BMK_testXXH128_withSecret(NULL, 0, secret, secretSize, expected); /* empty string */ } - { XXH128_hash_t const expected = { 0xC3382C326E24E3CDULL, 0x2A2771BA8906D2EBULL }; + { XXH128_hash_t const expected = { 0x8A52451418B2DA4DULL, 0x3A66AF5A9819198EULL }; BMK_testXXH128_withSecret(sanityBuffer, 1, secret, secretSize, expected); /* 1-3 */ } { XXH128_hash_t const expected = { 0x0B61C8ACA7D4778FULL, 0x376BD91B6432F36DULL }; @@ -1374,7 +1373,7 @@ static void BMK_sanityCheck(void) BMK_testSecretGenerator(NULL, 0, expected); } - { verifSample_t const expected = { { 0x25, 0x82, 0x62, 0x9A } }; + { verifSample_t const expected = { { 0xA6, 0x16, 0x06, 0x7B } }; BMK_testSecretGenerator(sanityBuffer, 1, expected); } @@ -1385,7 +1384,6 @@ static void BMK_sanityCheck(void) { verifSample_t const expected = { { 0x7E, 0x48, 0x0C, 0xA7 } }; BMK_testSecretGenerator(sanityBuffer, XXH3_SECRET_DEFAULT_SIZE + 500, expected); } -#endif DISPLAYLEVEL(3, "\r%70s\r", ""); /* Clean display line */ DISPLAYLEVEL(3, "Sanity check -- all tests ok\n");