Intel vector instruction dispatcher #387
No reviewers
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 milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash!387
Loading…
Reference in a new issue
No description provided.
Delete branch "x86dispatch_table"
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?
Started from a baseline developed by @easyaspi314 (#358),
xxh_x86dispatch.cmakes it possible to dynamically detectwhich vector instruction set is present on the active system
and use the (presumable) best available one,
using this priority order :
avx512>avx2>sse2>scalar.3rd party applications willing to employ this ability
just have to
#include "xxh_x86dispatch.h".This header automatically includes
xxhash.h,and swap relevant
XXH3/XXH128symbolswith their vector dispatch counterpart.
Only runs on
x86/x64.Only compiles with
gccandclang.added :
make dispatchtarget, which compilesxxhsumwith this new ability.added :
make xxhsum DISPATCH=1, which is equivalent tomake dispatchIt happens that my wife has one those almost rare icelake laptop, which supports
avx512f.So it's a nice playground to test this code path.
Good news :
xxhsumcompiles and runs fine with-mavx512f.Bad news :
dispatchcompiles, with bothgccandclang, but then fails at runtime.Exact reason is unclear yet.
gccjust immediatelysegfault.clangfails during the self-test (64-bit hash test 100, likely related toxxh3).This feels like some out-of-bound access, but need more traces.
No problem with a standard
avx2laptop or desktop, tested withmacosx,linuxand Windows. So, one needs the specific hardware to observe ...Worst case, I will have to disable
avx512from the dispatcher if I can't debug it on time.Weird...Does my version also segfault?
(On my branch you can just run
make DISPATCH=1).Also, I believe Intel's SDE might be useful for testing AVX512.
OK, this is fixed. This was an index issue, now checked with a
static_assert().Dispatcher works fine on
avx512too now.Shouldn't we use the official names for
-DXXH_VECTOR? e.g.XXH_SSE2,XXH_AVX2, etc?Are you referring to the
README.mddocumentation onXXH_VECTORbuild macro ?I mean in places like
travis.ymlwhere the bug was caused by mixing up the magic ID numbers forXXH_VECTOR.If we just used the textual names, we wouldn't have had the issue you just had.
In reality, this wasn't the source of the problem. The change of vector ID numbers in
.travis.ymlwas merely a consequence of the selected fix.But I do nonetheless agree that expressing vector instruction set in name rather than ID would be beneficial for readability.
Thing is, I don't know how to do that without swamping the
Makefilewith a ton of lines of code just for this (barely used and mostly debug) feature.Anyway, if you believe you have a good solution, you're welcomed to give it a try.
It could be part of a separate PR, as I guess it doesn't impact the current one.
Huh? I am just talking about using
-DXXH_VECTOR=XXH_AVX2instead of-DXXH_VECTOR=2. It works, macros aren't expanded until they are used.My bad, misunderstood,
yes you are right, this is much cleaner