WebAssembly SIMD128 support #824
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#824
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?
WebAssembly's SIMD128 extension can use the double-width NEON approach almost literally (not XXH-ified):
Edit: I can count.
Dispatching support at runtime is impossible, as the entire binary is validated before executing, as far as I know. However, it can be dispatched as separate modules in JavaScript.
Clang 15, Node 18.13.0 (V8 10.2.154.23-node.21, a.k.a. Chromium 102), Cortex X1 gets 13.1 GB/s vs 6.6 GB/s from an initial implementation, so this seems like it is worth it.
I haven't tried Firefox or on x86 yet.
I expect x86 to not get as much because the shuffle and extmul would not work out as cleanly in SSE or AVX — WASM was definitely designed for NEON and not SSE.
Ideally it would be this, but I don't know if the JIT is smart enough to optimize the shuffle to unpacklo and unpackhi, and it might do two shuffles and a blend for each one.
Edit again: checked v8's source code, it would emit two
_mm_shuffle_epi8s and a_mm_or_si128per shuffle. No special cases except for when the two arguments are identical.It still would probably be faster than scalar despite the extra shuffling.
Update: 15.3 GB/s if I convert the data_swap's shuffle to a swizzle so V8 doesn't generate inline shuffle masks each time. It also should be smaller because the shuffle is an 18 byte opcode lol
Same version (with the updated swizzle), Clang 15, Node 18.14.0 (V8 10.2.154.23-node.22, a.k.a. Chromium 102), Core i7-8650u, it is also really good, 10.1 GB/s vs 5.5 GB/s.
WIP implementation is at #825
merged