concept-collection / matmul-bench
matmul-bench / README.md
2.5 KBPreviewCodeBlameHistoryRaw

matmul-bench#

Compares matrix-matrix multiply (GEMM) performance across implementations running in the browser, plus a native reference measured outside it.

Live: https://concept-collection.github.io/matmul-bench/

Methods:

Develop#

npm install
npm run dev            # local dev server (sends COOP/COEP for threaded methods)
wasm/build-wasm.sh      # rebuild wasm/dist/matmul.* + public/matmul/matmul_mt.*
                        #   (needs emsdk)

# One-time: build the WASM libflame/BLIS libraries in a sibling checkout
git clone https://github.com/concept-collection/libflame2wasm ../libflame2wasm
(cd ../libflame2wasm && ./build-all-wasm.sh)        # slow; builds libflame twice

blis/build-blis-wasm.sh # rebuild public/matmul/matmul_blis_{st,mt}.*
                        #   (needs emsdk + the sibling libflame2wasm above;
                        #    override its path with LIBFLAME=/path/to/libflame2wasm)
npm run build           # tsc -b && vite build

Nothing prebuilt is committed. The WASM modules under public/matmul/ (except worker.js) are built by CI: the custom kernels from wasm/matmul.c, and the libFLAME/BLIS modules by cloning libflame2wasm as a sibling, running its build-all-wasm.sh (cached, keyed on its commit SHA), and linking against the resulting .a libraries.

Native reference#

native/build.sh
OPENBLAS_NUM_THREADS=1  native/bench_native 128 256 512 1024 2048
OPENBLAS_NUM_THREADS=12 native/bench_native 128 256 512 1024 2048

Hand-copy the results into src/data/nativeReference.ts.