wgsl_fft/lib.rs
1//! GPU-accelerated FFT using [wgpu](https://github.com/gfx-rs/wgpu) compute shaders.
2//!
3//! This crate provides fast Fourier transform (FFT) computation on GPU hardware
4//! using WebGPU compute shaders via the [wgpu](https://github.com/gfx-rs/wgpu) library.
5//!
6//! ## Features
7//!
8//! - **GPU-accelerated**: Uses wgpu compute shaders for high-performance FFT computation.
9//! - **Stockham Radix-4/2**: Fast algorithm for power-of-two FFT sizes.
10//! - **Arbitrary sizes**: Bluestein's algorithm for non-power-of-two sizes (GPU-accelerated via power-of-2 FFTs).
11//! - **Batch processing**: Efficiently process multiple FFTs in a single call.
12//! - **Fallback support**: Automatically falls back to CPU software rendering if no GPU is available.
13//!
14//! ## Quick Start
15//!
16//! ```no_run
17//! use wgsl_fft::GpuFft;
18//! use num_complex::Complex;
19//!
20//! let fft = GpuFft::new().expect("GPU or CPU fallback required");
21//! let input = vec![vec![Complex::new(1.0, 0.0); 1024]];
22//! let spectrum = fft.fft(&input).expect("FFT failed");
23//! ```
24//!
25//! ## Module Structure
26//!
27//! - [`fft`] - Main FFT implementation with [`GpuFft`] and [`FftExecutor`] trait
28//! - [`pipelines`] - Pre-compiled FFT pipelines for embedding in larger GPU pipelines
29//! - [`shaders`] - WGSL compute shader source code
30//! - [`benchmark`] - Benchmarking utilities
31//! - [`error`] - Error types for FFT operations
32
33mod error;
34pub use error::{FftError, Result};
35
36pub mod benchmark;
37#[cfg(feature = "cuda")]
38mod cufft_wrapper;
39#[cfg(feature = "hipfft")]
40pub mod hipfft_wrapper;
41pub mod rivals;
42#[cfg(feature = "rocm")]
43mod rocfft_wrapper;
44pub mod shaders;
45
46mod fft;
47mod pipelines;
48
49pub use fft::{FftExecutor, FftUniforms, GpuFft, GpuFftTrait, SizeCache};
50pub use pipelines::{FftDirection, FftPipelines};
51
52#[cfg(feature = "cuda")]
53pub use cufft_wrapper::CuFft;
54#[cfg(feature = "hipfft")]
55pub use hipfft_wrapper::HipFft;
56#[cfg(feature = "rocm")]
57pub use rocfft_wrapper::RocFft;