Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the panic subgroup_fft_in_place benchmark for MNT6-753's Fr #284

Merged
merged 6 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

### Bug fixes
- [\#252](https://github.com/arkworks-rs/algebra/pull/252) (ark-ff) Fix prime field sampling when `REPR_SHIFT_BITS` is 64.
- [\#284](https://github.com/arkworks-rs/algebra/pull/284) (ark-poly-benches) Fix the panic `subgroup_fft_in_place` benchmark for MNT6-753's Fr.


## v0.2.0
Expand Down
50 changes: 38 additions & 12 deletions poly-benches/benches/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ use criterion::{criterion_group, criterion_main, Bencher, Criterion};
// degree bounds to benchmark on
// e.g. degree bound of 2^{15}, means we do an FFT for a degree (2^{15} - 1) polynomial
const BENCHMARK_MIN_DEGREE: usize = 1 << 15;
const BENCHMARK_MAX_DEGREE: usize = 1 << 22;
const BENCHMARK_MAX_DEGREE_BLS12_381: usize = 1 << 22;
const BENCHMARK_MAX_DEGREE_MNT6_753: usize = 1 << 17;
const BENCHMARK_LOG_INTERVAL_DEGREE: usize = 1;

const ENABLE_RADIX2_BENCHES: bool = true;
Expand All @@ -22,17 +23,30 @@ const ENABLE_MIXED_RADIX_BENCHES: bool = true;
// interval = BENCHMARK_LOG_INTERVAL_DEGREE
// min = ceil(log_2(BENCHMARK_MIN_DEGREE))
// max = ceil(log_2(BENCHMARK_MAX_DEGREE))
fn default_size_range() -> Vec<usize> {
fn default_size_range_bls12_381() -> Vec<usize> {
size_range(
BENCHMARK_LOG_INTERVAL_DEGREE,
BENCHMARK_MIN_DEGREE,
BENCHMARK_MAX_DEGREE,
BENCHMARK_MAX_DEGREE_BLS12_381,
)
}

fn setup_bench(c: &mut Criterion, name: &str, bench_fn: fn(&mut Bencher, &usize)) {
fn default_size_range_mnt6_753() -> Vec<usize> {
size_range(
BENCHMARK_LOG_INTERVAL_DEGREE,
BENCHMARK_MIN_DEGREE,
BENCHMARK_MAX_DEGREE_MNT6_753,
)
}

fn setup_bench(
c: &mut Criterion,
name: &str,
bench_fn: fn(&mut Bencher, &usize),
size_range: &[usize],
) {
let mut group = c.benchmark_group(name);
for degree in default_size_range().iter() {
for degree in size_range.iter() {
group.bench_with_input(BenchmarkId::from_parameter(degree), degree, bench_fn);
}
group.finish();
Expand Down Expand Up @@ -83,28 +97,40 @@ fn bench_coset_ifft_in_place<F: FftField, D: EvaluationDomain<F>>(b: &mut Benche
});
}

fn fft_benches<F: FftField, D: EvaluationDomain<F>>(c: &mut Criterion, name: &'static str) {
fn fft_benches<F: FftField, D: EvaluationDomain<F>>(
c: &mut Criterion,
name: &'static str,
size_range: &[usize],
) {
let cur_name = format!("{:?} - subgroup_fft_in_place", name.clone());
setup_bench(c, &cur_name, bench_fft_in_place::<F, D>);
setup_bench(c, &cur_name, bench_fft_in_place::<F, D>, size_range);
let cur_name = format!("{:?} - subgroup_ifft_in_place", name.clone());
setup_bench(c, &cur_name, bench_ifft_in_place::<F, D>);
setup_bench(c, &cur_name, bench_ifft_in_place::<F, D>, size_range);
let cur_name = format!("{:?} - coset_fft_in_place", name.clone());
setup_bench(c, &cur_name, bench_coset_fft_in_place::<F, D>);
setup_bench(c, &cur_name, bench_coset_fft_in_place::<F, D>, size_range);
let cur_name = format!("{:?} - coset_ifft_in_place", name.clone());
setup_bench(c, &cur_name, bench_coset_ifft_in_place::<F, D>);
setup_bench(c, &cur_name, bench_coset_ifft_in_place::<F, D>, size_range);
}

fn bench_bls12_381(c: &mut Criterion) {
let name = "bls12_381 - radix2";
if ENABLE_RADIX2_BENCHES {
fft_benches::<bls12_381_fr, Radix2EvaluationDomain<bls12_381_fr>>(c, name);
fft_benches::<bls12_381_fr, Radix2EvaluationDomain<bls12_381_fr>>(
c,
name,
&default_size_range_bls12_381(),
);
}
}

fn bench_mnt6_753(c: &mut Criterion) {
let name = "mnt6_753 - mixed radix";
if ENABLE_MIXED_RADIX_BENCHES {
fft_benches::<mnt6_753_fr, MixedRadixEvaluationDomain<mnt6_753_fr>>(c, name);
fft_benches::<mnt6_753_fr, MixedRadixEvaluationDomain<mnt6_753_fr>>(
c,
name,
&default_size_range_mnt6_753(),
);
}
}

Expand Down