Skip to content

wasm: add Node/Emscripten numerical CBLAS test suite - #6024

Open
jjerphan wants to merge 9 commits into
OpenMathLib:developfrom
jjerphan:wasm-numerical-suite
Open

wasm: add Node/Emscripten numerical CBLAS test suite#6024
jjerphan wants to merge 9 commits into
OpenMathLib:developfrom
jjerphan:wasm-numerical-suite

Conversation

@jjerphan

@jjerphan jjerphan commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Add test/wasm/, a deeper CBLAS correctness suite for TARGET=WASM128_GENERIC under Node / Emscripten. It complements the light ctest / utest gate and is meant to catch tile-remainder and stride bugs in the WASM SIMD kernels.

  • Compare public CBLAS results to a hand-written scalar C oracle (ref_l1.c / ref_l2.c / ref_l3.c: IEEE * / + only — not Netlib BLAS and not a second OpenBLAS build).
  • Cover the full standard BLAS Level 1/2/3 surface (dense, banded, and packed; S/D/C/Z where applicable), with deep AXPY/GEMV/GEMM grids that stress 4×4 / 8×4 / 2×2 remainders (cases.h).
  • Fill dense vectors and matrices with fill_vec_* / fill_mat_* (common.h). Drivers cycle six FillSpec cases across the size grid so remainders see different sign domains and magnitude spreads, without a 6× runtime:
    • R⁺ / R⁻ / R \ {0} (strictly positive, strictly negative, mixed signs; never exactly 0)
    • near 0 (log-uniform f32 [1e-4, 1], f64 [1e-8, 1]) and far from 0 (f32 [1e2, 1e4], f64 [1e4, 1e8])
    • Near-0 floors stay large enough that tol * (1 + maxv) still flags a wrong kernel; far-from-0 caps stay small enough that L3 GEMM at n≈129 does not overflow f32.
    • Triangular (make_tri_*) and band fixtures stay O(1) and diagonally dominant. Failure lines include the active spec (e.g. R+ far from 0).
  • test/wasm/run.sh builds with WASM_RELAXED_SIMD=0 and/or 1 and runs with matching tolerances (tol.h / TEST_WASM_RELAXED).
  • Ignore Emscripten .wasm sidecars from Node builds in .gitignore.
  • CI: .github/workflows/wasm.yml runs IEEE and relaxed matrix jobs on ubuntu-latest (Emscripten 4.0.10 + Node 22) when test/wasm/ or kernel/wasm/ changes.

Test plan

With emcc on PATH (or an emscripten-forge prefix via OPENBLAS_EM_PREFIX):

JOBS=20 ./test/wasm/run.sh
  • Suite passes for WASM_RELAXED_SIMD=0 (IEEE tolerances)
  • Suite passes for WASM_RELAXED_SIMD=1 (relaxed tolerances)
  • GitHub Actions job wasm numerical suite is green on this PR (WASM_RELAXED_SIMD=0 and =1)
  • Reviewers: run the same on their host if convenient

Shared headers for tolerances, size grids, and compare helpers, plus
README and gitignore for the Node/Emscripten deep CBLAS checks.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Hand-written IEEE mul/add implementations used as the correctness
baseline (not Netlib BLAS or a second OpenBLAS build).

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Cover AXPY, GEMV, GEMM/CGEMM/ZGEMM, SYRK, TRMM, and TRSM with tile
remainder sizes, rectangular cases, and stride variants.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Build TARGET=WASM128_GENERIC twice (WASM_RELAXED_SIMD=0/1), link
test/wasm, and run under node with matching tolerances.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Keep ctest/getarch/utest sidecars from Node builds out of version control,
alongside the existing *.exe rule.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Add a workflow that installs Emscripten and Node, then runs
test/wasm/run.sh (IEEE and relaxed SIMD builds) on PRs and pushes
that touch the WASM kernels or the suite.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
Expose WASM_RELAXED_SIMD=0 and =1 as separate GitHub Actions jobs so
both builds are visible checks. run.sh still runs both locally when the
variable is unset.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
@jjerphan

Copy link
Copy Markdown
Contributor Author

A priori the few failures (due to timeouts) are unrelated to those changes.

@jjerphan
jjerphan force-pushed the wasm-numerical-suite branch 4 times, most recently from 768b690 to 2e2134a Compare September 10, 2026 09:06
Add scalar-oracle checks for the full Level 1/2/3 surface (dense, banded,
and packed), including S/D/C/Z where applicable. Keep the deep AXPY/GEMV/
GEMM grids and exercise the remaining families on a compact size set.

Merge the former check_*_full sources into per-level check_l*.c files with
one test function per CBLAS interface and shared expect_close_* helpers.
House oracles in ref_l1.c / ref_l2.c / ref_l3.c (typed deep-grid AXPY/GEMV,
polymorphic L1/L2 helpers, and UPLO-aware L3 including SYMM/HEMM/HERK/
SYR2K/HER2K); triangular fixtures live in common.h.

Document L1/L2/L3 and IEEE vs relaxed tolerance choices in tol.h. Discover
emcc via PATH, OPENBLAS_EM_PREFIX, or \$ROOT/.em-prefix only.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
The previous fillers mapped (i, seed) into about [-0.5, 0.45], so the
suite never stressed values close to 0, large magnitudes, or a single
sign. Replace them with fill_vec_* / fill_mat_* (real and complex)
driven by a FillSpec: strictly positive (R+), strictly negative (R-),
or mixed (R \ {0}), each at a near-0 or far-from-0 log-uniform spread.

Drivers cycle the six cases across the size grid via use_fill_case so
tile remainders see different regimes without a 6x runtime. Near-0
floors stay large enough that tol*(1+maxv) still flags a wrong kernel;
far-from-0 caps stay small enough that L3 GEMM at n~129 does not
overflow f32. Existing fill_f32/f64/c32/c64 wrap the vector fillers.
Triangular and band fixtures stay O(1) and diagonally dominant.
Failure lines include the active spec.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
@jjerphan
jjerphan marked this pull request as ready for review September 10, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant