1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00
Files
6eanut 3cdcd64fb0 MDEV-41271 Add RISC-V Zvbc accelerated CRC-32C implementation
Extend the RISC-V CRC-32C path with a Zvbc vector implementation:

  - mysys/CMakeLists.txt: detect Zvbc + RVV intrinsics under
    -march=rv64gc_zbb_zvbc; when available rebuild the new
    crc32c_riscv_zvbc.cc with that march (optional, Zbc unaffected);
  - mysys/crc32/crc32c_riscv_zvbc.cc (new): K-lane vector core --
    4 lanes x 128-bit folding, vlseg2e64 de-interleaved 64B loads,
    vclmul_vx broadcast constants, single-element vector CLMUL for
    the Barrett merge (no scalar Zbc instruction anywhere), bit-exact
    with the Zbc core (same fold constants k1..k4 and Barrett math);
  - adaptive VLEN: one e64m1 vector pair at VLEN>=256, two pairs at
    VLEN=128, so 128-bit cores execute the vector path at full width;
  - mysys/crc32/crc32c_riscv.cc + crc32c.cc: runtime dispatch via
    riscv_hwprobe -- Zbc is preferred when present (existing
    deployments keep the optimized scalar core); the Zvbc vector
    path accelerates cores that implement Zvbc but not scalar Zbc.

Correctness: RFC 3720 + random/chained/boundary inputs bit-identical
to slicing-by-4; official unittest/mysys/crc32-t.c 36/36.

Performance on Spacemit X100 (k3, VLEN=256, gcc 14.3.0), vs inherited
slicing-by-4 crc32c_slow (official slow path, same my_crc32c entry):

    len      slow (MB/s)   PR-B2 Zvbc (MB/s)   vs slow
    128 B        289            1147              4.0x
    256 B        296            2105              7.1x
    1 KiB        297            5466             18.5x
    4 KiB        297            9116             30.7x
    64 KiB       296           11398             38.7x

Dispatch prefers the scalar Zbc path when Zbc is available, so
existing Zbc deployments see no behavior change or regression;
the vector path is selected on cores without scalar Zbc.
No behavior change on non-riscv64 builds or toolchains without
Zvbc (optional compile check).

Review revisions requested on PR #5746 (dr-m):

  - mysys/crc32/crc32c_riscv.cc: assemble the ZBC/ZVBC extension bits
    without a branch at both sites, dropping the redundant intermediate
    variable; replace `(void) hwprobe;` with `std::ignore = hwprobe;` and
    include <tuple>.  <tuple> introduces no static constructor, so the
    ifunc resolver's load-time constraint is unaffected.
  - mysys/crc32/crc32c.cc: expand the comment above the Zbc preference
    with the structural reason -- the vector core deliberately reuses the
    scalar fold to stay bit-exact, so its vl is capped at 4 and a wider
    VLEN buys nothing; scalar Zbc is preferred because the two are level
    on large input and the scalar path is clearly ahead on small input.
    Comment-only.

Assisted-by: YuanSheng:DeepSeek-V4-Flash
Co-authored-by: Xiaofei Gong <gongxiaofei24@iscas.ac.cn>
Signed-off-by: Jiakai Xu <xujiakai2025@iscas.ac.cn>
2026-10-01 10:26:01 +03:00
..
…
2025-04-29 11:18:00 +10:00
2026-09-04 12:14:15 +02:00
2026-05-26 21:15:58 +02:00
2023-08-04 08:01:06 +02:00
…
2026-07-30 11:41:55 +02:00
2026-02-07 22:12:32 +01:00
…
2025-07-31 20:55:47 +02:00
…
2025-04-29 11:18:00 +10:00
2026-08-20 08:27:14 +02:00
…
2022-04-25 09:40:40 +03:00
2026-03-24 09:49:17 +02:00
…
2026-05-26 21:15:58 +02:00
2026-05-04 18:21:26 +02:00
…
2026-06-15 16:53:03 +02:00
2026-09-04 12:21:02 +02:00
2026-06-15 16:53:03 +02:00
2026-05-26 21:15:58 +02:00
2024-11-23 08:14:22 -07:00
2023-10-14 13:36:11 +03:00
…
…
…
2025-09-24 13:40:09 +03:00
…
…
…
2024-10-31 10:01:01 +01:00
2026-08-19 08:40:05 +02:00
2026-05-08 08:00:01 +02:00
2021-10-29 18:29:01 +02:00
2026-06-24 12:27:13 +02:00
2026-01-08 12:02:45 +01:00
2024-10-29 14:47:32 +01:00
2026-08-19 08:40:05 +02:00
2026-08-19 11:28:01 +02:00
2026-01-21 00:22:06 +07:00
2025-10-25 00:19:11 +07:00
…