summaryrefslogtreecommitdiff
path: root/tests/test-hash.c
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-07-11 05:57:11 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-07-11 05:57:11 -0700
commitff8eeabd0dfa967c161c1591daea826f0da23da6 (patch)
tree8fdc34232365a3c0aae9bd7683b72d9ee46033be /tests/test-hash.c
parentafae68b16f01559df44e3fd62f1fc020faec5731 (diff)
downloadopenvswitch-ff8eeabd0dfa967c161c1591daea826f0da23da6.tar.gz
lib/hash: Use CRC32 for hashing.
Use CRC32 intrinsics for hash computations when building for X86_64 with SSE4_2. Add a new hash_words64() and change hash_words() to be inlined when 'n_words' is a compile-time constant. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests/test-hash.c')
-rw-r--r--tests/test-hash.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test-hash.c b/tests/test-hash.c
index 081e72383..f410c1614 100644
--- a/tests/test-hash.c
+++ b/tests/test-hash.c
@@ -92,15 +92,22 @@ check_3word_hash(uint32_t (*hash)(const uint32_t[], size_t, uint32_t),
for (i = 0; i <= 96; i++) {
for (j = i + 1; j <= 96; j++) {
- uint32_t in1[3], in2[3];
- uint32_t out1, out2;
+ uint32_t in0[3], in1[3], in2[3];
+ uint32_t out0,out1, out2;
const int min_unique = 12;
const uint32_t unique_mask = (UINT32_C(1) << min_unique) - 1;
+ set_bit(in0, i);
set_bit(in1, i);
set_bit(in2, j);
+ out0 = hash(in0, 3, 0);
out1 = hash(in1, 3, 0);
out2 = hash(in2, 3, 0);
+
+ if (out0 != out1) {
+ printf("%s hash not the same for non-64 aligned data "
+ "%08"PRIx32" != %08"PRIx32"\n", name, out0, out1);
+ }
if ((out1 & unique_mask) == (out2 & unique_mask)) {
printf("%s has a partial collision:\n", name);
printf("hash(1 << %d) == %08"PRIx32"\n", i, out1);