Generalize dispatch add-in #483
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#483
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently a client needs to look for xxhx86dispatch.h and see if it can build against it, and link to the dispatch symbols, which is a bit unfortunate:
Generally, from a system library perspective it would be beneficial to have one way to use whatever fastest xxhash there is, whether it's an optimized X86 dispatch thing or a future optimized ARM version, for example.
I think the answer is to add a more generic name xxhash_dispatch.h (xxhash_simd.h?, also keeping the old name around for compatibility), and either install that (DISPATCH=1) or make it just an include for xxhash.h if DISPATCH=0, such that you can always just
#include <xxhash_dispatch.h>and you'll get whatever fastest version is available; and then you have xxhash.h left in case you want a non-dispatched version, which maybe you have valid reasons for (short data sizes?).The other alternative would be to make
xxhash.hbe the dispatched one if DISPATCH=1, and install real "xxhash.h" as xxhash_basic.h, such that everyone using xxhash.h gets dispatched versions automatically.Arguably it's worth wondering if it shouldn't do DISPATCH=1 automatically when building as a shared library. Basically avoiding the need for distributions to set those flags based on architectures, and having to adjust that if an ARM version is added for example.
There is unfortunately no easy way to check if ARMv7 has NEON.
The architecture has it (it is in the HCPTR register), but it can't be accessed from user code. The best option is to use platform-specific things like
/proc/cpuinfowhich is very ugly.The answer on Linux would be
getauxval(AT_HWCAP) & HWCAP_NEONis my understanding. And yes, it will get platform specific, but oh well, that's a price you gotta pay for optimal performance - and it's only in a dispatch.c file, so meh.This objective has been set for
v0.9.0Next version of
xxhsumwill automatically compile withDISPATCH=1when target is detected asx86/x64.Note that this
DISPATCH=1functionality is forxxhsum, the command line interface, and not forlibxxhash, the library.