Open WalterSmuts opened 1 year ago
Good morning,
Thank you for the contribution!
I don't see any problem with this PR and I will get it merged, just want to make sure that I can still build the library for wasm first.
You seem to know your way around the various fft libraries, so I have an unrelated question for you.
I was trying to get this library built for a no_std
environment, but I didn't get far as rustfft
brings in a few dependencies (mainly the num traits) that are no_std
compatible but only when specifying some flags, which rustfft doesn't expose to its consumers.
Do you know if there is a workaround for this?
I don't have much experience with no_std
but here goes some info. Take it with a grain of salt however because I've not ever really been involved:
rustfft
uses std
a LOT:
$ git grep std | wc
347 1250 25387
rustfft
's functionality relies on Allocation such as the convenient general planner:
let mut planner = FftPlanner::new();
let fft = planner.plan_fft_forward(1234); // <-- This returns an Arc<dyn Fft
so you'd atleast need an allocator which AFAIK can be achieved without std.
* Rustfft does some feature detection at runtime that I think needs an OS:
https://doc.rust-lang.org/std/macro.is_x86_feature_detected.html?search=is_x86_feature_detected
* There may be a `no_std` version: https://doc.rust-lang.org/std/macro.is_x86_feature_detected.html?search=is_x86_feature_detected
* There seems to be a `no_std` fft crate that's quite popular: https://crates.io/crates/microfft
* All in all I think `rustfft` is just for `std` compatible targets. Perhaps open an issue to be sure? I think it's definitely something others will be interested in too.
This makes the logic simpler and manages the planner and scratch buffers behind the scenes resulting in a ~80% benchmark improvement across the board:
Unfortunately it requires an extra trait bound on
Default
for the fft elements. This is not neccesary but requires changes torustfft
tracked in https://github.com/ejmahler/RustFFT/issues/105.