Repository navigation
v18.5 — The int16 FFTs run about twice as fast on Cortex-M4
v18.5 — The int16 FFTs run about twice as fast on Cortex-M4
Faster FFTs, same output (#284, #285)
QFFT1Dis 1.75 to 2.32 times faster on a Cortex-M4F (NUCLEO-F411RE,-O3, N = 64 to 1,024) andQRFFT1D1.64 to 2.00 times. A 256-point real-input transform now takes 0.24 ms at 100 MHz, down from 0.47 ms in v18.4. On a Cortex-M0+ (NUCLEO-L031K6)QFFT1Dis 1.04 to 1.33 times faster at-O3and 1.03 to 1.57 times at-O2.FFT1D<Q8.8>is 1.08 to 1.36 times faster on the Cortex-M4F at-O3and 1.15 to 1.23 times on the Cortex-M0+.- Every output is bit-identical to v18.4's: forward, inverse and real-input, for every N from 2 to 4,096 (
QFFT1D,QRFFT1D) and for Q8.8, Q16.16, float and double (FFT1D). The on-board benchmark checks each transform's output against the host before it records a timing.
What was slow
- The int16 saturation, written as early-return compares, compiled to four compare-and-branch pairs per butterfly. It is now one
SSATwhere the compiler reports the instruction (__ARM_FEATURE_SAT, as on the Cortex-M4) and a conditional elsewhere. - GCC kept the stage and group bookkeeping in registers and spilled the butterfly's own values to the stack, and how much depended on the transform length and even on unrelated code: one build of
QFFT1D<64>did 16 stack accesses per butterfly, another 1. Each stage is now its own out-of-line function with three values live across the inner loop, so the cost per butterfly is smooth in N: 46 to 53 cycles forQFFT1Don the Cortex-M4F, down from 78 to 114. - Two Cortex-M0+ figures are slower, which the benchmark README lists:
QRFFT1D<128>at-O3by 0.1%, andQFFT1D<512>with the twiddle tables in RAM by 5%.
Benchmark and docs
benchmarks/fft_onboardgainsIMG=fft1d, which timesFFT1D<Q8.8>with host-checked output.- The FFT page's "ARM Cortex-M0 Performance Estimates" table claimed about 22,000 cycles for a 256-point Q8.8 transform. Measured on the Cortex-M0+ it was 219,379 at
-O2(202,696 after #285); the page now shows measured figures for both boards. Its conclusion, that a 256-point FFT keeps up with a 1 kHz sample rate on a small M0+, still holds. QRFFT1Dis now 1.98 to 2.23 times faster thanQFFT1D, down from about 2.3 in v18.4, becauseQFFT1Dgained more.
Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/
Full changelog: v18.4...v18.5