feat: add ARM NEON optimization for startcode prefix search#3949
Open
llongint wants to merge 1 commit into
Open
feat: add ARM NEON optimization for startcode prefix search#3949llongint wants to merge 1 commit into
llongint wants to merge 1 commit into
Conversation
SIMD fast filter: load 64 bytes, use ext to create adjacent byte pairs, detect consecutive 0x00 bytes via orr+umin+uminv reduction. No candidate pair → skip entire 64B block (~97% filtered); found → fall back to precise C scan for 0x000001. Performance (C: 8268.15 → NEON: 501.80 cycles/iter, ~16.5x) Refactor into pfDetectStartCodePrefix function pointer dispatch, selecting C/NEON at runtime based on CPU capabilities. Add comprehensive decoder unit tests for startcode detection.
Author
|
cc @mstorsjo Could you help review this? |
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.
SIMD fast filter: load 64 bytes, use ext to create adjacent byte pairs, detect consecutive 0x00 bytes via orr+umin+uminv reduction. No candidate pair → skip entire 64B block (~97% filtered); found → fall back to precise C scan for 0x000001.
Performance (C: 8268.15 → NEON: 501.80 cycles/iter, ~16.5x)
Refactor into pfDetectStartCodePrefix function pointer dispatch, selecting C/NEON at runtime based on CPU capabilities.
Add comprehensive decoder unit tests for startcode detection.
The assembly code directly uses the compiler-generated output, see: https://www.godbolt.org/z/9coKKfGd5
The following implementation (883.83 Cycles/iter) was attempted, contributed by expert Dougall Johnson: https://www.godbolt.org/z/fKrfPEPW4
And this implementation (744.94 Cycles/iter): https://www.godbolt.org/z/jMhzzMWad