You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
optimize crc32c for riscv64 with Zbc carry-less multiplication (apache#3312)
* optimize crc32c for riscv64 with Zbc carry-less multiplication
Implement hardware-accelerated CRC32C for RISC-V using the Zbc
(carry-less multiplication) extension. The implementation uses
128-bit folding with 4-way parallelism and Barrett reduction,
following the approach from Hadoop PR #8371.
Key changes:
- Add rv_clmul/rv_clmulh inline assembly wrappers
- Implement 128-bit fold with 4-way parallel processing (64 bytes/iter)
- Add Barrett reduction for final 128-bit to 32-bit conversion
- Runtime CPU feature detection via /proc/cpuinfo
- Compile-time guard: #ifdef __riscv_zbc
- CMake option: WITH_RISCV_ZBC (default OFF)
Performance: 3-4x speedup over table-based 8-byte unrolled baseline,
~1.1 GB/s throughput on 1MB data.
Correctness: Verified against RFC 3720 B.4 and bitwise reference.
Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
* fix: wrap isSSE42() in #ifdef __SSE4_2__ to fix -Wunused-function
isSSE42() is only called from within #ifdef __SSE4_2__ blocks,
but the function definition was unconditional, causing
-Wunused-function errors on non-x86 builds with -Werror.
Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Fix CRC32C Zbc: add missing ^ 0xFFFFFFFF pre/post processing
rv_crc32c_clmul was missing the standard CRC32C pre/post XOR
conversion. ExtendImpl does crc ^ 0xFFFFFFFF at entry and
result ^ 0xFFFFFFFF at exit, but rv_crc32c_clmul did neither,
causing wrong CRC values on RISC-V with Zbc extension.
Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
---------
Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
0 commit comments