Repository navigation
Accelerate BN254 Fp12 half-GCD with shared transforms and fused matrix products - #177
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Half-GCD currently pays FFT and CRT overhead for scalar/linear polynomial products and repeatedly transforms operands during matrix updates. This PR reduces that overhead in the BN254 small-prime FFT backend.
• Route scalar and linear operands through existing schoolbook arithmetic.
• Share input conversions and forward transforms across matrix–matrix and matrix–pair products.
• Accumulate each sum of two products before inverse transforms and CRT reconstruction.
• Preserve exact coefficient bounds, output aliasing, and ordinary multiplication fallbacks. Shared input spectra have a configurable 256 MiB budget; exceeding it declines fusion without changing outputs.
Single-core x86 benchmarks show 1.80–1.86× faster execution than the existing half-GCD implementation across degrees 512–8192, using identical cutoffs and three timed trials after one warmup.
Validation on saved degree-14,938 operands also measures the cumulative improvement over classical GCD:
Operation: Original classical GCD, Optimized half-GCD, Speedup
Square-free check: gcd(H, H′): 340.63 s , 18.15 s, 18.76×
Frobenius screening GCD: 344.20 s , 18.20 s, 18.91×
These cumulative gains include enabling half-GCD. Measurements used AMD EPYC 9454, GCC 15.2, identical compiler flags, and one pinned CPU. Each saved-input configuration had one timed trial without warmup. Process peak RSS increased from approximately 77 MiB to 284 MiB.
Half-GCD remains opt-in. The measured configuration uses gcd_half_gcd_cutoff = 128 and half_gcd_basecase_cutoff = 60, selected by the caller. These measurements validate GCD performance on the tested operands; full AADP workflow performance remains unmeasured.