Repository navigation
Fix arm64 NEON dispatch to use the existing shared wrappers - #2
Open
thomasahle wants to merge 1 commit into
Open
thomasahle wants to merge 1 commit into
thomasahle wants to merge 1 commit into
Conversation
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.
Fixes #1.
example.cppfails to compile on arm64 because the NEON dispatch instantiatesV2Neon,V3Neon, andV4Neon, while the shared SSE2/NEON wrappers are declared asV2Sse2,V3Sse2, andV4Sse2.Use the same SSE2-or-NEON guard for the dispatch as for those wrapper declarations, and remove the duplicate branch that references undeclared functions. The existing arm64
BlockWrapper128continues to execute NEON operations. The header change is one guard edit and deletion of the obsolete branch; the hash implementations and x86 dispatch remain unchanged.Add
check-dispatch.cpp, a standalone test in the style of the existing consistency checker. It reads entropy arrays and input bytes from a simple text stream and emits all returned words fromHalftimeHashStyle64/128/256/512andadvanced::V1<3>throughV4<3>. Compile it with-DHALFTIME_TEST_SCALARto select the header's existing scalar fallback; that test-only option undefines the architecture feature macros before including the header. The normal build uses native dispatch without aliases or header substitutions.Verified against upstream commit
caf7924ceab4721f4e0cc33442b185558ba7f1c4:clang-1700.6.4.2): the stock example fails with 12 undeclared-name diagnostics; the fixed example compiles and runs with-std=c++17 -O2, both with default target flags and-march=armv8-a+crypto.kEntropyBytesNeeded / sizeof(uint64_t)allocation of 8,866 words. The JSON stores the actual entropy words and input bytes, not just seeds.-O2both with and without-fwrapv, for 14 builds total. All 73,744 returned 64-bit words per build match byte-for-byte: 36,872 API calls per build, zero mismatches. Both canonical hex streams and their decoded little-endian bytes were compared.Vector JSON SHA-256:
c731f2e7565e5798dafa9c7ecf5c43ed9807ec0254a062e7385a0d1c2287d8d1.Common output-stream SHA-256:
554f8550a4aefd9badd87131998fe2b8993b153c3141a71862c24041fb05342f.Reproduction scripts, vectors, exact compiler commands, dispatch reports, outputs from both hosts, and the complete comparison are in the accompanying verification directory. The larger vector corpus and verification artifacts are outside the source patch. The Mac runs were sequential correctness checks, with no timing benchmark.
The shared
TabulateAfterout-of-bounds array subscript remains a separate portability defect. Existing signed lane sums motivated the additional-fwrapvruns. These results establish equality for the tested builds and vectors; they do not establish that the existing header is free of undefined behavior. Homebrew GNU g++ 14.2.0 on arm64 still fails on existing NEON vector conversions and local SDK declarations; this change specifically fixes the dispatch-name failure reproduced with Apple clang 17.