Commit 1163a37
feat(sumcheck): [PR06] row-parallel compute_univariate via VectorField (WASM SIMD) (#186)
Introduce a row-parallel WASM-SIMD path for the sumcheck prover round. The round
is written once against an `Element` template parameter that is either scalar `FF`
(one trace row per iteration) or `VectorField<FF::Params>`, which packs 5 trace
rows per SIMD lane on WASM-SIMD builds of opted-in flavors. Scalar is the width-1
special case -- `FF`'s `from_lanes`, `horizontal_sum`, and `convert_to` are
identities -- so one code path serves both and element-type branches survive in
only a few named helpers.
Key points:
- Element-generic accumulate path. `accumulate_edge_chunks<Element>` drives the
main loop with `EDGE_STRIDE = 2 * lane_count<Element>` (1 for `FF`, 5 for
`VectorField`). `for_each_edge_group` sweeps full SIMD groups then a scalar
leftover-pair tail; `reduce_accumulator<Element>` horizontally sums lanes into
the FF round accumulator (a plain add for `FF`).
- Dispatch. `compute_univariate<Element = void>` resolves the element from an
explicit per-flavor `USE_SIMD_SUMCHECK` opt-in, gated by
`SupportsSimdSumcheck<Flavor> && simd_available_v<FF::Params> &&
!USES_ROW_MANIFEST`; `BB_FORCE_SCALAR_LANE` forces scalar (A/B benchmarks).
Ultra/Mega opt in; AVM stays scalar (it proves natively, SIMD is WASM-only).
Parity tests pass the concrete element explicitly.
- VectorField primitives. `from_lanes` / `horizontal_sum` / `gather`, and
`is_zero()` / `eq()` returning a bool with all-lanes semantics (per-lane mask
forms live at `is_zero_mask` / `eq_mask`). The bool form is what the batched
relation-skip and selector-gated subrelations require; the earlier raw-mask
signature silently disabled gated subrelations on the SIMD path.
- Edge gather / parameters. `LazyExtendedEdges` is generalized over the element
type, so columns of relations that skip a row are never gathered; its cache is
heap-backed for `VectorField` (~33 KB on Mega would overflow thin WASM worker
stacks) and stays inline for `FF`. `RelationParameters::convert_to<Element>`
broadcasts every parameter next to its declaration; `GateSeparatorPolynomial::
gather<Element>` does the stride-2 pow_beta read.
- Tuning. `ROWS_PER_CHUNK = 50` on the SIMD path (5 lane-batches per chunk, no
scalar tail).
Correctness: bit-identical to the prior scalar path for both `FF` and
`VectorField`; `RowParallelParity` tests green across Mega/MegaZK/Ultra/UltraZK.
Performance: +5.02% aggregate chonk-prove (V8 / M3 Pro, threads = 8) across the
11 pinned flows.
Co-authored-by: iakovenkos <sergey.s.yakovenko@gmail.com>1 parent aa67845 commit 1163a37
18 files changed
Lines changed: 789 additions & 60 deletions
File tree
- barretenberg/cpp/src/barretenberg
- ecc/fields
- flavor
- polynomials
- relations
- sumcheck
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
336 | 344 | | |
337 | 345 | | |
338 | 346 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| |||
Lines changed: 72 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
132 | 139 | | |
| 140 | + | |
133 | 141 | | |
134 | 142 | | |
135 | 143 | | |
| |||
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
176 | 209 | | |
177 | 210 | | |
178 | 211 | | |
| |||
193 | 226 | | |
194 | 227 | | |
195 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
196 | 239 | | |
197 | 240 | | |
198 | 241 | | |
| |||
217 | 260 | | |
218 | 261 | | |
219 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
220 | 279 | | |
221 | 280 | | |
222 | 281 | | |
| |||
312 | 371 | | |
313 | 372 | | |
314 | 373 | | |
315 | | - | |
316 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
317 | 383 | | |
318 | 384 | | |
319 | 385 | | |
| |||
1035 | 1101 | | |
1036 | 1102 | | |
1037 | 1103 | | |
1038 | | - | |
| 1104 | + | |
1039 | 1105 | | |
1040 | 1106 | | |
1041 | 1107 | | |
| |||
1119 | 1185 | | |
1120 | 1186 | | |
1121 | 1187 | | |
1122 | | - | |
| 1188 | + | |
1123 | 1189 | | |
1124 | 1190 | | |
1125 | 1191 | | |
| |||
1316 | 1382 | | |
1317 | 1383 | | |
1318 | 1384 | | |
1319 | | - | |
| 1385 | + | |
1320 | 1386 | | |
1321 | 1387 | | |
1322 | 1388 | | |
| |||
1327 | 1393 | | |
1328 | 1394 | | |
1329 | 1395 | | |
1330 | | - | |
| 1396 | + | |
1331 | 1397 | | |
1332 | 1398 | | |
1333 | 1399 | | |
| |||
Lines changed: 80 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
620 | 620 | | |
621 | 621 | | |
622 | 622 | | |
623 | | - | |
| 623 | + | |
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
628 | | - | |
| 628 | + | |
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
680 | 750 | | |
681 | 751 | | |
682 | 752 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
71 | 81 | | |
72 | 82 | | |
73 | 83 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
0 commit comments