#!/bin/bash # Build the browser benchmark modules (single-threaded and pthreads variants) # into web/dist/. Requires the libraries built by ../build-wasm.sh (+ PTHREAD=1) # and ../build-blis-wasm.sh (+ THREADING=pthreads). set -euo pipefail cd "$(dirname "$0")" ROOT=$(cd .. && pwd) if ! command -v emcc >/dev/null 2>&1; then source ~/emsdk/emsdk_env.sh fi mkdir -p dist COMMON="-O2 -sMODULARIZE -sENVIRONMENT=web,worker,node \ -sEXPORTED_FUNCTIONS=_run_bench -sEXPORTED_RUNTIME_METHODS=cwrap" # Single-threaded: BLIS(st) first so its BLAS symbols win over libflame's f2c BLAS. emcc $COMMON bench_web.c \ -sEXPORT_NAME=createBenchST \ -sALLOW_MEMORY_GROWTH \ "$ROOT/install/lib/libblis-st.a" \ "$ROOT/install/lib/libflame.a" \ -o dist/bench_st.js # Threaded: everything compiled with -pthread; fixed shared memory (growth is # costly with shared memory); worker pool must cover max threads + margin. emcc $COMMON -pthread -DBLIS_MT bench_web.c \ -sEXPORT_NAME=createBenchMT \ -sPTHREAD_POOL_SIZE=14 -sINITIAL_MEMORY=1024MB \ "$ROOT/blis/lib/generic/libblis.a" \ "$ROOT/install/lib/libflame-mt.a" \ -o dist/bench_mt.js echo "Done: web/dist/bench_st.{js,wasm} and web/dist/bench_mt.{js,wasm}"