Repository navigation
Fletcher short inputs: one pass below the kernel threshold, plus doc gaps - #3
Merged
Merged
Conversation
On 64-bit targets sum_portable() gets the input bound from its caller and, below the kernel threshold, sums in one run without the loop over reduction runs or reducing the incoming sums first. Empty data takes the unfinished-block path, and finished sums return through std::bit_cast. Fletcher-32 at 20 B against the deferred-modulo loop: x86-64 GCC 0.73x -> 0.94x, Cortex-A72 0.84x -> 0.94x. 32-bit targets compile to the same code.
Re-measured Fletcher/Adler-32 short inputs; untested acceleration paths; EOR3, Zve64x, RVV vector lengths; CRC on the A72 against zlib-ng and ISA-L; braid count and rejected table layouts; xxHash and MurmurHash3 reference comparisons; reduction bounds no test reaches; Cortex-M4 code size.
misc-include-cleaner over every header, each architecture header with the prelude of its dispatcher, in nine target configurations; only includes unused where their code is active are removed.
On 32-bit Arm without NEON (Cortex-M, small A-profile cores), the one-shot and streamed MurmurHash3_x86_32 take four blocks per iteration, and the fletcher4 word loop takes two words. In-order cores then overlap the independent work with the dependency chains. On a Cortex-M33 (nRF54L15) at 4 KiB: MurmurHash3_x86_32 3.77 -> 2.27 cycles per byte, fletcher4 3.78 -> 2.79. Other targets compile to the same code as before; x86-64 lost 2-4 % from 4 KiB with the unrolled MurmurHash3 loop.
Cycles and MB/s at 128 MHz with code in RRAM and the instruction cache on. Also: CRC tables in RAM vs RRAM, kernel thresholds rechecked on the M33, no general-purpose CRC unit on the chip, and updated Cortex-M4 code sizes.
…letcher4 loops Same harness and code alignment for both builds: MurmurHash3_x86_32 3.02 -> 2.52 cycles per byte at 4 KiB (1.20x), fletcher4 3.54 -> 3.17 (1.12x), 0.98-0.99x at 20 B.
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.
Performance
On 64-bit targets the portable Fletcher/Adler-32 loop now takes the input bound from its caller. Below the kernel threshold it sums in one run, with no loop over reduction runs and no reduction of the incoming sums first. That removes a stack frame. Empty data goes to the unfinished-block path, and finished sums return through
std::bit_cast.Fletcher-32 against the deferred-modulo loop (Wikipedia),
-O2, one pinned core:-mcpu=cortex-a72, 20 B-march=armv8-a, 20 B-O2and-Os) compile to the same code as before.Tests:
adler32|fletcherpass on native-gcc, native-clang, native-asan, native-gcc-portable, x86_64-gcc-pclmul, cross-aarch64-pmull, cross-aarch64-portable, cross-arm-crc32, cross-arm-portable, cross-riscv64-rvv, cross-riscv64-portable, and a local-march=nativebuild with AVX-VNNI. The big-endian branch was not run, because noaarch64_betoolchain is available.Cortex-M33 (nRF54L15)
All algorithms were measured on an nRF54L15 at 128 MHz, with code in RRAM and the instruction cache on. Every result matched the host's checksums.
On 32-bit Arm without NEON:
Other targets compile to the same code as before. The
cross-arm-portablepreset tests the new loops in QEMU. On a Cortex-M4 (nRF52840), with both builds aligned the same way, the changes give 1.20× (MurmurHash3_x86_32, 3.02 → 2.52 cycles per byte) and 1.12× (fletcher4, 3.54 → 3.17). At 20 B they are 0.98-0.99× as fast as before.The new doc sections cover:
The chip has no general-purpose CRC unit. Its CRACEN block is a crypto engine, which is out of scope.
Includes
Unused includes were removed from three architecture headers.
Documentation
crc32without PCLMULQDQ, Arm-stateldm, big-endian, and RVV vector lengths other than 128.+sha3, and Zve64x.