Add arm64 NEON acceleration#32
Open
mgomes wants to merge 7 commits into
Open
Conversation
Four chunks/parents per pass in 128-bit vector lanes, generated Go assembly (no cgo) following the upstream C NEON implementation. The generator lives in avo/neon and the committed impl_arm64.s is verified against hash_pure by the same property tests used for AVX2.
Same thresholds as the AVX2 path: HashF for inputs over two chunks, HashP for two or more parents. Below the HashF threshold the 4-lane kernel cannot beat the scalar loop since it always runs 16 blocks.
Bumping the go directive would change loop variable semantics for the existing avx2/sse41 generators; write the neon generator in 1.13-compatible style instead.
Write errors were silently discarded, so an ENOSPC during generation could exit zero and leave truncated assembly behind the redirect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On arm64 every input fell back to the pure-Go implementation. This adds a cgo-free NEON backend for chunk and parent hashing, processing four chunks/parents per pass in 128-bit vector lanes, dispatched with the same thresholds as AVX2. The committed
impl_arm64.sis emitted by a small generator inavo/neon(mirroring how the avo-generated amd64 assembly is treated) and is verified againsthash_pureby the same property tests used for AVX2.Apple M4, benchstat n=6:
Unfortunately NEON is fixed at 128 bits by the ARM architecture, so four chunks per pass is the ceiling (versus eight for 256-bit AVX2). ARM's wider SVE extension is optional and not implemented on Apple Silicon yet. Happy to follow up with a PR that interleaves the two independent 4-lane passes into one instruction stream (still single-threaded). That should fill idle NEON slots and boost perf a bit more.