From 741dc4c94c82a8ecd7753bc7ff4d285182eb585b Mon Sep 17 00:00:00 2001 From: Daniel Lubarov Date: Sat, 22 May 2021 09:38:07 -0700 Subject: [PATCH] Tweaks to bench_ldes --- src/bin/bench_ldes.rs | 27 +++++++++++++++------------ src/gates/gmimc.rs | 2 +- src/gates/interpolation.rs | 4 +--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/bin/bench_ldes.rs b/src/bin/bench_ldes.rs index 5620bd80..b267466c 100644 --- a/src/bin/bench_ldes.rs +++ b/src/bin/bench_ldes.rs @@ -8,25 +8,28 @@ use plonky2::polynomial::polynomial::PolynomialValues; type F = CrandallField; -// 113 wire polys, 3 Z polys, 4 parts of quotient poly. -const PROVER_POLYS: usize = 113 + 3 + 4; +// This is an estimate of how many LDEs the prover will compute. The biggest component, 86, comes +// from wire polynomials which "store" the outputs of S-boxes in our Poseidon gate. +const NUM_LDES: usize = 8 + 8 + 3 + 86 + 3 + 8; + +const DEGREE: usize = 1 << 14; + +const RATE_BITS: usize = 3; fn main() { - const DEGREE: usize = 1 << 13; - const RATE_BITS: usize = 3; + // We start with random polynomials. + let all_poly_values = (0..NUM_LDES) + .map(|_| PolynomialValues::new(F::rand_vec(DEGREE))) + .collect::>(); let start = Instant::now(); - (0usize..PROVER_POLYS).into_par_iter().for_each(|i| { - let mut values = vec![F::ZERO; DEGREE]; - for j in 0usize..DEGREE { - values[j] = F::from_canonical_u64((i * j) as u64); - } - let poly_values = PolynomialValues::new(values); + + all_poly_values.into_par_iter().for_each(|poly_values| { let start = Instant::now(); - let result = poly_values.lde(RATE_BITS); + let lde = poly_values.lde(RATE_BITS); let duration = start.elapsed(); println!("LDE took {:?}", duration); - println!("LDE result: {:?}", result.values[0]); + println!("LDE result: {:?}", lde.values[0]); }); println!("FFT overall took {:?}", start.elapsed()); } diff --git a/src/gates/gmimc.rs b/src/gates/gmimc.rs index da8ce670..3097ccfb 100644 --- a/src/gates/gmimc.rs +++ b/src/gates/gmimc.rs @@ -349,12 +349,12 @@ mod tests { use crate::circuit_data::CircuitConfig; use crate::field::crandall_field::CrandallField; use crate::field::field::Field; + use crate::gates::gate_testing::test_low_degree; use crate::gates::gmimc::{GMiMCGate, W}; use crate::generator::generate_partial_witness; use crate::gmimc::gmimc_permute_naive; use crate::wire::Wire; use crate::witness::PartialWitness; - use crate::gates::gate_testing::test_low_degree; #[test] fn generated_output() { diff --git a/src/gates/interpolation.rs b/src/gates/interpolation.rs index 732f28ba..adc7055d 100644 --- a/src/gates/interpolation.rs +++ b/src/gates/interpolation.rs @@ -168,9 +168,7 @@ struct InterpolationGenerator, const D: usize> { _phantom: PhantomData, } -impl, const D: usize> SimpleGenerator - for InterpolationGenerator -{ +impl, const D: usize> SimpleGenerator for InterpolationGenerator { fn dependencies(&self) -> Vec { let local_target = |input| { Target::Wire(Wire {