From 4e762044ffb6e23ca64361f22e60e81a36a347a6 Mon Sep 17 00:00:00 2001 From: yichi170 Date: Mon, 9 Jan 2023 20:49:22 +0800 Subject: [PATCH 1/3] feat: conditional compile --- src/{ => intrinsic}/intrinfft.rs | 0 src/intrinsic/mod.rs | 2 ++ src/lib.rs | 3 ++- src/main.rs | 41 +++++++++++++++++--------------- 4 files changed, 26 insertions(+), 20 deletions(-) rename src/{ => intrinsic}/intrinfft.rs (100%) create mode 100644 src/intrinsic/mod.rs diff --git a/src/intrinfft.rs b/src/intrinsic/intrinfft.rs similarity index 100% rename from src/intrinfft.rs rename to src/intrinsic/intrinfft.rs diff --git a/src/intrinsic/mod.rs b/src/intrinsic/mod.rs new file mode 100644 index 0000000..adfabe3 --- /dev/null +++ b/src/intrinsic/mod.rs @@ -0,0 +1,2 @@ +#[cfg(target_arch = "x86_64")] +pub mod intrinfft; diff --git a/src/lib.rs b/src/lib.rs index 1d03a9c..a7c6ac8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod freq_scale; -pub mod intrinfft; +#[cfg(target_arch = "x86_64")] +pub mod intrinsic; pub mod pfft; pub mod rfft; pub mod sfft; diff --git a/src/main.rs b/src/main.rs index 40e2bda..1c3d7db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ -mod intrinfft; mod pfft; mod rfft; mod sfft; -mod splitfft; mod utils; +mod splitfft; +mod intrinsic; use num_complex::Complex; use rustfft::FftPlanner; @@ -63,23 +63,26 @@ fn main() { ); utils::dump_result("rayon", &mut result, output_filename).unwrap(); - let mut result = bench_fft( - intrinfft::simd_fft, - intrinfft::simd_ifft, - benchname, - "SIMD", - bench_niter, - ); - utils::dump_result("simd", &mut result, output_filename).unwrap(); - - let mut result = bench_fft( - intrinfft::rayon_simd_fft, - intrinfft::rayon_simd_ifft, - benchname, - "Rayon SIMD", - bench_niter, - ); - utils::dump_result("rayon simd", &mut result, output_filename).unwrap(); + #[cfg(target_arch = "x86_64")] + { + let mut result = bench_fft( + intrinfft::simd_fft, + intrinfft::simd_ifft, + benchname, + "SIMD", + bench_niter, + ); + utils::dump_result("simd", &mut result, output_filename).unwrap(); + + let mut result = bench_fft( + intrinfft::rayon_simd_fft, + intrinfft::rayon_simd_ifft, + benchname, + "Rayon SIMD", + bench_niter, + ); + utils::dump_result("rayon simd", &mut result, output_filename).unwrap(); + } let mut result = bench_fft( splitfft::fft, From 90c9f534dc01781376b9b043714043123d67116d Mon Sep 17 00:00:00 2001 From: yichi170 Date: Mon, 9 Jan 2023 23:12:05 +0800 Subject: [PATCH 2/3] feat: conditional compile at tests/ --- tests/accuracy.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/accuracy.rs b/tests/accuracy.rs index 663827d..3ecce4e 100644 --- a/tests/accuracy.rs +++ b/tests/accuracy.rs @@ -1,5 +1,6 @@ use ffrust::freq_scale; -use ffrust::intrinfft; +#[cfg(target_arch = "x86_64")] +use ffrust::intrinsic; use ffrust::pfft; use ffrust::rfft; use ffrust::sfft; @@ -53,16 +54,18 @@ fn test_rayon_fft() { run_fft_ifft(pfft::rayon_fft, pfft::rayon_ifft, "rayon_recon.wav"); } +#[cfg(target_arch = "x86_64")] #[test] fn test_simd_fft() { - run_fft_ifft(intrinfft::simd_fft, intrinfft::simd_ifft, "simd_recon.wav"); + run_fft_ifft(intrinsic::simd_fft, intrinsic::simd_ifft, "simd_recon.wav"); } +#[cfg(target_arch = "x86_64")] #[test] fn test_rayon_simd_fft() { run_fft_ifft( - intrinfft::rayon_simd_fft, - intrinfft::rayon_simd_ifft, + intrinsic::rayon_simd_fft, + intrinsic::rayon_simd_ifft, "rayon_simd_recon.wav", ); } From 9a83534a178b2ebc1dff9d318ee25a5bd9c66298 Mon Sep 17 00:00:00 2001 From: yichi170 Date: Mon, 9 Jan 2023 23:23:33 +0800 Subject: [PATCH 3/3] fix: conditional compile --- src/main.rs | 3 +++ tests/accuracy.rs | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1c3d7db..acb35ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,9 @@ mod utils; mod splitfft; mod intrinsic; +#[cfg(target_arch = "x86_64")] +use intrinsic::intrinfft; + use num_complex::Complex; use rustfft::FftPlanner; use std::env; diff --git a/tests/accuracy.rs b/tests/accuracy.rs index 3ecce4e..14c7ab5 100644 --- a/tests/accuracy.rs +++ b/tests/accuracy.rs @@ -1,6 +1,6 @@ use ffrust::freq_scale; #[cfg(target_arch = "x86_64")] -use ffrust::intrinsic; +use ffrust::intrinsic::intrinfft; use ffrust::pfft; use ffrust::rfft; use ffrust::sfft; @@ -57,15 +57,15 @@ fn test_rayon_fft() { #[cfg(target_arch = "x86_64")] #[test] fn test_simd_fft() { - run_fft_ifft(intrinsic::simd_fft, intrinsic::simd_ifft, "simd_recon.wav"); + run_fft_ifft(intrinfft::simd_fft, intrinfft::simd_ifft, "simd_recon.wav"); } #[cfg(target_arch = "x86_64")] #[test] fn test_rayon_simd_fft() { run_fft_ifft( - intrinsic::rayon_simd_fft, - intrinsic::rayon_simd_ifft, + intrinfft::rayon_simd_fft, + intrinfft::rayon_simd_ifft, "rayon_simd_recon.wav", ); }