FFTW on MacOS: configure arguments
-
This is not a question, just for reference for people who want to use FFTW in their Qt projects.
In Windows:
Although I am a MSVC user in Windows, I couldn't find the correct compile arguments to equal the benchmark performance of the pre-compiled binaries found on the fftw.org site, so I used MinGW64 (provided by MSYS2) to build the binaries. This is very easy using the BUILD-MINGW32.sh and BUILD-MINGW64.sh script files they provide. The compile settings therein resulted in DLLs that slightly exceeded the reference benchmarks set by the official pre-compiled Windows binaries.On MacOS X, building is again very easy with the
./configure && make && sudo make install
sequence. But I couldn't initially find theconfigure
settings to use on MacOS.
I found them by peeking into the Brew "formula" for the fftw package found here:
https://github.com/Homebrew/homebrew-core/blob/master/Formula/fftw.rb.In there, it is easy to see that you can use the following
./configure
line:For double precision:
./configure --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avx
For single precision:
./configure --enable-single --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avx
For long double precision:
./configure --enable-long-double --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avx
On my virtual MacOSX system, I don't have avx2 apparently, as the following command (in a MacOSX terminal)
sysctl -a | grep machdep.cpu.features
gave me this output:
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS MMX FXSR SSE SSE2 SS HTT SSE3 PCLMULQDQ MON SSSE3 CX16 SSE4.1 SSE4.2 x2APIC POPCNT VMM PCID XSAVE OSXSAVE AVX1.0
So I didn't include the
--enable-avx2
configure option in the above, but maybe your Mac machine has it, so you should include it.Building with those settings gave me nearly the same benchmark performance on my MacOS X Virtual machine as natively on my Windows machine.
-
An additional note: on Windows, the BUILD-MINGW32.sh and BUILD-MINGW64.sh script files take care of building all the configurations and giving the different
bench.exe
test programs different names for the different builds (single, double, long double).When building on MacOS X, using the simple steps above, the libraries for the different precisions are automatically named differently, but the
bench
executable is always namedbench
and found in thetests
subdirectory.
So before starting the build for a different precision, you need to rename thebench
binary to e.g.benchf
andbenchl
yourself. Or create a script file to do all the build & renaming for you.Finally, in your .pro file, add something like:
msvc { INCLUDEPATH += "E:\msys64\home\user\fftw-3.3.5\mingw64\include" LIBS += -L"E:\msys64\home\user\fftw-3.3.5\mingw64\bin" -lfftw3f-3 -lfftw3-3 } macx { INCLUDEPATH += "/usr/local/include" LIBS += -L"/usr/local/lib" -lfftw3 -lfftw3f }