From 306a533d023431287d69bc83fe8e7ba9d1638e5b Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 2 Aug 2022 22:10:51 +0200 Subject: [PATCH] extract khashv_seed_init --- Hashes.cpp | 13 ++++---- Hashes.h | 1 + README.md | 2 +- doc/k-hashv32.txt | 84 +++++++++++++++++++++++------------------------ doc/k-hashv64.txt | 84 +++++++++++++++++++++++------------------------ doc/ryzen3.html | 12 +++---- doc/table.html | 12 +++---- main.cpp | 10 +++--- 8 files changed, 111 insertions(+), 107 deletions(-) diff --git a/Hashes.cpp b/Hashes.cpp index e8a961ae..e8e287b8 100644 --- a/Hashes.cpp +++ b/Hashes.cpp @@ -1227,16 +1227,17 @@ void nmhash32x_test ( const void * key, int len, uint32_t seed, void * out ) { #ifndef HAVE_BIT32 #include "k-hashv/khashv.h" + +khashvSeed khashv_seed; +void khashv_seed_init(size_t &seed) { + khashv_prep_seed64 (&khashv_seed, seed); +} //objsize: 46b4a0-46b535: 149 + 426ad0-426f3a: 1130 void khashv64_test ( const void *key, int len, uint32_t seed, void *out) { - khashvSeed myseed; - khashv_prep_seed32 (&myseed, seed); - *(uint64_t*)out = khashv64 (&myseed, (const uint8_t*)key, (size_t)len); + *(uint64_t*)out = khashv64 (&khashv_seed, (const uint8_t*)key, (size_t)len); } //objsize: 46b540-46b5d6: 150 + 1130 void khashv32_test ( const void *key, int len, uint32_t seed, void *out) { - khashvSeed myseed; - khashv_prep_seed32 (&myseed, seed); - *(uint32_t*)out = khashv32 (&myseed, (const uint8_t*)key, (size_t)len); + *(uint32_t*)out = khashv32 (&khashv_seed, (const uint8_t*)key, (size_t)len); } #endif diff --git a/Hashes.h b/Hashes.h index bcc776d8..99c45d91 100644 --- a/Hashes.h +++ b/Hashes.h @@ -1344,6 +1344,7 @@ inline void khash64_test ( const void *key, int len, uint32_t seed, void *out) { #endif #ifndef HAVE_BIT32 +void khashv_seed_init(size_t &seed); // call to khashv_hash_vector not inlined. void khashv32_test ( const void *key, int len, uint32_t seed, void *out); void khashv64_test ( const void *key, int len, uint32_t seed, void *out); diff --git a/README.md b/README.md index 603f2164..2ee2a95f 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ SMhasher | [halftime_hash512](doc/halftime_hash512.txt) | 7681.62 | 125.81 | 274.01 (3) |3550 | | | [nmhash32](doc/nmhash32.txt) | 7850.01 | 56.74 | 207.59 (1) |2445 | | | [nmhash32x](doc/nmhash32x.txt) | 7850.92 | 46.94 | 193.94 (1) |1494 | | -| [k-hashv32](doc/k-hashv32.txt) | 7836.31 | 69.00 | 191.35 (1) |1280 | | +| [k-hashv32](doc/k-hashv32.txt) | 7079.27 | 62.44 | 213.31 (1) |1280 | | | [k-hashv64](doc/k-hashv32.txt) | 7850.92 | 46.94 | 193.94 (1) |1279 | | | [komihash](doc/komihash.txt) | 10444.53 | 39.55 | 176.50 (1) | 728 | | diff --git a/doc/k-hashv32.txt b/doc/k-hashv32.txt index 921b6294..77c202ac 100644 --- a/doc/k-hashv32.txt +++ b/doc/k-hashv32.txt @@ -10,48 +10,48 @@ Running AppendedZeroesTest .......... PASS [[[ Speed Tests ]]] Bulk speed test - 262144-byte keys -Alignment 7 - 3.927 bytes/cycle - 11234.15 MiB/sec @ 3 ghz -Alignment 6 - 3.927 bytes/cycle - 11233.89 MiB/sec @ 3 ghz -Alignment 5 - 3.906 bytes/cycle - 11175.60 MiB/sec @ 3 ghz -Alignment 4 - 3.845 bytes/cycle - 11000.20 MiB/sec @ 3 ghz -Alignment 3 - 3.865 bytes/cycle - 11058.22 MiB/sec @ 3 ghz -Alignment 2 - 3.865 bytes/cycle - 11058.18 MiB/sec @ 3 ghz -Alignment 1 - 3.867 bytes/cycle - 11063.17 MiB/sec @ 3 ghz -Alignment 0 - 3.881 bytes/cycle - 11103.72 MiB/sec @ 3 ghz -Average - 3.885 bytes/cycle - 11115.89 MiB/sec @ 3 ghz - -Small key speed test - 1-byte keys - 51.00 cycles/hash -Small key speed test - 2-byte keys - 50.98 cycles/hash -Small key speed test - 3-byte keys - 50.51 cycles/hash -Small key speed test - 4-byte keys - 50.27 cycles/hash -Small key speed test - 5-byte keys - 50.96 cycles/hash -Small key speed test - 6-byte keys - 50.96 cycles/hash -Small key speed test - 7-byte keys - 50.04 cycles/hash -Small key speed test - 8-byte keys - 50.26 cycles/hash -Small key speed test - 9-byte keys - 50.98 cycles/hash -Small key speed test - 10-byte keys - 50.98 cycles/hash -Small key speed test - 11-byte keys - 50.79 cycles/hash -Small key speed test - 12-byte keys - 50.96 cycles/hash -Small key speed test - 13-byte keys - 50.87 cycles/hash -Small key speed test - 14-byte keys - 50.82 cycles/hash -Small key speed test - 15-byte keys - 49.83 cycles/hash -Small key speed test - 16-byte keys - 49.97 cycles/hash -Small key speed test - 17-byte keys - 54.95 cycles/hash -Small key speed test - 18-byte keys - 54.92 cycles/hash -Small key speed test - 19-byte keys - 55.79 cycles/hash -Small key speed test - 20-byte keys - 55.40 cycles/hash -Small key speed test - 21-byte keys - 55.20 cycles/hash -Small key speed test - 22-byte keys - 55.20 cycles/hash -Small key speed test - 23-byte keys - 55.00 cycles/hash -Small key speed test - 24-byte keys - 55.66 cycles/hash -Small key speed test - 25-byte keys - 55.51 cycles/hash -Small key speed test - 26-byte keys - 55.46 cycles/hash -Small key speed test - 27-byte keys - 55.01 cycles/hash -Small key speed test - 28-byte keys - 55.43 cycles/hash -Small key speed test - 29-byte keys - 54.33 cycles/hash -Small key speed test - 30-byte keys - 55.12 cycles/hash -Small key speed test - 31-byte keys - 55.55 cycles/hash -Average 52.862 cycles/hash +Alignment 7 - 2.457 bytes/cycle - 7028.45 MiB/sec @ 3 ghz +Alignment 6 - 2.457 bytes/cycle - 7028.31 MiB/sec @ 3 ghz +Alignment 5 - 2.457 bytes/cycle - 7028.66 MiB/sec @ 3 ghz +Alignment 4 - 2.457 bytes/cycle - 7028.58 MiB/sec @ 3 ghz +Alignment 3 - 2.457 bytes/cycle - 7028.44 MiB/sec @ 3 ghz +Alignment 2 - 2.457 bytes/cycle - 7028.49 MiB/sec @ 3 ghz +Alignment 1 - 2.457 bytes/cycle - 7028.33 MiB/sec @ 3 ghz +Alignment 0 - 2.599 bytes/cycle - 7434.87 MiB/sec @ 3 ghz +Average - 2.474 bytes/cycle - 7079.27 MiB/sec @ 3 ghz + +Small key speed test - 1-byte keys - 52.77 cycles/hash +Small key speed test - 2-byte keys - 70.00 cycles/hash +Small key speed test - 3-byte keys - 71.00 cycles/hash +Small key speed test - 4-byte keys - 52.00 cycles/hash +Small key speed test - 5-byte keys - 52.72 cycles/hash +Small key speed test - 6-byte keys - 53.00 cycles/hash +Small key speed test - 7-byte keys - 54.00 cycles/hash +Small key speed test - 8-byte keys - 52.00 cycles/hash +Small key speed test - 9-byte keys - 53.00 cycles/hash +Small key speed test - 10-byte keys - 52.00 cycles/hash +Small key speed test - 11-byte keys - 54.00 cycles/hash +Small key speed test - 12-byte keys - 52.44 cycles/hash +Small key speed test - 13-byte keys - 54.00 cycles/hash +Small key speed test - 14-byte keys - 54.00 cycles/hash +Small key speed test - 15-byte keys - 55.00 cycles/hash +Small key speed test - 16-byte keys - 54.74 cycles/hash +Small key speed test - 17-byte keys - 66.73 cycles/hash +Small key speed test - 18-byte keys - 91.86 cycles/hash +Small key speed test - 19-byte keys - 93.11 cycles/hash +Small key speed test - 20-byte keys - 65.53 cycles/hash +Small key speed test - 21-byte keys - 66.00 cycles/hash +Small key speed test - 22-byte keys - 66.00 cycles/hash +Small key speed test - 23-byte keys - 67.00 cycles/hash +Small key speed test - 24-byte keys - 65.00 cycles/hash +Small key speed test - 25-byte keys - 66.00 cycles/hash +Small key speed test - 26-byte keys - 66.48 cycles/hash +Small key speed test - 27-byte keys - 67.00 cycles/hash +Small key speed test - 28-byte keys - 66.17 cycles/hash +Small key speed test - 29-byte keys - 67.00 cycles/hash +Small key speed test - 30-byte keys - 67.00 cycles/hash +Small key speed test - 31-byte keys - 68.00 cycles/hash +Average 62.437 cycles/hash [[[ 'Hashmap' Speed Tests ]]] diff --git a/doc/k-hashv64.txt b/doc/k-hashv64.txt index 105bb783..9b6b8bec 100644 --- a/doc/k-hashv64.txt +++ b/doc/k-hashv64.txt @@ -10,48 +10,48 @@ Running AppendedZeroesTest .......... PASS [[[ Speed Tests ]]] Bulk speed test - 262144-byte keys -Alignment 7 - 3.873 bytes/cycle - 11082.02 MiB/sec @ 3 ghz -Alignment 6 - 3.627 bytes/cycle - 10376.50 MiB/sec @ 3 ghz -Alignment 5 - 3.761 bytes/cycle - 10761.62 MiB/sec @ 3 ghz -Alignment 4 - 3.889 bytes/cycle - 11126.53 MiB/sec @ 3 ghz -Alignment 3 - 3.887 bytes/cycle - 11121.71 MiB/sec @ 3 ghz -Alignment 2 - 3.931 bytes/cycle - 11246.07 MiB/sec @ 3 ghz -Alignment 1 - 3.929 bytes/cycle - 11241.50 MiB/sec @ 3 ghz -Alignment 0 - 3.928 bytes/cycle - 11239.35 MiB/sec @ 3 ghz -Average - 3.853 bytes/cycle - 11024.41 MiB/sec @ 3 ghz - -Small key speed test - 1-byte keys - 49.55 cycles/hash -Small key speed test - 2-byte keys - 48.97 cycles/hash -Small key speed test - 3-byte keys - 49.00 cycles/hash -Small key speed test - 4-byte keys - 49.11 cycles/hash -Small key speed test - 5-byte keys - 49.32 cycles/hash -Small key speed test - 6-byte keys - 49.44 cycles/hash -Small key speed test - 7-byte keys - 49.32 cycles/hash -Small key speed test - 8-byte keys - 49.05 cycles/hash -Small key speed test - 9-byte keys - 49.45 cycles/hash -Small key speed test - 10-byte keys - 49.43 cycles/hash -Small key speed test - 11-byte keys - 49.00 cycles/hash -Small key speed test - 12-byte keys - 49.24 cycles/hash -Small key speed test - 13-byte keys - 49.32 cycles/hash -Small key speed test - 14-byte keys - 49.28 cycles/hash -Small key speed test - 15-byte keys - 50.14 cycles/hash -Small key speed test - 16-byte keys - 48.91 cycles/hash -Small key speed test - 17-byte keys - 54.00 cycles/hash -Small key speed test - 18-byte keys - 54.00 cycles/hash -Small key speed test - 19-byte keys - 54.86 cycles/hash -Small key speed test - 20-byte keys - 54.60 cycles/hash -Small key speed test - 21-byte keys - 54.00 cycles/hash -Small key speed test - 22-byte keys - 54.00 cycles/hash -Small key speed test - 23-byte keys - 54.93 cycles/hash -Small key speed test - 24-byte keys - 54.00 cycles/hash -Small key speed test - 25-byte keys - 54.00 cycles/hash -Small key speed test - 26-byte keys - 54.00 cycles/hash -Small key speed test - 27-byte keys - 54.92 cycles/hash -Small key speed test - 28-byte keys - 54.42 cycles/hash -Small key speed test - 29-byte keys - 54.87 cycles/hash -Small key speed test - 30-byte keys - 55.02 cycles/hash -Small key speed test - 31-byte keys - 55.97 cycles/hash -Average 51.810 cycles/hash +Alignment 7 - 2.458 bytes/cycle - 7033.34 MiB/sec @ 3 ghz +Alignment 6 - 2.458 bytes/cycle - 7033.36 MiB/sec @ 3 ghz +Alignment 5 - 2.458 bytes/cycle - 7033.40 MiB/sec @ 3 ghz +Alignment 4 - 2.458 bytes/cycle - 7033.34 MiB/sec @ 3 ghz +Alignment 3 - 2.458 bytes/cycle - 7033.48 MiB/sec @ 3 ghz +Alignment 2 - 2.458 bytes/cycle - 7033.37 MiB/sec @ 3 ghz +Alignment 1 - 2.458 bytes/cycle - 7033.35 MiB/sec @ 3 ghz +Alignment 0 - 2.606 bytes/cycle - 7455.33 MiB/sec @ 3 ghz +Average - 2.477 bytes/cycle - 7086.12 MiB/sec @ 3 ghz + +Small key speed test - 1-byte keys - 51.00 cycles/hash +Small key speed test - 2-byte keys - 68.00 cycles/hash +Small key speed test - 3-byte keys - 69.00 cycles/hash +Small key speed test - 4-byte keys - 50.00 cycles/hash +Small key speed test - 5-byte keys - 54.87 cycles/hash +Small key speed test - 6-byte keys - 54.96 cycles/hash +Small key speed test - 7-byte keys - 56.49 cycles/hash +Small key speed test - 8-byte keys - 54.48 cycles/hash +Small key speed test - 9-byte keys - 62.00 cycles/hash +Small key speed test - 10-byte keys - 62.00 cycles/hash +Small key speed test - 11-byte keys - 64.00 cycles/hash +Small key speed test - 12-byte keys - 62.00 cycles/hash +Small key speed test - 13-byte keys - 63.78 cycles/hash +Small key speed test - 14-byte keys - 63.95 cycles/hash +Small key speed test - 15-byte keys - 64.00 cycles/hash +Small key speed test - 16-byte keys - 65.25 cycles/hash +Small key speed test - 17-byte keys - 70.39 cycles/hash +Small key speed test - 18-byte keys - 100.01 cycles/hash +Small key speed test - 19-byte keys - 100.99 cycles/hash +Small key speed test - 20-byte keys - 69.76 cycles/hash +Small key speed test - 21-byte keys - 64.00 cycles/hash +Small key speed test - 22-byte keys - 64.00 cycles/hash +Small key speed test - 23-byte keys - 65.00 cycles/hash +Small key speed test - 24-byte keys - 63.00 cycles/hash +Small key speed test - 25-byte keys - 64.00 cycles/hash +Small key speed test - 26-byte keys - 64.00 cycles/hash +Small key speed test - 27-byte keys - 65.00 cycles/hash +Small key speed test - 28-byte keys - 64.00 cycles/hash +Small key speed test - 29-byte keys - 65.00 cycles/hash +Small key speed test - 30-byte keys - 65.00 cycles/hash +Small key speed test - 31-byte keys - 65.88 cycles/hash +Average 65.026 cycles/hash [[[ 'Hashmap' Speed Tests ]]] diff --git a/doc/ryzen3.html b/doc/ryzen3.html index c8c81dc8..89bd11b1 100644 --- a/doc/ryzen3.html +++ b/doc/ryzen3.html @@ -1617,17 +1617,17 @@

SMhasher

k-hashv32 -11115.89 -52.86 -528.06 (11) +11312.23 +43.05 +519.40 (10) 1280 k-hashv64 -11024.41 -51.81 -521.90 (15) +11309.15 +42.69 +515.67 (19) 1279 diff --git a/doc/table.html b/doc/table.html index 031f51c5..b54b38e1 100644 --- a/doc/table.html +++ b/doc/table.html @@ -1617,17 +1617,17 @@

SMhasher

k-hashv32 -7836.31 -69.00 -191.35 (1) +7079.27 +62.44 +213.31 (1) 1280 k-hashv64 -7850.92 -46.94 -193.94 (1) +7086.12 +65.03 +190.55 (1) 1279 diff --git a/main.cpp b/main.cpp index 806626ff..f139635f 100644 --- a/main.cpp +++ b/main.cpp @@ -733,13 +733,13 @@ HashInfo g_hashes[] = // all seeds with those lower bits { 0x14cc886e, 0x1bf4ed84, 0x14cc886e14cc886eULL} /* !! 2^33 bad seeds, but easy to check */ }, //{ wyhash_condom_test, 64, 0x7C62138D, "wyhash_condom", "wyhash v3 condom 2 (64-bit)", GOOD, { } }, -#endif -#ifndef HAVE_BIT32 - { khashv32_test, 32, 0x2A336D18, "k-hashv32", "Vectorized K-HashV, 32-bit", GOOD, {} /* */}, - { khashv64_test, 64, 0xC25A0905, "k-hashv64", "Vectorized K-HashV, 64-bit", GOOD, {} /* */}, #endif { nmhash32_test, 32, 0x12A30553, "nmhash32", "nmhash32", GOOD, {}}, { nmhash32x_test, 32, 0xA8580227, "nmhash32x", "nmhash32x", GOOD, {}}, +#ifndef HAVE_BIT32 + { khashv32_test, 32, 0xB69DF8EB, "k-hashv32", "Vectorized K-HashV, 32-bit", GOOD, {}}, + { khashv64_test, 64, 0xA6B7E55B, "k-hashv64", "Vectorized K-HashV, 64-bit", GOOD, {}}, +#endif }; HashInfo * findHash ( const char * name ) @@ -905,6 +905,8 @@ void Hash_Seed_init (pfHash hash, size_t seed) { else if(hash == hashx_test) hashx_seed_init(info, seed); */ + else if(hash == khashv64_test || hash == khashv32_test) + khashv_seed_init(seed); #endif }