Skip to main content

Module best_fft

Module best_fft 

Source
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:

  1. 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 ±i rotations inside a radix-4 butterfly are free). For an odd log2(n) one radix-2 pass comes first.
  2. 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.
  3. Cache blocking. Every stage whose butterflies span at most BLOCK points is run on one BLOCK-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.
  4. Bandwidth-saving large passes. Passes that sweep the whole array store only W^j and form W^2j and W^3j in registers, cutting their twiddle traffic by a factor of three.
  5. 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.

Structs§

BestFft