Skip to content

Commit

Permalink
Expand range of benchmarks and better parallelization handling for sm…
Browse files Browse the repository at this point in the history
…all FFTs
  • Loading branch information
Pratyush committed Aug 13, 2024
1 parent fdf9f1a commit 9a9b132
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion poly/benches/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use criterion::{criterion_group, criterion_main, Bencher, BenchmarkId, 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_MIN_DEGREE: usize = 1 << 4;
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;
Expand Down
14 changes: 9 additions & 5 deletions poly/src/domain/radix2/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ impl<F: FftField> Radix2EvaluationDomain<F> {
max_threads: usize,
gap: usize,
) {
if xi.len() <= 16 {
if xi.len() <= MIN_INPUT_SIZE_FOR_PARALLELIZATION {
xi.chunks_mut(chunk_size).for_each(|cxi| {
let (lo, hi) = cxi.split_at_mut(gap);
// If the chunk is sufficiently big that parallelism helps,
// we parallelize the butterfly operation within the chunk.
lo.iter_mut()
.zip(hi)
.zip(roots.iter().step_by(step))
Expand All @@ -240,7 +238,7 @@ impl<F: FftField> Radix2EvaluationDomain<F> {
// If the chunk is sufficiently big that parallelism helps,
// we parallelize the butterfly operation within the chunk.

if gap > MIN_GAP_SIZE_FOR_PARALLELISATION && num_chunks < max_threads {
if gap > MIN_GAP_SIZE_FOR_PARALLELIZATION && num_chunks < max_threads {
cfg_iter_mut!(lo)
.zip(hi)
.zip(cfg_iter!(roots).step_by(step))
Expand Down Expand Up @@ -361,7 +359,13 @@ const MIN_NUM_CHUNKS_FOR_COMPACTION: usize = 1 << 7;

/// The minimum size of a chunk at which parallelization of `butterfly`s is
/// beneficial. This value was chosen empirically.
const MIN_GAP_SIZE_FOR_PARALLELISATION: usize = 1 << 10;
const MIN_GAP_SIZE_FOR_PARALLELIZATION: usize = 1 << 10;


/// The minimum size of a chunk at which parallelization of `butterfly`s is
/// beneficial. This value was chosen empirically.
const MIN_INPUT_SIZE_FOR_PARALLELIZATION: usize = 1 << 10;


// minimum size at which to parallelize.
#[cfg(feature = "parallel")]
Expand Down

0 comments on commit 9a9b132

Please sign in to comment.