Skip to content

Commit 8fe9395

Browse files
authored
Merge pull request #69 from QuState/determine-level-once
Determine SIMD level in the planner
2 parents 7aaba0f + 04f73a9 commit 8fe9395

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/algorithms/dit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! DIT starts with fine-grained memory access and progressively works with
1515
//! larger contiguous chunks.
1616
//!
17-
use fearless_simd::{dispatch, Level, Simd};
17+
use fearless_simd::{dispatch, Simd};
1818

1919
use crate::algorithms::bravo::{bit_rev_bravo_f32, bit_rev_bravo_f64};
2020
use crate::kernels::dit::*;
@@ -251,7 +251,7 @@ pub fn fft_64_dit_with_planner_and_opts(
251251
let log_n = n.ilog2() as usize;
252252
assert_eq!(log_n, planner.log_n);
253253

254-
let simd_level = Level::new();
254+
let simd_level = planner.simd_level;
255255

256256
// DIT requires bit-reversed input
257257
run_maybe_in_parallel(
@@ -296,7 +296,7 @@ pub fn fft_32_dit_with_planner_and_opts(
296296
let log_n = n.ilog2() as usize;
297297
assert_eq!(log_n, planner.log_n);
298298

299-
let simd_level = Level::new();
299+
let simd_level = planner.simd_level;
300300

301301
// DIT requires bit-reversed input
302302
run_maybe_in_parallel(

src/planner.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,17 @@ macro_rules! impl_planner_dit_for {
8787
pub direction: Direction,
8888
/// The log2 of the FFT size
8989
pub log_n: usize,
90+
/// The level of SIMD instruction support, detected at runtime on x86 and hardcoded elsewhere
91+
pub simd_level: fearless_simd::Level,
9092
}
9193

9294
impl $struct_name {
9395
/// Create a DIT planner for an FFT of size `num_points`
9496
pub fn new(num_points: usize, direction: Direction) -> Self {
9597
assert!(num_points > 0 && num_points.is_power_of_two());
9698

99+
let simd_level = fearless_simd::Level::new();
100+
97101
let log_n = num_points.ilog2() as usize;
98102
let mut stage_twiddles = Vec::new();
99103

@@ -123,6 +127,7 @@ macro_rules! impl_planner_dit_for {
123127
stage_twiddles,
124128
direction,
125129
log_n,
130+
simd_level,
126131
}
127132
}
128133
}

0 commit comments

Comments
 (0)