Skip to content
AniruthAnanthPublic

About

Fast Fourier Transform: Cache-Hierarchy Optimized, Deterministic Edition

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

40 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fftchode

fftchode (Fast Fourier Transform, Cache-Hierarchy Optimized, Deterministic Edition): a single-file, FFTW 3-compatible FFT library built on FFTW 3.3.10.

Performance

Geometric-mean speedup over FFTW 3.3.10 (scalar build, FFTW_ESTIMATE) on the 128-problem frozen suite:

mode 1 thread best thread count
bit-identical 1.19x 1.42x
fast 3.04x 3.14x

"Best thread count" runs each build at its own fastest of 1, 2, 4 and 8 threads per problem. Measured on an AMD Zen 4 VM (4 cores, 8 threads, AVX-512); see the paper and bench/results/threads/.

Modes

  • Bit-identical (default, fftchode_set_numerics(0)): every output and exported wisdom match scalar FFTW 3.3.10 (built without FMA contraction) bit for bit.
  • Fast (fftchode_set_numerics(1)): adds SIMD codelets and a cost-model planner; results differ from FFTW only at roundoff level.

FFTCHODE_NUMERICS=baseline|fast selects the mode from the environment. FFTCHODE_THREAD_WORK sets the work per thread (default 32768 flops, 0 = off) below which small problems use fewer threads than requested.

Build

make lib            # build/libfftchode.a (clang++ -O2 -ffp-contract=off)
make test           # bit-identity vs upstream FFTW 3.3.10, and fast-mode accuracy

Or compile the one file directly: c++ -std=c++17 -O2 -ffp-contract=off -pthread -c src/fftchode.cpp. No dependencies beyond the C++ standard library and pthreads.

Usage

Use fftchode.h in place of fftw3.h; the FFTW 3 API (fftw_*, fftwf_*, threads) is unchanged.

#include "fftchode.h"

int main(void) {
    fftchode_set_numerics(1);                        /* optional: fast mode */
    int n = 1024;
    fftw_complex *x = fftw_alloc_complex(n);
    fftw_plan p = fftw_plan_dft_1d(n, x, x, FFTW_FORWARD, FFTW_ESTIMATE);
    for (int i = 0; i < n; i++) { x[i][0] = i; x[i][1] = 0; }
    fftw_execute(p);
    fftw_destroy_plan(p);
    fftw_free(x);
    return 0;
}
cc -Isrc example.c build/libfftchode.a -lstdc++ -lm -pthread

Docs

License

GPL-2.0-or-later; see LICENSE. Built on FFTW 3.3.10 by Matteo Frigo and Steven G. Johnson, whose copyright notices are kept in the source. Third-party code under bench/ keeps its own notices.

About

Fast Fourier Transform: Cache-Hierarchy Optimized, Deterministic Edition

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages