Skip to content

riscv64: wire TRSM, complex SYMV, and complex GEMM copy RVV kernels#5807

Open
mengzhuo wants to merge 1 commit into
OpenMathLib:developfrom
mengzhuo:no_gen
Open

riscv64: wire TRSM, complex SYMV, and complex GEMM copy RVV kernels#5807
mengzhuo wants to merge 1 commit into
OpenMathLib:developfrom
mengzhuo:no_gen

Conversation

@mengzhuo
Copy link
Copy Markdown

Wire existing RVV-optimized kernels into KERNEL.RISCV64_ZVL128B and KERNEL.RISCV64_ZVL256B that were already implemented but not referenced:

  • TRSM (S/D/C/Z, all 4 directions): replace ../generic/trsm_kernel_.c with trsm_kernel__rvv_v1.c
  • TRSM copy: add TRSMCOPY*M and ZTRSMCOPY*M variables using trsm*copy_rvv_v1.c and ztrsm*copy_rvv_v1.c
  • Complex SYMV (C/Z): replace ../generic/zsymv_k.c with zsymv_*_rvv.c
  • HEMV (C/Z): replace zhemv_vector.c with zhemv_rvv.c
  • Complex GEMM copy (C/Z): replace ../generic/zgemm_ncopy/tcopy with zgemm_ncopy_rvv_v1.c / zgemm_tcopy_rvv_v1.c

Generic fallback counts: ZVL256B 56->28, ZVL128B 63->47

Wire existing RVV-optimized kernels into KERNEL.RISCV64_ZVL128B and
KERNEL.RISCV64_ZVL256B that were already implemented but not referenced:

- TRSM (S/D/C/Z, all 4 directions): replace ../generic/trsm_kernel_*.c
  with trsm_kernel_*_rvv_v1.c
- TRSM copy: add TRSMCOPY*_M and ZTRSMCOPY*_M variables using
  trsm_*copy_rvv_v1.c and ztrsm_*copy_rvv_v1.c
- Complex SYMV (C/Z): replace ../generic/zsymv_k.c with zsymv_*_rvv.c
- HEMV (C/Z): replace zhemv_*_vector.c with zhemv_*_rvv.c
- Complex GEMM copy (C/Z): replace ../generic/zgemm_ncopy/tcopy with
  zgemm_ncopy_rvv_v1.c / zgemm_tcopy_rvv_v1.c

Generic fallback counts: ZVL256B 56->28, ZVL128B 63->47
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 20, 2026

Merging this PR will improve performance by 17.64%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

#### 🎉 Hooray! `pytest-codspeed` just leveled up to 5.0.2!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

⚡ 14 improved benchmarks
✅ 48 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_daxpy[100-c] 25.3 µs 21.6 µs +17.2%
test_daxpy[100-d] 24.3 µs 20.6 µs +18.15%
test_nrm2[100-d] 37.7 µs 25.8 µs +46.39%
test_daxpy[100-s] 24.2 µs 20.4 µs +18.58%
test_nrm2[100-dz] 28.9 µs 25.3 µs +14.22%
test_nrm2[1000-d] 30.6 µs 26.8 µs +14.07%
test_daxpy[100-z] 26 µs 22.3 µs +16.8%
test_nrm2[1000-dz] 35.5 µs 31.9 µs +11.41%
test_daxpy[1000-c] 32.9 µs 29.2 µs +12.75%
test_daxpy[1000-d] 32.6 µs 28.4 µs +15.06%
test_daxpy[1000-s] 27.7 µs 24 µs +15.52%
test_daxpy[1000-z] 40.7 µs 37 µs +10.19%
test_dot[1000] 28.4 µs 24.5 µs +15.99%
test_dot[100] 22.5 µs 18 µs +24.57%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mengzhuo:no_gen (7ad237f) with develop (3da0ff7)

Open in CodSpeed

@martin-frbg
Copy link
Copy Markdown
Collaborator

Sorry, no - you cannot just wire up GEMM copy functions from a different target without regard for the blocking parameters as defined in param.h that the respective GEMM kernels use. Likewise, TRSM depends in part on the GEMM kernel so needs to be matched to it.
What would probably work from this PR is the SYMV/HEMV parts , and reusing ZGEMMONCOPY/ZGEMMOTCOPY from x280 for ZVL256B - but exactly the zgemm_ncopy_4_rvv/zgemm_tcopy_4_rvv that KERNEL.x280 has.
But it would still be a fairly pointless exercise without benchmark results showing a clear advantage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants