ejmahler / RustFFT

RustFFT is a high-performance FFT library written in pure Rust.
Apache License 2.0
678 stars 47 forks source link

Implement WebAssembly SIMD acceleration #120

Closed pr1metine closed 1 year ago

pr1metine commented 1 year ago

Should fix #89. The code for WASM SIMD is heavily inspired by the NEON implementation. Run unit tests using wasm-pack test:

wasm-pack test --node --features wasm_simd

472d4716-52bd-4ebd-86f0-2322b521ab0a

When running FFTs on f32 data, we can expect twice the performance when compared to scalar algorithms. This means, that WASM SIMD performance is on par with native AArch64 w/o Neon.

image Unfortunately, WASM SIMD FFT performance is only marginally better than scalar. AFAIK, it's because of mul_complex_f64:

https://github.com/pr1metine/RustFFT/blob/33ff96aa347e82cc4e05409885093cfa256fd9e2/src/wasm_simd/wasm_simd_utils.rs#L171-L176

Additionally in some cases, I could not find equivalent WASM operations for NEON. Relaxed SIMD should help once it is implemented.

HEnquist commented 1 year ago

I have not looked very carefully (yet), but on first glance this looks very good! Nice work!

pr1metine commented 1 year ago

Thanks for the feedback and your kind words 🙏. I‘ll give you guys a couple of days, then I‘ll incorporate your feedback

pr1metine commented 1 year ago

Anything else, @ejmahler ?

pr1metine commented 1 year ago

Thanks again for your kind words 🙏. LMK if I can improve anything else.

HEnquist commented 1 year ago

I have not found anything more to comment on, all looks good to me.

ejmahler commented 1 year ago

Thanks! I'll make a release tomorrow.

pr1metine commented 1 year ago

Thank you too 🙏 🙏. I'm glad to be a part of this

pr1metine commented 7 months ago

Hey, it's been a while. I need WASM SIMD for work. Can we push a new release containing this feature?

ejmahler commented 7 months ago

Done. https://crates.io/crates/rustfft/6.2.0