From 38c3a8c65439059344d94aceddb1d4bd880a15da Mon Sep 17 00:00:00 2001 From: Yicheng Kang <3193997905@qq.com> Date: Sun, 25 Oct 2026 15:47:32 -0700 Subject: [PATCH] RISC-V: fix the strided loop of sum_vector.c (S/DSUM on RISCV64_ZVL256B) The unrolled strided loop never advanced ix and tripled inc_xv on every iteration ("inc_xv += inc_xv * 2"), so for incx > 1 and n >= 2*vl it summed the first block repeatedly plus elements past the end of x. Results were wrong, and for longer vectors the reads left the mapping (SIGSEGV for cblas_ssum(1000, x, 2)). Advance ix by two blocks instead, as zsum_vector.c does. --- kernel/riscv64/sum_vector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/riscv64/sum_vector.c b/kernel/riscv64/sum_vector.c index cf734faabf..68fd0c130f 100644 --- a/kernel/riscv64/sum_vector.c +++ b/kernel/riscv64/sum_vector.c @@ -96,7 +96,7 @@ FLOAT CNAME(BLASLONG n, FLOAT *x, BLASLONG inc_x) v1 = VLSEV_FLOAT(&x[ix+inc_xv], stride_x, gvl); v_sum = VFADDVV_FLOAT(v_sum, v1, gvl); j += gvl * 2; - inc_xv += inc_xv * 2; + ix += inc_xv * 2; } v_res = VFREDSUMVS_FLOAT(v_sum, v_res, gvl); }