ici/crc: add x86 SSE4.2 + PCLMULQDQ hardware acceleration for BPv7/CFDP CRCs - #112
Open
zebastian wants to merge 1 commit into
Open
ici/crc: add x86 SSE4.2 + PCLMULQDQ hardware acceleration for BPv7/CFDP CRCs#112zebastian wants to merge 1 commit into
zebastian wants to merge 1 commit into
Conversation
…DP CRCs Accelerate the two CRC polynomials on the ION data path with x86 intrinsics, selected at run time so a single binary still runs on CPUs that lack the instructions: - CRC-32C (poly 0x1EDC6F41): use the SSE4.2 crc32 instruction, which computes exactly this reflected polynomial. Wired into both ion_CRC32_1EDC6F41_C and ion_CRC32_1EDC6F41_C_slice (BPv7 block CRCs, CFDP checksums). ~2.2x over the slice-by-16 table. - CRC-16/X-25 (poly 0x1021): no dedicated instruction exists, so fold 16-byte blocks with PCLMULQDQ carry-less multiply and reduce the result with the byte-wise table. Fold constants reflect(x^143 mod P) and reflect(x^79 mod P). ~2.6x over the slice-by-8 table. Detection is via __builtin_cpu_supports(); each accelerated routine carries a per-function target attribute so the rest of the object stays at the baseline ISA (no -msse4.2/-mpclmul build flags, no SIGILL on older CPUs). Output is bitwise-identical to the existing table routines, verified exhaustively across all offsets, lengths, and accumulation boundaries. Guarded to x86/x86_64 GCC/Clang; other polynomials and platforms fall through to the table paths unchanged.
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.
Accelerate the two CRC polynomials on the ION data path with x86 intrinsics, selected at run time so a single binary still runs on CPUs that lack the instructions:
CRC-32C (poly 0x1EDC6F41): use the SSE4.2 crc32 instruction, which computes exactly this reflected polynomial. Wired into both ion_CRC32_1EDC6F41_C and ion_CRC32_1EDC6F41_C_slice (BPv7 block CRCs, CFDP checksums). ~2.2x over the slice-by-16 table.
CRC-16/X-25 (poly 0x1021): no dedicated instruction exists, so fold 16-byte blocks with PCLMULQDQ carry-less multiply and reduce the result with the byte-wise table. Fold constants reflect(x^143 mod P) and reflect(x^79 mod P). ~2.6x over the slice-by-8 table.
Detection is via __builtin_cpu_supports(); each accelerated routine carries a per-function target attribute so the rest of the object stays at the baseline ISA (no -msse4.2/-mpclmul build flags, no SIGILL on older CPUs). Output is bitwise-identical to the existing table routines, verified exhaustively across all offsets, lengths, and accumulation boundaries. Guarded to x86/x86_64 GCC/Clang; other polynomials and platforms fall through to the table paths unchanged.
CRC16 PCLMULQDQ: 9.20 GB/s vs 3.51 GB/s slice-by-8 table (~2.6×)
CRC32 SSE4.2: 10.87 GB/s vs. 4.86 GB/s for the existing slice-by-16 table (~2.2×)