Skip to content

Commit

Permalink
chore(ci): fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
IceTDrinker committed Aug 19, 2024
1 parent 47e02d3 commit f08e54b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 43 deletions.
18 changes: 8 additions & 10 deletions benches/fft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,22 @@ pub fn bench_ffts(c: &mut Criterion) {
concrete_fft::unordered::Method::Measure(bench_duration),
);

let (mut dst, stack) = stack.rb_mut().make_aligned_with::<c64, _>(n, 64, |_| z);
let (mut src, mut stack) = stack.make_aligned_with::<c64, _>(n, 64, |_| z);
let (dst, stack) = stack.rb_mut().make_aligned_with::<c64, _>(n, 64, |_| z);
let (src, mut stack) = stack.make_aligned_with::<c64, _>(n, 64, |_| z);

let bench_id = format!("rustfft-fwd-{n}");
c.bench_function(&bench_id, |b| {
let mut planner = FftPlannerAvx::<f64>::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);

let bench_id = format!("fftw-fwd-{n}");
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);
Expand All @@ -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);

Expand All @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/nat.rs
Original file line number Diff line number Diff line change
@@ -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<N>(pub N);
pub struct Zero;
pub type N0 = Zero;
Expand Down
34 changes: 11 additions & 23 deletions src/ordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ fn measure_n_runs(
stack: PodStack,
) -> Duration {
let n = buf.len();
let (mut scratch, _) = stack.make_aligned_raw::<c64>(n, CACHELINE_ALIGN);
let (scratch, _) = stack.make_aligned_raw::<c64>(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()
Expand Down Expand Up @@ -112,7 +112,7 @@ pub(crate) fn measure_fastest(
let (twiddles, stack) = stack.make_aligned_with::<c64, _>(2 * n, align, f);
let twiddles_init = &twiddles[..n];
let twiddles = &twiddles[n..];
let (mut buf, mut stack) = stack.make_aligned_with::<c64, _>(n, align, f);
let (buf, mut stack) = stack.make_aligned_with::<c64, _>(n, align, f);

{
// initialize scratch to load it in the cpu cache
Expand Down Expand Up @@ -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;
Expand All @@ -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)
};
}
Expand Down Expand Up @@ -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::<c64>(n, CACHELINE_ALIGN);
let (scratch, _) = stack.make_aligned_raw::<c64>(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.
Expand All @@ -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::<c64>(n, CACHELINE_ALIGN);
let (scratch, _) = stack.make_aligned_raw::<c64>(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)
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/unordered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@ fn measure_fastest(
let (w, stack) = stack
.rb_mut()
.make_aligned_with::<c64, _>(n + base_n, align, f);
let (mut scratch, stack) = stack.make_aligned_with::<c64, _>(base_n, align, f);
let (mut z, _) = stack.make_aligned_with::<c64, _>(n, align, f);
let (scratch, stack) = stack.make_aligned_with::<c64, _>(base_n, align, f);
let (z, _) = stack.make_aligned_with::<c64, _>(n, align, f);

let n_runs = min_bench_duration_per_algo.as_secs_f64()
/ (duration.as_secs_f64() * (n / base_n) as f64);
Expand All @@ -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,
Expand Down Expand Up @@ -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::<c64>(self.algo().1, CACHELINE_ALIGN);
let (scratch, _) = stack.make_aligned_raw::<c64>(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,
Expand Down Expand Up @@ -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::<c64>(self.algo().1, CACHELINE_ALIGN);
let (scratch, _) = stack.make_aligned_raw::<c64>(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,
Expand Down
2 changes: 1 addition & 1 deletion toolchain.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-02-08
nightly-2024-07-18

0 comments on commit f08e54b

Please sign in to comment.