All Projects → marton78 → pffft

marton78 / pffft

Licence: other
A fork of Julien Pommier's Pretty Fast FFT (PFFFT) library, with several additions

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
CMake
9771 projects
shell
77523 projects

Projects that are alternatives of or similar to pffft

fftpack
Double precision version of fftpack
Stars: ✭ 44 (-70.47%)
Mutual labels:  fft, fft-library
Filmroom
A Image Processing test field of Apple Platform. Mainly using Swift and Metal
Stars: ✭ 42 (-71.81%)
Mutual labels:  fft
intel-mkl-src
Redistribute Intel MKL as a crate
Stars: ✭ 52 (-65.1%)
Mutual labels:  fft
CCWT
Complex Continuous Wavelet Transform
Stars: ✭ 136 (-8.72%)
Mutual labels:  fft
fftWater
Ocean simulation based on the paper of Jerry Tessendorf: Simulating Ocean Water
Stars: ✭ 20 (-86.58%)
Mutual labels:  fft
MCHE485---Mechanical-Vibrations
Code supporting MCHE485: Mechanical Vibrations at the Univsersity of Louisiana at Lafayette
Stars: ✭ 30 (-79.87%)
Mutual labels:  fft
unity-music-visualizer
Basic music visualization project for Unity.
Stars: ✭ 39 (-73.83%)
Mutual labels:  fft
dsp-theory
Theory of digital signal processing (DSP): signals, filtration (IIR, FIR, CIC, MAF), transforms (FFT, DFT, Hilbert, Z-transform) etc.
Stars: ✭ 643 (+331.54%)
Mutual labels:  fft
go-kzg
FFT, data-recovery and KZG commitments, a.k.a. Kate commitments, in Go - *super experimental*
Stars: ✭ 34 (-77.18%)
Mutual labels:  fft
NMRI
2D Fourier Transform of Nuclear Magnetic Resonance Imaging raw data
Stars: ✭ 13 (-91.28%)
Mutual labels:  fft
dsp-kit
A digital signal processing library in Javascript
Stars: ✭ 32 (-78.52%)
Mutual labels:  fft
AbstractFFTs.jl
A Julia framework for implementing FFTs
Stars: ✭ 72 (-51.68%)
Mutual labels:  fft
FftSharp
A .NET Standard library for computing the Fast Fourier Transform (FFT) of real or complex data
Stars: ✭ 132 (-11.41%)
Mutual labels:  fft
GX-EncinoWaves
Graphics Experiment - FFT Ocean Water Simulation
Stars: ✭ 34 (-77.18%)
Mutual labels:  fft
Chisel-FFT-generator
FFT generator using Chisel
Stars: ✭ 26 (-82.55%)
Mutual labels:  fft
gpyfft
python wrapper for the OpenCL FFT library clFFT
Stars: ✭ 52 (-65.1%)
Mutual labels:  fft
benchmarking-fft
choosing FFT library...
Stars: ✭ 74 (-50.34%)
Mutual labels:  fft
aurora-sdk-mac
An SDK to develop effects for Nanoleaf Light Panels using features like frequency, beat, or tempo.
Stars: ✭ 43 (-71.14%)
Mutual labels:  fft
FFmpegPlayer
Simple FFmpeg video player
Stars: ✭ 72 (-51.68%)
Mutual labels:  fft
OceanFFT
OpenGL Demo: Simulating Ocean Waves with FFT
Stars: ✭ 60 (-59.73%)
Mutual labels:  fft

PFFFT: a pretty fast FFT and fast convolution with PFFASTCONV



Brief description:

PFFFT does 1D Fast Fourier Transforms, of single precision real and complex vectors. It tries do it fast, it tries to be correct, and it tries to be small. Computations do take advantage of SSE1 instructions on x86 cpus, Altivec on powerpc cpus, and NEON on ARM cpus. The license is BSD-like.

PFFFT is a fork of Julien Pommier's library on bitbucket with some changes and additions.

PFFASTCONV does fast convolution (FIR filtering), of single precision real vectors, utilizing the PFFFT library. The license is BSD-like.

PFDSP contains a few other signal processing functions. Currently, mixing and carrier generation functions are contained. It is work in progress - also the API! The fast convolution from PFFASTCONV might get merged into PFDSP.

Why does it exist:

I (Julien Pommier) was in search of a good performing FFT library , preferably very small and with a very liberal license.

When one says "fft library", FFTW ("Fastest Fourier Transform in the West") is probably the first name that comes to mind -- I guess that 99% of open-source projects that need a FFT do use FFTW, and are happy with it. However, it is quite a large library , which does everything fft related (2d transforms, 3d transforms, other transformations such as discrete cosine , or fast hartley). And it is licensed under the GNU GPL , which means that it cannot be used in non open-source products.

