Skip to content

Add a WASM SIMD128 2x2 CGEMM microkernel - #5985

Open
jjerphan wants to merge 1 commit into
OpenMathLib:developfrom
jjerphan:wasm128-cgemm
Open

Add a WASM SIMD128 2x2 CGEMM microkernel#5985
jjerphan wants to merge 1 commit into
OpenMathLib:developfrom
jjerphan:wasm128-cgemm

Conversation

@jjerphan

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #5983 / #5680 / #4023: replace the scalar packed 2×2 CGEMM/ZGEMM kernel used by WASM128_GENERIC with a WASM SIMD128 microkernel.

  • CGEMMKERNEL / ZGEMMKERNEL now use kernel/wasm/zgemmkernel_2x2_wasm128.c. The main 2×2 tile is f32x4 / f64x2 complex mul for all four conjugate patterns; remainders stay scalar. Packing stays zgemm_{n,t}copy_2.
  • kernel/wasm/KERNEL wraps CGEMMKERNEL / ZGEMMKERNEL (and their copy objects) in ifndef so KERNEL.WASM128_GENERIC is not overwritten — the same include-order fix as TRMM/GEMM in Add a 4x4 WASM SIMD128 GEMM microkernel #5983.
  • Relaxed madd is used in the complex GEMM inner loop only (same as real GEMM in Add a 4x4 WASM SIMD128 GEMM microkernel #5983). CHEMM/ZHEMM pick this up through the GEMM kernel.

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 than develop.

Geomean vs develop: CGEMM 1.51x, ZGEMM 1.53x, CHEMM 1.52x, ZHEMM 1.52x. SGEMM/DGEMM unchanged within noise.

op n develop MFLOPS SIMD MFLOPS speedup
cgemm 32 12559.5 20998.4 1.672
cgemm 64 12326.2 19923.6 1.616
cgemm 128 12482.5 19674.4 1.576
cgemm 256 13527.8 18571.3 1.373
cgemm 512 13688.7 18270.4 1.335
zgemm 32 9509.2 14651.0 1.541
zgemm 64 9696.1 14446.3 1.490
zgemm 128 9322.0 14696.6 1.577
zgemm 256 9386.7 14568.9 1.552
zgemm 512 9757.1 14458.4 1.482
chemm 32 12686.5 19882.1 1.567
chemm 64 12339.9 19008.8 1.540
chemm 128 12128.2 19439.0 1.603
chemm 256 12655.2 18789.4 1.485
chemm 512 12852.4 18081.3 1.407
zhemm 32 9613.3 14245.4 1.482
zhemm 64 9630.4 14118.1 1.466
zhemm 128 9251.8 14245.9 1.540
zhemm 256 9333.3 14723.7 1.578
zhemm 512 9443.9 14417.8 1.527

Test plan

  • Node CBLAS odd-size GEMM/TRSM/TRMM check
  • utest under node (106/106)
  • CBLAS ctest L1/L2/L3 (x{s,d,c,z}cblat{1,2,3}) under node, including CGEMM/ZGEMM and CHEMM/ZHEMM

@jjerphan jjerphan changed the title Add a WASM SIMD128 2x2 complex GEMM microkernel Add a WASM SIMD128 2x2 CGEMM microkernel Aug 20, 2026
Vectorize the packed 2x2 CGEMM/ZGEMM inner loop with f32x4/f64x2
complex mul. Do not let kernel/wasm/KERNEL override the target
kernel the way 4x4 real GEMM already guards TRMM.

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
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