MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたいが、 /usr/bin/clangが-fopenmpを受け付けてくれないので今のところうまくいかない。
$ sudo emacs /opt/local/etc/macports/sources.conf # add a line of "file:///Users/t-nissie/ports"
$ mkdir -p ~/ports/math/fftw-3/files
$ cd ~/ports/math/fftw-3
$ wget https://raw.githubusercontent.com/macports/macports-ports/master/math/fftw-3/Portfile
$ cd files
$ wget https://raw.githubusercontent.com/macports/macports-ports/master/math/fftw-3/files/patch-pfft.diff
$ wget https://raw.githubusercontent.com/macports/macports-ports/master/math/fftw-3/files/yosemite-libtool.patch
$ sudo mkdir -p /opt/local/var/macports/distfiles/fftw-3
$ emacs ~/ports/math/fftw-3/Portfile # add a line of "--enable-openmp \"
$ sudo cp patch-pfft.diff yosemite-libtool.patch /opt/local/var/macports/distfiles/fftw-3
$ sudo port selfupdate # instead of portindex
$ port install fftw-3 +gfortran # It fails because /usr/bin/clang cannot understand -fopenmp option.
NUMAのマシンで2つ以上のCPUチップにまたがってOpenMPを使う場合、 libfftw3_threadsよりlibfftw3_ompを使う方が高速にFFTできる。 逆にNUMAでない場合libfftw3_ompを使うご利益はあまりない。 ただしコンパチビリティ/互換性/可搬性の点からlibfftw3_ompはあった方がよい。
http://loto.sourceforge.net/feram/ を使って以前自分でインストールしたfftw-3.3.5をベンチマーク。 Macにfftw-3.3.5をソースから自分でインストールする方法は http://loto.sourceforge.net/feram/INSTALL.html の底の方に書いてある。
$ which fftw-wisdom
/usr/local/bin/fftw-wisdom
$ fftw-wisdom --version
fftw-wisdom tool for FFTW version 3.3.5.
$ tar xf feram-0.26.04.tar.xz
$ mkdir feram-0.26.04/Darwin-gfortran-7.2.0-fftw-3.3.5-omp
$ cd $_
$ ../configure --help
$ ../configure
$ cd src/
$ make -j5 feram_fftw_wisdom
$ otool -L feram_fftw_wisdom
feram_fftw_wisdom:
:
/usr/local/lib/libfftw3_omp.3.dylib (compatibility version 9.0.0, current version 9.5.0)
/usr/local/lib/libfftw3.3.dylib (compatibility version 9.0.0, current version 9.5.0)
:
$ ./feram_fftw_wisdom 10 128 128 128 1 FFTW_MEASURE
../../src/feram_fftw_wisdom.F:63: flags = FFTW_MEASURE
10 3 128 128 128 1 2097152 in 4 0.634 10.4
10 6 128 128 128 1 2097152 in 4 1.322 10.0
10 3 128 128 128 1 2097152 out 4 0.632 10.5
10 6 128 128 128 1 2097152 out 4 2.322 5.7
$ mkdir ../../Darwin-gfortran-7.2.0-fftw-3.3.5-threads
$ cd $_
$ ../configure --help
$ ../configure --with-fft=fftw3_threads
$ cd src
$ make -j5 feram_fftw_wisdom
$ otool -L feram_fftw_wisdom
feram_fftw_wisdom:
:
/usr/local/lib/libfftw3_threads.3.dylib (compatibility version 9.0.0, current version 9.5.0)
/usr/local/lib/libfftw3.3.dylib (compatibility version 9.0.0, current version 9.5.0)
:
$ ./feram_fftw_wisdom 10 128 128 128 1 FFTW_MEASURE # NUMAでないので結果は上にほぼ同じ