Commit 8f414ef
committed
feat(bb): WebGPU field-mul micro-benchmark + Karatsuba/sos3uv3 Mont mults
Adds a standalone WebGPU micro-benchmark page comparing three BN254
Montgomery product implementations for chained-mul throughput:
- cios (u32): mitschabaude runtime-loop CIOS over 20×13-bit limbs.
Baseline, ~109 ms at n=2^20, k=100.
- karat (u32): recursive Karatsuba + Yuval reduction. 9 5×5 schoolbook
sub-sub-products are computed independently and combined via two
Karatsuba levels; reduction uses precomputed r_inv = W^-1 mod p with
zero drains in the multiply phase (unsigned wrap unwinds via
subsequent subtraction). ~80 ms (~28% faster than cios).
- sos3uv3 (f32, reference): 22-bit f32 limbs with separate per-slot
tlo/thi accumulators that break the inner-j carry chain. Single
drain per outer iter via bias_split_f32_le4w. ~79 ms.
The bench harness:
- bench-field-mul.html is a standalone page; reads ?path=u32|f32
&n=N&k=K&validate-n=N&reps=R&variant=V from the URL.
- bench-field-mul.ts runs k chained Mont mults per thread, validates
the first `validate-n` outputs against a host BigInt reference, and
writes timing into window.__bench.
- scripts/bench-field-mul.mjs is a Playwright driver for headless
invocation from the CLI (added playwright-core as devDependency).1 parent 80124f6 commit 8f414ef
15 files changed
Lines changed: 2720 additions & 1 deletion
File tree
- barretenberg/ts
- dev/msm-webgpu
- scripts
- src/msm_webgpu
- cuzk
- wgsl
- _generated
- bigint
- cuzk
- montgomery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments