Skip to content

optimize coefficent combinations - #176

Merged
odraccir1 merged 1 commit into
masterfrom
ra/coefficient_combination
Oct 17, 2026
Merged

odraccir1 merged 1 commit into
masterfrom
ra/coefficient_combination

Conversation

@odraccir1

@odraccir1 odraccir1 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Modular composition repeatedly multiplies outer coefficients by cached baby-step coefficients. This PR adds an opt-in prepared kernel that reuses operand preparation and accumulates base-field dot products before reconstructing each Fp12 result.

The full-size BN254 benchmark reduces coefficient-combination time from 330.15 s to 29.77 s, an 11.09× speedup on one x86 core.

The implementation:

• Represents Fp12 multiplication through 54 reusable base-field operand forms, with recombination performed after accumulation.
• Caches prepared baby-step coefficients and prepares each selected outer coefficient once per block evaluation.
• Processes up to four adjacent blocks together while preserving the original descending Horner order.
• Adds portable and BMI2/ADX scalar arithmetic, plus four- and eight-lane AVX-512 IFMA kernels with bounded accumulation and canonical Montgomery results.
• Retains scalar evaluation for blocks with fewer than eight nonzero nonconstant terms, unsupported fields, or insufficient preparation budget.
• Keeps prepared storage owned by the cache and scratch storage local to each composition call.

Preparation is controlled by modular_composition_prepared_byte_limit, which defaults to zero. The limit covers additional prepared coefficient storage. modular_composition_simd_lanes selects scalar prepared arithmetic (0) or four/eight SIMD lanes where supported; its default is eight. CMake checks host and compiler support before enabling IFMA.

The benchmark used an AMD EPYC 9454, GCC 15.2, degree 14,938, 122 blocks of 123 terms, one warmup and three measured trials. Headline timings come from builds without instrumentation.

Measurement, Original scalar, Prepared IFMA8
Median coefficient-combination time, 330.15 s, 29.77 s
One-time composition-cache construction, 99.34 s, 112.25 s
Peak process memory, 1.28 GiB, 4.96 GiB

@odraccir1
odraccir1 merged commit 7453457 into master Oct 17, 2026
2 checks passed
@odraccir1
odraccir1 requested a review from spaceships October 17, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant