Expand description
BestFft: the crate’s high-performance FFT for power-of-two sizes.
The transform is an iterative decimation-in-time Cooley-Tukey FFT on bit-reversed data, tuned in five ways compared with a textbook radix-2 loop:
- Radix-4 passes. Pairs of radix-2 stages are fused into one radix-4 pass. Each pass reads and
writes the array once instead of twice, and needs three complex twiddle multiplications per
four outputs instead of four (the
±irotations inside a radix-4 butterfly are free). For an oddlog2(n)one radix-2 pass comes first. - SIMD. On x86-64 with AVX2 and FMA (detected at run time) the passes process two complex
values per 256-bit register, with complex multiplication done by
fmaddsub. Other targets use a portable scalar implementation of the same algorithm. - Cache blocking. Every stage whose butterflies span at most
BLOCKpoints is run on oneBLOCK-point chunk at a time (all those stages for a chunk, then the next chunk), so the chunk stays in L1/L2 cache. Only the few largest stages make full passes over a big array. - Bandwidth-saving large passes. Passes that sweep the whole array store only
W^jand formW^2jandW^3jin registers, cutting their twiddle traffic by a factor of three. - Cache-friendly permutation, no extra copies. The bit-reversal permutation is done in 16×16 tiles that use whole cache lines, writes straight into the output vector with any scaling folded in, and the transform then runs in place in the output.
Twiddle factors are computed once at planning time from exact angles (no recurrences), and laid out per pass in exactly the order the kernels read them.
See the book entry The fast Fourier transform.