Skip to content

Commit

Permalink
extract khashv_seed_init
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Aug 2, 2022
1 parent 2435a03 commit 306a533
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 107 deletions.
13 changes: 7 additions & 6 deletions Hashes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Hashes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |

Expand Down
84 changes: 42 additions & 42 deletions doc/k-hashv32.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]]]

Expand Down
84 changes: 42 additions & 42 deletions doc/k-hashv64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]]]

Expand Down
12 changes: 6 additions & 6 deletions doc/ryzen3.html
Original file line number Diff line number Diff line change
Expand Up @@ -1617,17 +1617,17 @@ <h1 id="smhasher">SMhasher</h1>
</tr>
<tr class="good">
<td align="left"><a href="k-hashv32.txt">k-hashv32</a></td>
<td align="right">11115.89</td>
<td align="right">52.86</td>
<td align="right">528.06 (11)</td>
<td align="right">11312.23</td>
<td align="right">43.05</td>
<td align="right">519.40 (10)</td>
<td align="right">1280</td>
<td align="left"></td>
</tr>
<tr class="good">
<td align="left"><a href="k-hashv64.txt">k-hashv64</a></td>
<td align="right">11024.41</td>
<td align="right">51.81</td>
<td align="right">521.90 (15)</td>
<td align="right">11309.15</td>
<td align="right">42.69</td>
<td align="right">515.67 (19)</td>
<td align="right">1279</td>
<td align="left"></td>
</tr>
Expand Down
12 changes: 6 additions & 6 deletions doc/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -1617,17 +1617,17 @@ <h1 id="smhasher">SMhasher</h1>
</tr>
<tr class="good">
<td align="left"><a href="k-hashv32.txt">k-hashv32</a></td>
<td align="right">7836.31</td>
<td align="right">69.00</td>
<td align="right">191.35 (1)</td>
<td align="right">7079.27</td>
<td align="right">62.44</td>
<td align="right">213.31 (1)</td>
<td align="right">1280</td>
<td align="left"></td>
</tr>
<tr class="good">
<td align="left"><a href="k-hashv64.txt">k-hashv64</a></td>
<td align="right">7850.92</td>
<td align="right">46.94</td>
<td align="right">193.94 (1)</td>
<td align="right">7086.12</td>
<td align="right">65.03</td>
<td align="right">190.55 (1)</td>
<td align="right">1279</td>
<td align="left"></td>
</tr>
Expand Down
10 changes: 6 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 306a533

Please sign in to comment.