Conversation
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 <yuansheng@isrc.iscas.ac.cn> Co-authored-by: Ning Tian <tianning24@iscas.ac.cn> Signed-off-by: jiakai xu <xujiakai2025@iscas.ac.cn>
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
Raise the LMUL of the ZVL256B real AXPY kernel from
m2tom4.With a 256-bit vector unit,
m2moves 16 single-precision (8 double-precision)elements per
vle/vse, so the main loop, whose VL is clamped to VLMAX, runsceil(n/16)(resp.ceil(n/8)) times. The register file is 32 vector registerswide and the kernel keeps four vector operands live (
vx0,vx1,vy0,vy1),so
m2occupies 8 of them — the grouping is narrower than the register budgetneeds.
m4doubles the elements per vector load and store and halves both the loop tripcount and the number of
vsetvliexecutions for the samen. It also matchesthe branch this file already takes for the other riscv64 targets, where LMUL is
already
m4.Only the vector register grouping changes: for a given column each element is
still processed by one
vfmaccover the same operand triplets in the sameascending element order, so each
y[i]accumulates the same sequence of addendsas before. For non-zero increments the emitted results are bit-identical.
This backs both SAXPY and DAXPY.
Performance
benchmark/saxpy.gotoandbenchmark/daxpy.goto, one X100 core at 2.2 GHz,single thread, warm-up once and the median of three runs per size:
Testing
make testsreturns 0: 125/125 utests, 1473/1473 extension tests, no newCBLAS failure.
single-precision and 11136 double-precision cases, covering
n = 0..4097andincrements of 1, 2, 3, 4, 5, 7, 8 and 16, produce output bit-identical to the
unpatched kernel, with no out-of-bounds access. Both builds were also checked
against a double-precision reference.
vsetvliin the kernel moves frome32,m2/e64,m2toe32,m4/e64,m4.