From f08e54b4092d02860942ab6ea05b13858dd7afc2 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Thu, 18 Jul 2024 11:44:35 +0200 Subject: [PATCH] chore(ci): fix clippy lints --- benches/fft.rs | 18 ++++++++---------- src/nat.rs | 3 +++ src/ordered.rs | 34 +++++++++++----------------------- src/unordered.rs | 18 +++++++++--------- toolchain.txt | 2 +- 5 files changed, 32 insertions(+), 43 deletions(-) diff --git a/benches/fft.rs b/benches/fft.rs index bbc3e76..3160bba 100644 --- a/benches/fft.rs +++ b/benches/fft.rs @@ -141,14 +141,14 @@ pub fn bench_ffts(c: &mut Criterion) { concrete_fft::unordered::Method::Measure(bench_duration), ); - let (mut dst, stack) = stack.rb_mut().make_aligned_with::(n, 64, |_| z); - let (mut src, mut stack) = stack.make_aligned_with::(n, 64, |_| z); + let (dst, stack) = stack.rb_mut().make_aligned_with::(n, 64, |_| z); + let (src, mut stack) = stack.make_aligned_with::(n, 64, |_| z); let bench_id = format!("rustfft-fwd-{n}"); c.bench_function(&bench_id, |b| { let mut planner = FftPlannerAvx::::new().unwrap(); let fwd_rustfft = planner.plan_fft_forward(n); - b.iter(|| fwd_rustfft.process_outofplace_with_scratch(&mut src, &mut dst, &mut scratch)) + b.iter(|| fwd_rustfft.process_outofplace_with_scratch(src, dst, &mut scratch)) }); write_to_json(&bench_id, "rustfft-fwd", n); @@ -156,7 +156,7 @@ pub fn bench_ffts(c: &mut Criterion) { c.bench_function(&bench_id, |b| { let fwd_fftw = PlanInterleavedC64::new(n, Sign::Forward); b.iter(|| { - fwd_fftw.execute(&mut src, &mut dst); + fwd_fftw.execute(src, dst); }) }); write_to_json(&bench_id, "fftw-fwd", n); @@ -168,21 +168,19 @@ pub fn bench_ffts(c: &mut Criterion) { ); let bench_id = format!("concrete-fwd-{n}"); - c.bench_function(&bench_id, |b| { - b.iter(|| ordered.fwd(&mut dst, stack.rb_mut())) - }); + c.bench_function(&bench_id, |b| b.iter(|| ordered.fwd(dst, stack.rb_mut()))); write_to_json(&bench_id, "concrete-fwd", n); } let bench_id = format!("unordered-fwd-{n}"); c.bench_function(&bench_id, |b| { - b.iter(|| unordered.fwd(&mut dst, stack.rb_mut())); + b.iter(|| unordered.fwd(dst, stack.rb_mut())); }); write_to_json(&bench_id, "unordered-fwd", n); let bench_id = format!("unordered-inv-{n}"); c.bench_function(&bench_id, |b| { - b.iter(|| unordered.inv(&mut dst, stack.rb_mut())); + b.iter(|| unordered.inv(dst, stack.rb_mut())); }); write_to_json(&bench_id, "unordered-inv", n); @@ -203,7 +201,7 @@ pub fn bench_ffts(c: &mut Criterion) { if degree == n { degree = 0; } - unordered.fwd_monomial(degree, &mut dst); + unordered.fwd_monomial(degree, dst); }) }); write_to_json(&bench_id, "fwd-monomial", n); diff --git a/src/nat.rs b/src/nat.rs index d5aca28..69f2803 100644 --- a/src/nat.rs +++ b/src/nat.rs @@ -1,3 +1,6 @@ +#![allow(dead_code)] +// TODO: remove this allow, clippy has a false positive on this for Plus2, Plus3 and Plus4 + pub struct Successor(pub N); pub struct Zero; pub type N0 = Zero; diff --git a/src/ordered.rs b/src/ordered.rs index 688e63b..0f93219 100644 --- a/src/ordered.rs +++ b/src/ordered.rs @@ -68,14 +68,14 @@ fn measure_n_runs( stack: PodStack, ) -> Duration { let n = buf.len(); - let (mut scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); + let (scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); let [fwd, _] = get_fn_ptr(algo, n); use std::time::Instant; let now = Instant::now(); for _ in 0..n_runs { - fwd(buf, &mut scratch, twiddles, twiddles_init); + fwd(buf, scratch, twiddles, twiddles_init); } now.elapsed() @@ -112,7 +112,7 @@ pub(crate) fn measure_fastest( let (twiddles, stack) = stack.make_aligned_with::(2 * n, align, f); let twiddles_init = &twiddles[..n]; let twiddles = &twiddles[n..]; - let (mut buf, mut stack) = stack.make_aligned_with::(n, align, f); + let (buf, mut stack) = stack.make_aligned_with::(n, align, f); { // initialize scratch to load it in the cpu cache @@ -142,14 +142,8 @@ pub(crate) fn measure_fastest( let mut n_runs: u128 = 1; loop { - let duration = measure_n_runs( - n_runs, - algo, - &mut buf, - twiddles_init, - twiddles, - stack.rb_mut(), - ); + let duration = + measure_n_runs(n_runs, algo, buf, twiddles_init, twiddles, stack.rb_mut()); if duration < MIN_DURATION { n_runs *= 2; @@ -164,14 +158,8 @@ pub(crate) fn measure_fastest( *avg = if n_runs <= init_n_runs { approx_duration } else { - let duration = measure_n_runs( - n_runs, - algo, - &mut buf, - twiddles_init, - twiddles, - stack.rb_mut(), - ); + let duration = + measure_n_runs(n_runs, algo, buf, twiddles_init, twiddles, stack.rb_mut()); duration_div_f64(duration, n_runs as f64) }; } @@ -346,9 +334,9 @@ impl Plan { /// ``` pub fn fwd(&self, buf: &mut [c64], stack: PodStack) { let n = self.fft_size(); - let (mut scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); + let (scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); let (w_init, w) = split_2(&self.twiddles); - (self.fwd)(buf, &mut scratch, w_init, w) + (self.fwd)(buf, scratch, w_init, w) } /// Performs an inverse FFT in place, using the provided stack as scratch space. @@ -372,9 +360,9 @@ impl Plan { /// ``` pub fn inv(&self, buf: &mut [c64], stack: PodStack) { let n = self.fft_size(); - let (mut scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); + let (scratch, _) = stack.make_aligned_raw::(n, CACHELINE_ALIGN); let (w_init, w) = split_2(&self.twiddles_inv); - (self.inv)(buf, &mut scratch, w_init, w) + (self.inv)(buf, scratch, w_init, w) } } diff --git a/src/unordered.rs b/src/unordered.rs index dc68055..60e63be 100644 --- a/src/unordered.rs +++ b/src/unordered.rs @@ -602,8 +602,8 @@ fn measure_fastest( let (w, stack) = stack .rb_mut() .make_aligned_with::(n + base_n, align, f); - let (mut scratch, stack) = stack.make_aligned_with::(base_n, align, f); - let (mut z, _) = stack.make_aligned_with::(n, align, f); + let (scratch, stack) = stack.make_aligned_with::(base_n, align, f); + let (z, _) = stack.make_aligned_with::(n, align, f); let n_runs = min_bench_duration_per_algo.as_secs_f64() / (duration.as_secs_f64() * (n / base_n) as f64); @@ -614,11 +614,11 @@ fn measure_fastest( let now = Instant::now(); for _ in 0..n_runs { fwd_depth( - &mut z, - &w, + z, + w, base_fn, base_n, - &mut scratch, + scratch, fwd_process_x2, fwd_process_x4, fwd_process_x8, @@ -824,13 +824,13 @@ impl Plan { /// ``` pub fn fwd(&self, buf: &mut [c64], stack: PodStack) { assert_eq!(self.fft_size(), buf.len()); - let (mut scratch, _) = stack.make_aligned_raw::(self.algo().1, CACHELINE_ALIGN); + let (scratch, _) = stack.make_aligned_raw::(self.algo().1, CACHELINE_ALIGN); fwd_depth( buf, &self.twiddles, self.base_fn_fwd, self.base_n, - &mut scratch, + scratch, self.fwd_process_x2, self.fwd_process_x4, self.fwd_process_x8, @@ -925,13 +925,13 @@ impl Plan { /// ``` pub fn inv(&self, buf: &mut [c64], stack: PodStack) { assert_eq!(self.fft_size(), buf.len()); - let (mut scratch, _) = stack.make_aligned_raw::(self.algo().1, CACHELINE_ALIGN); + let (scratch, _) = stack.make_aligned_raw::(self.algo().1, CACHELINE_ALIGN); inv_depth( buf, &self.twiddles_inv, self.base_fn_inv, self.base_n, - &mut scratch, + scratch, self.inv_process_x2, self.inv_process_x4, self.inv_process_x8, diff --git a/toolchain.txt b/toolchain.txt index 36e57ce..a6d32a8 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -1 +1 @@ -nightly-2024-02-08 +nightly-2024-07-18