Repository navigation
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kernel/riscv64/sum_vector.cis the S/DSUM kernel of RISCV64_ZVL256B. In its unrolled loop forincx > 1it neveradvanced
ix, and it tripledinc_xvon every iteration:For
incx > 1andn >= 2*vl, this summed the first block again on every iteration, plus elements further and furtherpast the end of
x:cblas_dsumreturned wrong results, e.g. −2.15 instead of 3.55;cblas_ssum(1000, x, 2)andcblas_dsum(1000, x, 2)crashed withSIGSEGV.
The fix advances
ixby two blocks, aszsum_vector.calready does. No other target uses this file: C910V and GENERICuse
../arm/sum.c, and ZVL128B usessum_rvv.c.Testing
All runs were on a SpacemiT K3 (X100 core), GCC 15.2, RISCV64_ZVL256B.
OpenBLAS test suite (
make TARGET=RISCV64_ZVL256B NO_FORTRAN=1 NO_LAPACK=1 NO_LAPACKE=1 USE_OPENMP=0 NUM_THREADS=8): identical to develop, with utest 141/141, extension tests 1479/1479 and every BLAS/CBLAS test PASSED.A level-1 sweep through CBLAS, for all four precisions. It covers copy, swap, scal, axpy, axpby, rot, dot,
asum, sum, i?amax and i?amin:
Disclosure: an AI coding agent (Anthropic Claude) prepared this patch, its validation runs and this description on
behalf of the account owner. All numbers above come from archived runs on the board.