Skip to content

Commit

Permalink
t1ha-bench: add wyhash_v4.
Browse files Browse the repository at this point in the history
  • Loading branch information
erthink committed Jan 30, 2020
1 parent 4104261 commit b8eefd2
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 17 deletions.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TARGET_ARCH_ia32 ?= $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>
TARGET_ARCH_ppc ?= $(shell (export LC_ALL=C; ($(CC) --version 2>&1; $(CC) -v 2>&1) | grep -q -i -e '^Target: powerpc.*' && echo yes || echo no))

OBJ_LIST := t1ha0.o t1ha1.o t1ha2.o t1ha0_selfcheck.o t1ha1_selfcheck.o t1ha2_selfcheck.o t1ha_selfcheck.o t1ha_selfcheck_all.o
BENCH_EXTRA := bench.o mera.o test.o 4bench_xxhash.o 4bench_highwayhash_test.o 4bench_highwayhash_pure_c.o 4bench_highwayhash_portable.o
BENCH_EXTRA := bench.o mera.o test.o 4bench_xxhash.o 4bench_stadtx.o 4bench_wyhash.o 4bench_highwayhash_test.o 4bench_highwayhash_pure_c.o 4bench_highwayhash_portable.o
ifeq ($(TARGET_ARCH_e2k),yes)
TARGET_ARCH := e2k
CFLAGS += -mtune=native
Expand Down Expand Up @@ -125,12 +125,19 @@ test.o: t1ha.h tests/common.h tests/mera.h tests/test.c \
$(CC) $(CFLAGS_TEST) -c -o $@ tests/test.c

4bench_xxhash.o: tests/xxhash/xxhash.h tests/xxhash/xxhash.c \
tests/xxhash/xxh_thunk.c Makefile
tests/xxhash/xxh_thunk.c tests/common.h Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/xxhash/xxh_thunk.c

4bench_stadtx.o: tests/common.h tests/stadtx/stadtx_hash.h \
tests/stadtx/stadtx_thunk.c tests/common.h Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/stadtx/stadtx_thunk.c

4bench_wyhash.o: tests/wyhash/wyhash.h tests/wyhash/wyhash_thunk.c \
tests/common.h Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/wyhash/wyhash_thunk.c

4bench_highwayhash_pure_c.o: tests/highwayhash/pure_c.h \
tests/highwayhash/pure_c.c \
Makefile
tests/highwayhash/pure_c.c Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/highwayhash/pure_c.c

HIGHWAYHASH_SRC = $(addprefix tests/highwayhash/, \
Expand Down Expand Up @@ -177,11 +184,6 @@ endif
tests/highwayhash/verifier.c Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/highwayhash/verifier.c

BENCH_EXTRA += 4bench_stadtx.o
4bench_stadtx.o: tests/common.h tests/stadtx/stadtx_hash.h \
tests/stadtx/stadtx_thunk.c Makefile
$(CC) $(CFLAGS_TEST) -Wno-error -c -o $@ tests/stadtx/stadtx_thunk.c

test: $(OBJ_LIST) $(BENCH_EXTRA) tests/main.c Makefile \
t1ha.h tests/common.h tests/mera.h \
mera.o bench.o test.o
Expand Down
2 changes: 2 additions & 0 deletions t1ha-test.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
<ClCompile Include="tests\highwayhash\pure_c.c" />
<ClCompile Include="tests\highwayhash\verifier.c" />
<ClCompile Include="tests\stadtx\stadtx_thunk.c" />
<ClCompile Include="tests\wyhash\wyhash_thunk.c" />
<ClCompile Include="tests\xxhash\xxh_thunk.c">
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</TreatWarningAsError>
<TreatWarningAsError Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">false</TreatWarningAsError>
Expand Down Expand Up @@ -389,6 +390,7 @@
<ClInclude Include="tests\highwayhash\vector128.h" />
<ClInclude Include="tests\highwayhash\vector256.h" />
<ClInclude Include="tests\stadtx\stadtx_hash.h" />
<ClInclude Include="tests\wyhash\wyhash.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="t1ha-static.vcxproj">
Expand Down
4 changes: 4 additions & 0 deletions t1ha.files
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ tests/mera.h
tests/stadtx/stadtx_hash.h
tests/stadtx/stadtx_thunk.c
tests/test.c
tests/wyhash/LICENSE
tests/wyhash/README.md
tests/wyhash/wyhash.h
tests/wyhash/wyhash_thunk.c
tests/xxhash/xxh3.h
tests/xxhash/xxh_thunk.c
tests/xxhash/xxhash.c
Expand Down
3 changes: 3 additions & 0 deletions tests/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,8 @@ void bench_size(const unsigned size, const char *caption) {
#endif
/* TODO: thunk_HighwayHash64_VSX() */
}
if (is_selected(bench_wyhash)) {
bench("wyhash_v4", thunk_wyhash_v4, buffer, size, seed);
}
free(buffer);
}
9 changes: 7 additions & 2 deletions tests/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum test_flags {
bench_xxhash = 1u << 4,
bench_highwayhash = 1u << 5,
bench_stadtx = 1u << 6,
/* 7 */
bench_wyhash = 1u << 7,

bench_0 = 1u << 8,
bench_1 = 1u << 9,
Expand Down Expand Up @@ -85,7 +85,8 @@ enum test_flags {
bench_funcs_flags = bench_0 | bench_1 | bench_2 | bench_3 | bench_4 |
bench_5 | bench_6 | bench_7 | bench_32 | bench_64 |
bench_le | bench_be | 1u << 28 | 1u << 29 | 1u << 30 |
1u << 31 | bench_xxhash | bench_highwayhash | bench_stadtx
1u << 31 | bench_xxhash | bench_highwayhash |
bench_stadtx | bench_wyhash
};

extern unsigned option_flags, disabled_option_flags;
Expand Down Expand Up @@ -168,3 +169,7 @@ uint64_t thunk_HighwayHash64_SSE41(const void *input, size_t length,
uint64_t seed);
uint64_t thunk_HighwayHash64_VSX(const void *input, size_t length,
uint64_t seed);

/* wyhash v4 */
uint64_t thunk_wyhash_v4(const void *input, size_t length, uint64_t seed);
extern const uint64_t refval_wyhash_v4[];
20 changes: 14 additions & 6 deletions tests/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>

const unsigned default_option_flags = bench_0 | bench_1 | bench_2 |
bench_xxhash | bench_highwayhash |
bench_stadtx | bench_tiny | bench_large;
const unsigned default_option_flags =
bench_0 | bench_1 | bench_2 | bench_xxhash | bench_highwayhash |
bench_stadtx | bench_wyhash | bench_tiny | bench_large;

const unsigned available_eas_flags =
#if T1HA0_AESNI_AVAILABLE
Expand Down Expand Up @@ -96,6 +96,7 @@ void usage(void) {
"Just for comparison:\n"
" --xxhash, --no-xxhash - include/exclude xxHash32 and xxHash64\n"
" --stadtx, --no-stadtx - include/exclude StadtX\n"
" --wyhash, --no-wyhash - include/exclude wyhash\n"
" --highway, --no-highway - include/exclude Google's HighwayHash.\n");
}

