Add opt-in BMI2/ADX Montgomery multiplication for the Pasta fields on x86_64 - #285
Open
lamb356 wants to merge 2 commits into
Open
Add opt-in BMI2/ADX Montgomery multiplication for the Pasta fields on x86_64#285lamb356 wants to merge 2 commits into
lamb356 wants to merge 2 commits into
Conversation
Contributor
|
Will test this same time were testing all the other x86 work in repo! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration
Bot
force-pushed
the
devin/split-1-x86-asm
branch
from
September 2, 2026 00:18
69b668b to
5418a35
Compare
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.
Summary
Adds an opt-in BMI2/ADX inline-assembly Montgomery multiplication backend for the Pasta fields on x86_64, behind a new
x86_64-asmfeature (off by default). The repo already ships an aarch64 assembly path for Apple silicon; this is the x86_64 counterpart.crates/pasta_curves/src/fields/x86_64_asm.rs: 4x4-limb Montgomery multiply/square usingmulx/adcx/adoxcarry chains, wrapped in narrowunsafefunctions.Fp/Fqdispatch to the asm path for mul, square, and repeated square-and-multiply whenfeature = "x86_64-asm"andtarget_arch = "x86_64"; the portable Rust path is unchanged and remains the default everywhere else.Measured on the Orchard k=11 prover benchmark (8 threads): roughly 10ms off the end-to-end proving time on its own. All numbers in this PR series were measured on an 8-thread VM — if you have a 16-core machine handy we'd appreciate your numbers, since the dominant stages scale with cores. Reproduce with:
RAYON_NUM_THREADS=16 ORCHARD_K11_PROVER_THREADS=16 cargo bench -p zakura-orchard --features circuit,orbits --bench orchard_k11_proverPart of the split of #273 (piece 1 of 6, as proposed there).
Testing
cargo test --release --features x86_64-asmincrates/pasta_curves(91 + 1 tests pass, exercising both fields against the portable implementation).cargo check --locked --all-features --all-targetsand MSRV (1.91) check clean.cargo fmt --all -- --checkclean.