Enable RVV-optimized TRSM kernels for RISCV64_ZVL128B#5830
Conversation
Use existing RVV-optimized TRSM kernel implementations instead of the
generic C versions for the RISCV64_ZVL128B target. The RVV kernels
(trsm_kernel_{LN,LT,RN,RT}_rvv_v1.c) are already present in the
repository and used by the x280 target, but were not enabled for
ZVL128B.
Note: ZVL256B is not included because the RVV TRSM kernel has
correctness issues with VLEN=256.
Signed-off-by: Felix-Gong <gongxiaofei24@iscas.ac.cn>
c50f0a6 to
4fb51e3
Compare
Root-cause analysis of the
|
| type | SEW | VSETVL_MAX (solver M-block) |
GEMM_UNROLL_M (packer) |
match? |
|---|---|---|---|---|
| S | 32 | 16 | 8 | ✗ |
| D | 64 | 8 | 8 | ✓ |
| C | 32 | 16 | 8 | ✗ (→ cblas_ctrsm FAILED) |
| Z | 64 | 8 | 4 | ✗ |
This lines up exactly with the observed cblas_ctrsm failure, and it is the same effect as the "wrong results at VLEN=256" that motivated excluding ZVL256B — it's one root cause, not two. x280 is unaffected because its GEMM kernel and copies are all _rvv_v1, so the rectangular block width is also VSETVL_MAX and everything agrees.
Note the mismatch depends on the runtime VLEN, not the build target name: a ZVL128B binary run on a VLEN≥256 core still uses VSETVL_MAX≥16, so it breaks even though the target says 128.
Options
- Revert TRSM to generic for this target (safe, guaranteed green, drops the RVV TRSM speedup):
[SDCZ]TRSMKERNEL_{LN,LT,RN,RT} = ../generic/trsm_kernel_{LN,LT,RN,RT}.c - Keep the optimization by making the whole
ZVL128BGEMM path adaptive_rvv_v1(likex280), or by writing TRSM kernels that block byGEMM_UNROLL_Minstead ofVSETVL_MAX. This is a larger change and needs on-hardware verification that GEMM/TRMM don't regress.
I'm planning to verify both empirically on a SpaceMiT X60 (VLEN=256) — reproduce the ctrsm failure as-is, then confirm the chosen fix. Happy to push the fix once validated. Let me know which direction you'd prefer.
Summary
trsm_kernel_{LN,LT,RN,RT}_rvv_v1.c) forRISCV64_ZVL128Btargetx280target, but were not enabled for ZVL128B configurationNote on ZVL256B
ZVL256B is intentionally excluded from this change. Testing revealed that the RVV TRSM kernel produces incorrect results with VLEN=256 (e.g., 3x3 lower triangular solve returns wrong values). This needs to be investigated separately.
Test plan