Skip to content

FFTL.jl

FFTL.jl ​

Fastest Fourier Transform in Lübeck: a fast Fourier transform written in Julia. Complex, real and real-to-real transforms of any length and any number of dimensions, in Float32, Float64 and other floating-point types, on several threads with SIMD on the CPU, through KernelAbstractions on GPUs, and as a C library (libfftl) compiled from the same Julia code.

Background ​

FFTL was written by a coding agent under the guidance of a domain expert. Julia makes a library of this scope possible in one language: the compiler generates the codelets for the radix, element type and SIMD width in use, the same generator serves the GPU kernels, and juliac turns the package into a C library. A coding agent makes it possible to implement, test and measure the many details such a library needs. The library builds on decades of work on fast Fourier transforms, above all on FFTW; FFTW and FFTL describes that history.

FFTL is meant to be developed further by the Julia community, as one FFT that the ecosystem shares. Contribute says where help is most useful.

Scope / Coverage ​

Fourier and discrete cosine transforms written in Julia, with wide support for number types and CPU and GPU execution.

  • Complex, real-input and all eleven real-to-real kinds (DCT-I to DCT-IV, DST-I to DST-IV, Hartley, halfcomplex), along any set of dimensions of any rank.

  • Any length: smooth lengths through generated codelets, lengths with large prime factors resampled onto a smooth grid, no padding to powers of two.

  • BigFloat and other floating-point types in their own precision, not converted to Float64.

  • GPUs through KernelAbstractions.jl, with the same functions.

  • Multithreading where the transform is large enough, and the four-step algorithm for one long line (see Threads).

A C library made from the Julia code. libfftl is the package compiled with juliac --trim, with FFTW3's C and Fortran interfaces, so programs written for FFTW3 compile and link against it without source changes. No transform is written in C, and a program that links the library needs no Julia installation. The run-time plans it is built from are public, so Julia programs that use them can be trimmed as well.

Entry points for special variants. Passes transform one dimension of a strided array. Libraries that assemble their own transforms from such passes, such as NFFT.jl, use them.

The interface of the ecosystem. FFTL implements AbstractFFTs.jl: its plans are AbstractFFTs plans, and generic code that calls AbstractFFTs.fft, plan_fft, … runs on FFTL. In addition, using FFTL brings functions with the names, conventions and scalings of FFTW.jl (fft, rfft, dct, FFTL.r2r, …), so code written for FFTW.jl runs after replacing using FFTW by using FFTL. These functions are FFTL's own, so a dependency that loads FFTW.jl does not redirect them (see Coming from FFTW.jl).

Installation ​

julia
using Pkg
Pkg.add("FFTL")

Quick start ​

julia
using FFTL, LinearAlgebra

x = randn(ComplexF64, 1000, 1000)
y = fft(x)                  # all dimensions, unnormalised
x2 = ifft(y)                # normalised inverse
x2 ≈ x
true
julia
p = plan_fft(x)             # a plan holds the work buffers and tables
mul!(y, p, x)               # apply it, as often as you like
y ≈ fft(x)
true
julia
r = randn(1000, 1000)
R = rfft(r)                 # half spectrum along dimension 1: 501 × 1000
irfft(R, 1000) ≈ r
true
julia
C = dct(r)                  # orthonormal DCT-II; idct inverts it
idct(C) ≈ r
true

Further reading ​

If you want toread
run your first transformYour first transform
see the library used on real problemsTutorials
move code from FFTW.jlComing from FFTW.jl
solve a specific task: plans, real data, threads, GPUs, CHow-to Guides
understand the mathematics and the algorithmsExplanation
look up a function, a kind, a limitReference

Design in one paragraph ​

A plan is a Julia object that carries the radix sequence, the twiddle tables and the work buffers for one size and one set of dimensions. Radix sequences are chosen by a fixed rule, and the codelets they run are generated for the radix, element type and SIMD width actually used. Long transforms run on several threads, and lengths with large prime factors are resampled onto a smooth grid. The details are in Algorithms.

Package status ​

Julia1.10 and newer (CI: 1.10 and current)
LicenseMIT
InterfaceAbstractFFTs.jl backend; plans are AbstractFFTs.Plans with mul!, *, \ and inv
PlatformsLinux and macOS (CI); Apple M1 Max is the development machine
GPUvia KernelAbstractions.jl, tuned on Metal and CUDA
C libraryexperimental, juliac --trim, see libfftl

The complete matrix of transforms, number types and platforms is in Platforms and limits.