Skip to content

Commit

Permalink
feat: integration with mopro-msm gpu acceleration
Browse files Browse the repository at this point in the history
  • Loading branch information
ElusAegis committed Jan 8, 2025
1 parent 8b13a0d commit e88c505
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion halo2_proofs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ serde_derive = { version = "1", optional = true}
bincode = { version = "1.3.3", default_features = false }
serde = { version = "1.0.126", features = ["derive"] }
instant = { version = "0.1" }

mopro-msm = { git = "https://github.com/ElusAegis/metal-msm-gpu-acceleration.git", rev = "962e4d", optional = true, features = ["h2c"], default-features = false }

# Developer tooling dependencies
plotters = { version = "0.3.0", default-features = false, optional = true }
Expand Down Expand Up @@ -107,6 +107,8 @@ batch = ["rand_core/getrandom"]
circuit-params = []
counter = []
icicle_gpu = ["icicle", "rustacuda"]
macos = ["mopro-msm/macos"]
ios = ["mopro-msm/ios"]
mv-lookup = []
cost-estimator = ["serde_derive"]
derive_serde = ["halo2curves/derive_serde"]
Expand Down
19 changes: 19 additions & 0 deletions halo2_proofs/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ where
///
/// This will use multithreading if beneficial.
pub fn best_multiexp_cpu<C: CurveAffine>(coeffs: &[C::Scalar], bases: &[C]) -> C::Curve {
#[cfg(feature = "metal")]

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with basic features

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with basic features

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with all features

unexpected `cfg` condition value: `metal`

Check warning on line 41 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with all features

unexpected `cfg` condition value: `metal`
if coeffs.len() >= 2_usize.pow(17) {
static PRINT_ONCE: Once = Once::new();

PRINT_ONCE.call_once(|| {
log::warn!(
"WARNING: Using Experimental Metal Acceleration for MSM. \
Best performance improvements are observed with log row size >= 20. \
Current log size: {}",
coeffs.len().ilog2()
);
});

use mopro_msm::metal::abstraction::limbs_conversion::h2c::{H2GAffine, H2G, H2Fr};
mopro_msm::metal::msm_best::<C, H2GAffine, H2G, H2Fr>(coeffs, bases)
} else {
msm_best(coeffs, bases)
}
#[cfg(not(feature = "metal"))]

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Build target wasm32-unknown-unknown

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Intra-doc links

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Bitrot check

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with basic features

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with basic features

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on macOS-latest with all features

unexpected `cfg` condition value: `metal`

Check warning on line 59 in halo2_proofs/src/arithmetic.rs

View workflow job for this annotation

GitHub Actions / Test on ubuntu-latest with all features

unexpected `cfg` condition value: `metal`
msm_best(coeffs, bases)
}

Expand Down

0 comments on commit e88c505

Please sign in to comment.