Suggestion: Use AVX-512DQ for XXH3_scrambleAcc_avx512 #1100
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#1100
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, the
XXH3_scrambleAcc_avx512function needs to simulate 64-bit multiplications using 4 instructions:With AVX-512DQ, this can be done with a single instruction:
Performance:
Running this quick benchmark on my machine (AMD AI 9 HX 370) shows a ~38% speedup.
Almost every CPU that implements AVX-512 also implements the DQ extension. The only exceptions are Intel's long-discontinued Xeon Phi accelerators (Knights Landing and Knights Mill). Since Xeon Phi saw very low adoption and support for it was recently removed in GCC 15, this kind of optimization that relies on AVX-512DQ is, in my opinion, worth it.
I'm not very familiar with this codebase, but if preferred I can attempt to implement this and open a PR.
On AMD, vpmullq is native 64-bit multiplier units, whereas on Intel, it is emulated by FMA units. So your optimization will actually reduce performance for all Intel CPU.
see
https://github.com/llvm/llvm-project/issues/158854
https://uops.info/html-instr/VPMULLQ_ZMM_ZMM_ZMM.html
Nice idea,
but indeed, the performance difference between AMD and Intel on this specific instruction is very large,
making it not universal.
Moreover, the current AVX512 implementation is only tied to
avx512f, but notavx512dqyet.For both these reasons, I think it's proper to not follow this direction in the reference implementation.
Feel free to open an AMD specific fork that could benefit from this change.