666db68matmul-bench: browser GEMM benchmark (JS, WebGPU, custom C WASM, libFLAME/BLIS WASM)Jeremy Magland 1export type Precision = 'f32' | 'f64'
3export interface MatmulResult {
4 ms: number
5 /** C[0], for a cheap cross-method sanity check. */
6 sample: number
7}
9export interface MatmulMethod {
10 id: string
11 label: string
12 precision: Precision
13 /** Short note shown next to the method (e.g. a precision caveat). */
14 note?: string
15 /** Runs synchronously long enough (n=2048 naive JS: ~10s+) to freeze the
16 * tab, so BenchmarkRunner dispatches it to a Web Worker instead of
17 * calling run() on the main thread. */
18 worker?: boolean
19 /** Methods backed by a pthread-capable WASM module run in a dedicated
20 * classic worker (threadedClient), keyed by this registry kind
21 * ('matmul-mt' | 'blis-st' | 'blis-mt'); BenchmarkRunner dispatches these
22 * specially and their run() is unused. Threaded kinds also require
23 * crossOriginIsolated. */
24 threadedKind?: 'matmul-mt' | 'blis-st' | 'blis-mt'
25 available(): boolean
26 run?(n: number, a: Float64Array, b: Float64Array): Promise<MatmulResult>
27}
29export function gflops(n: number, ms: number): number {
30 return (2 * n * n * n) / (ms / 1000) / 1e9
31}