Expand Down Expand Up @@ -227,11 +228,14 @@ int main(int argc, const char *argv[]) {
if (option(argv[i], "xxhash", bench_xxhash))
continue;

if (option(argv[i], "highwayhash", bench_highwayhash) ||
option(argv[i], "highway", bench_highwayhash))
if (option(argv[i], "stadtx", bench_stadtx))
continue;

if (option(argv[i], "stadtx", bench_stadtx))
if (option(argv[i], "wyhash", bench_wyhash))
continue;

if (option(argv[i], "highwayhash", bench_highwayhash) ||
option(argv[i], "highway", bench_highwayhash))
continue;

#ifndef T1HA0_DISABLED
Expand Down Expand Up @@ -365,6 +369,7 @@ int main(int argc, const char *argv[]) {
#endif

failed |= verify("StadtX", thunk_StadtX, refval_StadtX);
failed |= verify("wyhash_v4", thunk_wyhash_v4, refval_wyhash_v4);

if (failed)
return EXIT_FAILURE;
Expand All @@ -388,6 +393,9 @@ int main(int argc, const char *argv[]) {
} else if (is_selected(bench_64 | bench_stadtx)) {
hash_function = thunk_StadtX;
hash_name = "StadtX";
} else if (is_selected(bench_64 | bench_wyhash)) {
hash_function = thunk_wyhash_v4;
hash_name = "wyhash_v4";
#ifndef T1HA2_DISABLED
} else if (is_selected(bench_64 | bench_2)) {
hash_function = t1ha2_atonce;
Expand Down
25 changes: 25 additions & 0 deletions tests/wyhash/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

98 changes: 98 additions & 0 deletions tests/wyhash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
Simple Is Best
====

wyhash and wyrand are the ideal 64-bit hash function and PRNG respectively:

**solid**: wyhash passed SMHasher, wyrand passed BigCrush, practrand.

**portable**: 64-bit/32-bit system, big/little endian.

**fastest**: Effecient on all machines, exspecially for short keys.

**simplest**: In the sense of code size.

Currently wyhash has 13 language ports and is the default hasher for a hash table of the great Zig language.

----------------------------------------

**Version 4 is ready!**

big endian support. half code size. faster short key hashing, faster bulk key hashing.

![](Clipboard05.png)
![](Clipboard06.png)

**Good Boy Only Benchmark**

XXH3 was not included as it fails two tests according to SMHasher.

```C
#define XXH_INLINE_ALL
#define XXH_FORCE_MEMORY_ACCESS 0
```
![](Clipboard03.png)
![](Clipboard04.png)
![](Clipboard01.png)
![](Clipboard02.png)
----------------------------------------
Language Ports:
**C#** https://github.com/cocowalla/wyhash-dotnet
**C++** https://github.com/tommyettinger/waterhash
**GO** https://github.com/dgryski/go-wyhash
**GO** https://github.com/orisano/wyhash
**GO** https://github.com/littleli/go-wyhash16
**GO** https://github.com/zeebo/wyhash
**GO** https://github.com/lonewolf3739/wyhash-go
**Java** https://github.com/OpenHFT/Zero-Allocation-Hashing
**Rust** https://github.com/eldruin/wyhash-rs
**Swift** https://github.com/lemire/SwiftWyhash
**Swift** https://github.com/lemire/SwiftWyhashBenchmark
**Swift** https://github.com/jeudesprits/SwiftWyhash
**V** https://github.com/vlang/v/tree/master/vlib/hash/wyhash (v4)
**Zig** https://github.com/ManDeJan/zig-wyhash
----------------------------------------
I thank these names:
Reini Urban
Dietrich Epp
Joshua Haberman
Tommy Ettinger
Daniel Lemire
Otmar Ertl
cocowalla
leo-yuriev
Diego Barrios Romero
paulie-g
dumblob
Yann Collet
ivte-ms
Loading

0 comments on commit b8eefd2

Please sign in to comment.