forked from 0xPolygonZero/plonky2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
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); |