From d0b52234d9803d9b698f4c9cc645f6e43e4442b4 Mon Sep 17 00:00:00 2001 From: 6eanut Date: Fri, 18 Sep 2026 09:02:43 +0000 Subject: [PATCH] RISC-V: widen the ZVL256B AXPY vector length to LMUL m4 The ZVL256B real AXPY kernel selected LMUL m2. With a 256-bit vector unit that makes each vle/vse move 16 single-precision (8 double- precision) elements, and the main loop, whose VL is clamped to VLMAX, runs ceil(n/16) (resp. ceil(n/8)) times. The register file is 32 vector registers wide and the kernel keeps four vector operands live (vx0, vx1, vy0, vy1), so m2 occupies 8 of them - the grouping is narrower than the register budget needs. Raise LMUL to m4, which doubles the elements per vector load and store and halves both the loop trip count and the number of vsetvli executions for the same n. This also matches the branch this file already takes for the other riscv64 targets, where LMUL is m4. Only the vector register grouping changes: for a given column each element is still processed by one vfmacc over the same operand triplets in the same ascending element order, so each y[i] accumulates the same sequence of addends as before. For non-zero increments the emitted results are bit-identical: a differential run of the baseline and patched kernels against each other, and of both against a double-precision reference, over 11136 single-precision and 11136 double-precision cases covering n = 0..4097 and increments of 1, 2, 3, 4, 5, 7, 8 and 16, with guard pages around every buffer, shows no mismatch and no out-of-bounds access. The library built from the patched kernel passes 125/125 utests and 1473/1473 extension tests. Measured on one X100 core at 2.2 GHz, warm-up once and the median of three runs per size: saxpy 256 +25.39%, 512 +28.59%, 1024 +30.15%; daxpy 256 +28.62%, 512 +35.59%, 1024 +40.22%. Co-authored-by: Yuansheng Co-authored-by: Ning Tian Signed-off-by: jiakai xu --- kernel/riscv64/axpy_vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/riscv64/axpy_vector.c b/kernel/riscv64/axpy_vector.c index c77a18afa5..041f797a63 100644 --- a/kernel/riscv64/axpy_vector.c +++ b/kernel/riscv64/axpy_vector.c @@ -29,7 +29,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "common.h" #ifdef RISCV64_ZVL256B -# define LMUL m2 +# define LMUL m4 # if defined(DOUBLE) # define ELEN 64 # else