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 installsequence. But I couldn't initially find theconfiguresettings 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
./configureline:For double precision:
./configure --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avxFor single precision:
./configure --enable-single --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avxFor long double precision:
./configure --enable-long-double --enable-shared --disable-debug --enable-threads --disable-dependency-tracking --enable-sse2 --enable-avxOn my virtual MacOSX system, I don't have avx2 apparently, as the following command (in a MacOSX terminal)
sysctl -a | grep machdep.cpu.featuresgave 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.0So I didn't include the
--enable-avx2configure 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.exetest 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
benchexecutable is always namedbenchand found in thetestssubdirectory.
So before starting the build for a different precision, you need to rename thebenchbinary to e.g.benchfandbenchlyourself. 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 }