Skip to content

Commit 8f414ef

Browse files
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
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>BN254 field-mul micro-benchmark</title>
6+
<style>
7+
body {
8+
font-family: ui-sans-serif, system-ui, sans-serif;
9+
max-width: 1100px;
10+
margin: 1.5rem auto;
11+
padding: 0 1rem;
12+
line-height: 1.45;
13+
}
14+
h1 { font-size: 1.25rem; }
15+
#log {
16+
background: #0b1020;
17+
color: #e6e6e6;
18+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
19+
font-size: 12px;
20+
padding: 0.75rem;
21+
border-radius: 6px;
22+
white-space: pre-wrap;
23+
overflow-x: auto;
24+
min-height: 8rem;
25+
}
26+
.ok { color: #6ee7b7; }
27+
.err { color: #fca5a5; }
28+
.warn { color: #fde68a; }
29+
</style>
30+
</head>
31+
<body>
32+
<h1>BN254 field-mul micro-benchmark</h1>
33+
<p>Query params: <code>?path=u32|f32&amp;n=N&amp;k=K&amp;validate-n=N&amp;reps=R</code></p>
34+
<div id="log"></div>
35+
<script type="module" src="./bench-field-mul.ts"></script>
36+
</body>
37+
</html>

0 commit comments

Comments
 (0)