Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: wasm numerical suite

on:
push:
paths:
- 'test/wasm/**'
- 'kernel/wasm/**'
- 'kernel/simd/intrin_wasm.h'
- 'kernel/simd/intrin.h'
- 'Makefile.wasm'
- '.github/workflows/wasm.yml'
pull_request:
paths:
- 'test/wasm/**'
- 'kernel/wasm/**'
- 'kernel/simd/intrin_wasm.h'
- 'kernel/simd/intrin.h'
- 'Makefile.wasm'
- '.github/workflows/wasm.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
numerical:
if: github.repository == 'OpenMathLib/OpenBLAS' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
# Explicit IEEE vs relaxed-SIMD OpenBLAS builds (and matching suite tolerances).
wasm_relaxed_simd: ['0', '1']

name: numerical (WASM_RELAXED_SIMD=${{ matrix.wasm_relaxed_simd }})

steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Setup Emscripten
uses: emscripten-core/setup-emsdk@v16
with:
version: 4.0.10
actions-cache-folder: emsdk-cache

- name: Verify toolchain
run: |
emcc -v
node -v
which emmake emar emranlib

- name: Run WASM numerical CBLAS suite
env:
WASM_RELAXED_SIMD: ${{ matrix.wasm_relaxed_simd }}
run: |
echo "Running suite with WASM_RELAXED_SIMD=${WASM_RELAXED_SIMD}"
JOBS="$(nproc)" ./test/wasm/run.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.def
*.o
*.exe
*.wasm
*.out
*.tmp
lapack-3.1.1
Expand Down
4 changes: 4 additions & 0 deletions test/wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
out/
*.js
*.wasm
*.log
70 changes: 70 additions & 0 deletions test/wasm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# WASM numerical validation suite

Deep CBLAS correctness checks for `TARGET=WASM128_GENERIC`, run under Node / Emscripten.

## Oracle

Results from OpenBLAS (public CBLAS API) are compared to hand-written scalar
C references in `ref_l1.c`, `ref_l2.c`, and `ref_l3.c` (IEEE `*` / `+` only —
no SIMD or FMA intrinsics). This is not Netlib BLAS and not a second OpenBLAS
build.

Tolerances live in `tol.h`. Builds with `WASM_RELAXED_SIMD=1` use a slightly larger L2/L3 budget (`TEST_WASM_RELAXED`).

## Run

```bash
JOBS=20 ./test/wasm/run.sh
```

This:

1. Builds OpenBLAS wasm with `WASM_RELAXED_SIMD=0`, links and runs the suite (IEEE tolerances).
2. Rebuilds with `WASM_RELAXED_SIMD=1`, links and runs again (relaxed tolerances).

Requires `emcc` on `PATH`, or an emscripten-forge prefix via `OPENBLAS_EM_PREFIX` / auto-discovery used by `benchmark/wasm/build.sh`.

CI runs the same script via `.github/workflows/wasm.yml` (Emscripten + Node on `ubuntu-latest`) on changes under `test/wasm/` and `kernel/wasm/`.

## Coverage

The suite covers the complete standard CBLAS Level 1/2/3 families:

- Level 1: rotations, swap, scaling, copy, axpy, dot products, norms, absolute
sums, and maximum-index operations for all applicable S/D/C/Z types.
- Level 2 dense: general, symmetric, Hermitian, triangular, and rank-update
operations.
- Level 2 banded and packed: general, symmetric/Hermitian, triangular, solve,
and rank-update operations.
- Level 3: GEMM, SYMM/HEMM, SYRK/HERK, SYR2K/HER2K, and TRMM/TRSM.

Dense vectors and matrices are filled by `fill_vec_*` / `fill_mat_*` in
`common.h` (existing `fill_f32` / `fill_f64` / `fill_c32` / `fill_c64` wrap
those). Drivers cycle six `FillSpec` cases across the size grid so each
remainder hits a different sign domain and magnitude spread:

| Domain | Spread | f32 magnitudes | f64 magnitudes |
| --- | --- | --- | --- |
| R⁺ (strictly positive) | near 0 | log-uniform in [1e-4, 1] | [1e-8, 1] |
| R⁺ | far from 0 | [1e2, 1e4] | [1e4, 1e8] |
| R⁻ (strictly negative) | near 0 / far | same magnitudes, negated | same |
| R \ {0} (mixed signs) | near 0 / far | same magnitudes, random sign | same |

Values are never exactly 0. Near-0 lower bounds stay large enough that
`tol * (1 + maxv)` still flags a wrong kernel; far-from-0 upper bounds stay
small enough that L3 GEMM at n≈129 does not overflow f32. Failure messages
include the active spec (e.g. `R+ far from 0`).

Triangular solve / multiply fixtures (`make_tri_*`) and band builders stay
O(1) and diagonally dominant so those problems remain well-conditioned.
Symmetric and Hermitian inputs are mirrored explicitly; band and packed
layouts include their off-diagonals. Triangular solves are checked by
constructing a right-hand side with the matching scalar matrix product and
recovering the original input.

This scope is standard BLAS only. OpenBLAS extensions such as `axpby`, `gemmt`,
`imatcopy`, and bfloat16 routines are intentionally excluded.

Size grids emphasize tile remainders around 4×4 / 8×4 / 2×2 (see `cases.h`).

Netlib `ctest` / `utest` remain a separate light gate (`benchmark/wasm/test.sh`).
63 changes: 63 additions & 0 deletions test/wasm/cases.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright (c) 2026, The OpenBLAS Project
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef TEST_WASM_CASES_H
#define TEST_WASM_CASES_H

/* Dense remainders around 4x4 / 8x4 / 2x2 tiles, plus a few larger sizes. */
static const int SIZES_L1[] = {
0, 1, 2, 3, 4, 5, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65,
127, 128, 129, 255, 256, 257, 1023, 1024};
static const int NS_L1 = (int)(sizeof(SIZES_L1) / sizeof(SIZES_L1[0]));

static const int SIZES_L2[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
31, 32, 33, 34, 35, 36, 63, 64, 65, 127, 128, 129};
static const int NS_L2 = (int)(sizeof(SIZES_L2) / sizeof(SIZES_L2[0]));

static const int SIZES_L3[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
31, 32, 33, 34, 35, 36, 63, 64, 65, 127, 128, 129};
static const int NS_L3 = (int)(sizeof(SIZES_L3) / sizeof(SIZES_L3[0]));

/* Complex GEMM is heavier; keep max moderate while hitting 2x2 remainders. */
static const int SIZES_CZ[] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65};
static const int NS_CZ = (int)(sizeof(SIZES_CZ) / sizeof(SIZES_CZ[0]));

/* Full standard-BLAS coverage: broad remainder sampling without large cases. */
static const int SIZES_FULL[] = {
1, 2, 3, 4, 5, 7, 8, 9, 15, 16, 17, 31, 32};
static const int NS_FULL = (int)(sizeof(SIZES_FULL) / sizeof(SIZES_FULL[0]));

static const int INCS[] = {0, 1, 2, 3};
static const int NINCS = (int)(sizeof(INCS) / sizeof(INCS[0]));

#endif /* TEST_WASM_CASES_H */
Loading
Loading