Add a WASM SIMD128 SAXPY/DAXPY kernel - #5984
Open
jjerphan wants to merge 1 commit into
Open
Conversation
kernel/wasm/KERNEL is included after KERNEL.WASM128_GENERIC and unconditionally pointed S/D AXPY at RISC-V scalar axpy.c, so the x86_64 V_SIMD sources listed in the target file never ran. Add kernel/wasm/axpy.c for both precisions. Unit-stride y += da * x uses eight independent v128 lanes (32 floats / 16 doubles) with IEEE mul+add; remainder is one vector then scalar. Skip relaxed madd: AXPY is checked to machine epsilon, and putting it in the generic V_SIMD path previously slowed Level 1. Non-unit stride stays scalar (no WASM gather); inc==0 uses that path so y[0] += n * da * x[0]. Guard SAXPYKERNEL/DAXPYKERNEL with ifndef in KERNEL so the target file wins. CAXPY/ZAXPY stay RISC-V scalar. On n=512..8192 vs the RISC-V champion, SAXPY is about 1.4–3.0x and DAXPY about 1.4–2.2x. test.sh is green. Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
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
Follow-up to #5983 / #5680 / #4023: replace the RISC-V scalar SAXPY/DAXPY kernels used by
WASM128_GENERICwith a WASM SIMD128 unit-stride kernel.kernel/wasm/KERNELis included afterKERNEL.WASM128_GENERICand previously overwrote S/D AXPY withkernel/riscv64/axpy.c, so thex86_64V_SIMD sources listed in the target file never ran.kernel/wasm/axpy.c. Unit-stridey += da * xis eight independentv128lanes (32 floats / 16 doubles) with IEEE mul+add; remainder is one vector then scalar.V_SIMDpath previously slowed Level 1. Non-unit stride stays scalar (no WASM gather);inc == 0uses that path soy[0] += n * da * x[0].SAXPYKERNEL/DAXPYKERNELinKERNELare wrapped inifndefso the target file wins (same include-order fix as TRMM in Add a 4x4 WASM SIMD128 GEMM microkernel #5983). CAXPY/ZAXPY stay RISC-V scalar.Benchmarks
Node / Emscripten,
TARGET=WASM128_GENERIC,USE_THREAD=0,COMMON_OPT=-O2. Same machine, 5 warmup + 10 timed samples (median). Speedup > 1 means this branch is faster thandevelop.Geomean vs
develop: SAXPY 1.63x, DAXPY 1.53x.Test plan
utestunder node (includingsaxpy/daxpyinc==0; 106/106)ctestL1 (x{s,d,c,z}cblat1) under node, including SAXPY/DAXPY