Skip to content

Commit

Permalink
add LDE benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dloghin committed Oct 2, 2024
1 parent 067d4a3 commit 56c42f6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plonky2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ harness = false
name = "ffts"
harness = false

[[bench]]
name = "lde"
harness = false

[[bench]]
name = "hashing"
harness = false
Expand Down
46 changes: 46 additions & 0 deletions plonky2/benches/lde.rs
Original file line number Diff line number Diff line change
@@ -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<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>(c: &mut Criterion)
{
const RATE_BITS: usize = 3;

let mut group = c.benchmark_group(&format!("lde<{}>", type_name::<F>()));

#[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<PolynomialCoeffs<F>> = (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::<F, C, D>::from_coeffs(polynomials.clone(), RATE_BITS, false, 1, &mut timing, None)
});
});
}
}

fn criterion_benchmark(c: &mut Criterion) {
bench_batch_lde::<GoldilocksField, PoseidonGoldilocksConfig, 2>(c);
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

0 comments on commit 56c42f6

Please sign in to comment.