An alternative to FFTW that is really small, is the venerable FFTPACK v4, which is available on NETLIB. A more recent version (v5) exists, but it is larger as it deals with multi-dimensional transforms. This is a library that is written in FORTRAN 77, a language that is now considered as a bit antiquated by many. FFTPACKv4 was written in 1985, by Dr Paul Swarztrauber of NCAR, more than 25 years ago ! And despite its age, benchmarks show it that it still a very good performing FFT library, see for example the 1d single precision benchmarks here. It is however not competitive with the fastest ones, such as FFTW, Intel MKL, AMD ACML, Apple vDSP. The reason for that is that those libraries do take advantage of the SSE SIMD instructions available on Intel CPUs, available since the days of the Pentium III. These instructions deal with small vectors of 4 floats at a time, instead of a single float for a traditionnal FPU, so when using these instructions one may expect a 4-fold performance improvement.

The idea was to take this fortran fftpack v4 code, translate to C, modify it to deal with those SSE instructions, and check that the final performance is not completely ridiculous when compared to other SIMD FFT libraries. Translation to C was performed with f2c. The resulting file was a bit edited in order to remove the thousands of gotos that were introduced by f2c. You will find the fftpack.h and fftpack.c sources in the repository, this a complete translation of fftpack, with the discrete cosine transform and the test program. There is no license information in the netlib repository, but it was confirmed to me by the fftpack v5 curators that the [same terms do apply to fftpack v4] (http://www.cisl.ucar.edu/css/software/fftpack5/ftpk.html). This is a "BSD-like" license, it is compatible with proprietary projects.

Adapting fftpack to deal with the SIMD 4-element vectors instead of scalar single precision numbers was more complex than I originally thought, especially with the real transforms, and I ended up writing more code than I planned..

The code:

Good old C:

The FFT API is very very simple, just make sure that you read the comments in pffft.h.

The Fast convolution's API is also very simple, just make sure that you read the comments in pffastconv.h.

C++:

A simple C++ wrapper is available in pffft.hpp.

Git:

This archive's source can be downloaded with git (without the submodules):

git clone https://github.com/marton78/pffft.git

Only two files?:

"Only two files, in good old C, pffft.c and pffft.h"

This statement does NO LONGER hold!

With new functionality and support for AVX, there was need to restructure the sources. But you can compile and link pffft as a static library.

CMake:

There's now CMake support to build the static libraries libPFFFT.a and libPFFASTCONV.a from the source files, plus the additional libFFTPACK.a library. Later one's sources are there anyway for the benchmark.

There are several CMake options to modify library size and optimization. You can explore all available options with cmake-gui or ccmake, the console version - after having installed (on Debian/Ubuntu Linux) one of

sudo apt-get install cmake-qt-gui
sudo apt-get install cmake-curses-gui

Some of the options:

  • USE_TYPE_FLOAT to activate single precision 'float' (default: ON)
  • USE_TYPE_DOUBLE to activate 'double' precision float (default: ON)
  • USE_SIMD to use SIMD (SSE/AVX/NEON/ALTIVEC) CPU features? (default: ON)
  • DISABLE_SIMD_AVX to disable AVX CPU features (default: OFF)
  • USE_SIMD_NEON to force using NEON on ARM (requires USE_SIMD) (default: OFF)
  • USE_SCALAR_VECT to use 4-element vector scalar operations (if no other SIMD) (default: ON)

Options can be passed to cmake at command line, e.g.

cmake -DUSE_TYPE_FLOAT=OFF -DUSE_TYPE_DOUBLE=ON

My Linux distribution defaults to GCC. With installed CLANG and the bash shell, you can use it with

mkdir build
cd build
CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Debug ../
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=~ ../
ccmake .                          # or: cmake-gui .
cmake --build .                   # or simply: make
ctest                             # to execute some tests - including benchmarks
cmake --build . --target install  # or simply: [sudo] make install

With MSVC on Windows, you need some different options. Following ones to build a 64-bit Release with Visual Studio 2019:

mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
cmake --build . --config Release
ctest -C Release

see https://cmake.org/cmake/help/v3.15/manual/cmake-generators.7.html#visual-studio-generators

History / Origin / Changes:

Origin for this code/fork is Julien Pommier's pffft on bitbucket: https://bitbucket.org/jpommier/pffft/

Git history shows following first commits of the major contributors:

  • Julien Pommier: November 19, 2011
  • Marton Danoczy: September 30, 2015
  • Hayati Ayguen: December 22, 2019
  • Dario Mambro: March 24, 2020

There are a few other contributors not listed here.

The main changes include:

  • improved benchmarking, see https://github.com/hayguen/pffft_benchmarks
  • double support
  • avx(2) support
  • c++ headers (wrapper)
  • additional API helper functions
  • additional library for fast convolution
  • cmake support
  • ctest

Comparison with other FFTs:

The idea was not to break speed records, but to get a decently fast fft that is at least 50% as fast as the fastest FFT -- especially on slowest computers . I'm more focused on getting the best performance on slow cpus (Atom, Intel Core 1, old Athlons, ARM Cortex-A9...), than on getting top performance on today fastest cpus.

It can be used in a real-time context as the fft functions do not perform any memory allocation -- that is why they accept a 'work' array in their arguments.

It is also a bit focused on performing 1D convolutions, that is why it provides "unordered" FFTs , and a fourier domain convolution operation.

Very interesting is https://www.nayuki.io/page/free-small-fft-in-multiple-languages. It shows how small an FFT can be - including the Bluestein algorithm, but it's everything else than fast. The whole C++ implementation file is 161 lines, including the Copyright header, see https://github.com/nayuki/Nayuki-web-published-code/blob/master/free-small-fft-in-multiple-languages/FftComplex.cpp

Dependencies / Required Linux packages

On Debian/Ubuntu Linux following packages should be installed:

sudo apt-get install build-essential gcc g++ cmake

Benchmarks and results

Quicklink

Find results at https://github.com/hayguen/pffft_benchmarks.

General

My (Hayati Ayguen) first look at FFT-benchmarks was with benchFFT and especially the results of the benchmarks results, which demonstrate the performance of the FFTW. Looking at the benchmarked computer systems from todays view (2021), these are quite outdated.

Having a look into the benchFFT source code, the latest source changes, including competitive fft implementations, are dated November 2003.

In 2019, when pffft got my attention at bitbucket, there were also some benchmark results. Unfortunately the results are tables with numbers - without graphical plots. Without the plots, i could not get an impression. That was, why i started https://github.com/hayguen/pffft_benchmarks, which includes GnuPlot figures.

Today in June 2021, i realized the existence of https://github.com/FFTW/benchfft. This repository is much more up-to-date with a commit in December 2020. Unfortunately, it looks not so simple to get it run - including the generation of plots.

Is there any website showing benchFFT results of more recent computer systems?

Of course, it's very important, that a benchmark can be compared with a bunch of different FFT algorithms/implementations. This requires to have these compiled/built and utilizable.

Git submodules for Green-, Kiss- and Pocket-FFT

Sources for Green-, Kiss- and Pocket-FFT can be downloaded directly with the sources of this repository - using git submodules:

git clone --recursive https://github.com/marton78/pffft.git

Important is --recursive, that does also fetch the submodules directly. But you might retrieve the submodules later, too:

git submodule update --init

Fastest Fourier Transform in the West: FFTW

To allow comparison with FFTW http://www.fftw.org/, cmake option -DUSE_BENCH_FFTW=ON has to be used with following commands. The cmake option requires previous setup of following (debian/ubuntu) package:

sudo apt-get install libfftw3-dev

Intel Math Kernel Library: MKL

Intel's MKL https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html currently looks even faster than FFTW.

On Ubuntu-Linux it's easy to setup with the package intel-mkl. Similar on Debian: intel-mkl-full.

There are special repositories for following Linux distributions:

Performing the benchmarks - with CMake

Benchmarks should be prepared by creating a special build folder

mkdir build_benches
cd build_benches
cmake ../bench

There are several CMake options to parametrize, which fft implementations should be benched. You can explore all available options with cmake-gui or ccmake, see CMake.

Some of the options:

  • BENCH_ID name the benchmark - used in filename
  • BENCH_ARCH target architecture passed to compiler for code optimization
  • USE_BENCH_FFTW use (system-installed) FFTW3 in fft benchmark? (default: OFF)
  • USE_BENCH_GREEN use Green FFT in fft benchmark? (default: ON)
  • USE_BENCH_KISS use KissFFT in fft benchmark? (default: ON)
  • USE_BENCH_POCKET use PocketFFT in fft benchmark? (default: ON)
  • USE_BENCH_MKL use Intel MKL in fft benchmark? (default: OFF)

These options can be passed to cmake at command line, e.g.

cmake -DBENCH_ARCH=native -DUSE_BENCH_FFTW=ON -DUSE_BENCH_MKL=ON ../bench

The benchmarks are built and executed with

cmake --build .

You can also specify to use a different compiler/version with the cmake step, e.g.:

CC=/usr/bin/gcc-9 CXX=/usr/bin/g++-9 cmake -DBENCH_ID=gcc9 -DBENCH_ARCH=native -DUSE_BENCH_FFTW=ON -DUSE_BENCH_MKL=ON ../bench
CC=/usr/bin/clang-11 CXX=/usr/bin/clang++-11 cmake -DBENCH_ID=clang11 -DBENCH_ARCH=native -DUSE_BENCH_FFTW=ON -DUSE_BENCH_MKL=ON ../bench

For using MSVC/Windows, the cmake command requires/needs the generator and architecture options and to be called from the VS Developer prompt:

cmake -G "Visual Studio 16 2019" -A x64 ../bench/

see https://cmake.org/cmake/help/v3.15/manual/cmake-generators.7.html#visual-studio-generators

For running with different compiler version(s):

  • copy the result file (.tgz), e.g. cp *.tgz ../
  • delete the build directory: rm -rf *
  • then continue with the cmake step

Benchmark results and contribution

You might contribute by providing us the results of your computer(s).

The benchmark results are stored in a separate git-repository: See https://github.com/hayguen/pffft_benchmarks.

This is to keep this repositories' sources small.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].