diff --git a/plonky2/Cargo.toml b/plonky2/Cargo.toml index 94715189b3..791a64c922 100644 --- a/plonky2/Cargo.toml +++ b/plonky2/Cargo.toml @@ -80,6 +80,10 @@ harness = false name = "ffts" harness = false +[[bench]] +name = "lde" +harness = false + [[bench]] name = "hashing" harness = false diff --git a/plonky2/benches/lde.rs b/plonky2/benches/lde.rs new file mode 100644 index 0000000000..c1a702f931 --- /dev/null +++ b/plonky2/benches/lde.rs @@ -0,0 +1,46 @@ +mod allocator; + +use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; +use plonky2::field::extension::Extendable; +use plonky2::field::goldilocks_field::GoldilocksField; +use plonky2::field::polynomial::PolynomialCoeffs; +use plonky2::fri::oracle::PolynomialBatch; +use plonky2::hash::hash_types::RichField; +use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; +use plonky2::util::timing::TimingTree; +use tynm::type_name; +#[cfg(feature = "cuda")] +use cryptography_cuda::{init_cuda_degree_rs}; + +pub(crate) fn bench_batch_lde, C: GenericConfig, const D: usize>(c: &mut Criterion) +{ + const RATE_BITS: usize = 3; + + let mut group = c.benchmark_group(&format!("lde<{}>", type_name::())); + + #[cfg(feature = "cuda")] + init_cuda_degree_rs(16); + + for size_log in [13, 14, 15] { + let orig_size = 1 << (size_log - RATE_BITS); + let lde_size = 1 << size_log; + let batch_size = 1 << 4; + + group.bench_with_input(BenchmarkId::from_parameter(lde_size), &lde_size, |b, _| { + let polynomials: Vec> = (0..batch_size).into_iter().map(|_i| { + PolynomialCoeffs::new(F::rand_vec(orig_size)) + }).collect(); + let mut timing = TimingTree::new("lde", log::Level::Error); + b.iter(|| { + PolynomialBatch::::from_coeffs(polynomials.clone(), RATE_BITS, false, 1, &mut timing, None) + }); + }); + } +} + +fn criterion_benchmark(c: &mut Criterion) { + bench_batch_lde::(c); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches);