Skip to content

Instantly share code, notes, and snippets.

@t-nissie
Last active February 12, 2018 10:30
Show Gist options
  • Save t-nissie/e6a547c401557bb3496f7c512e314d9e to your computer and use it in GitHub Desktop.
Save t-nissie/e6a547c401557bb3496f7c512e314d9e to your computer and use it in GitHub Desktop.
MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたい

MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたい

MacPortsのmath/fftw-3のconfigureオプションに--enable-openmpを加えたいが、 /usr/bin/clangが-fopenmpを受け付けてくれないので今のところうまくいかない。

手元 (local) でmath/fftw-3/Portfileを変更してみる

MacPortsで自家製portsを使う方法を参考に。

$ 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.

以前自分でインストールしたfftw-3.3.5をベンチマーク

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でないので結果は上にほぼ同じ
/* -*-CSS-*-
* style.css for README.html of feram
* Time-stamp: <2014-08-26 15:50:24 takeshi>
* Author: Takeshi NISHIMATSU
*/
body {
color: black;
font-family: verdana, arial, helvetica, sans-serif;
}
h1, h2, h3, h4, h6 {
font-family: verdana, arial, helvetica, sans-serif;
}
h1 {
color: #dd0000;
background-color: #fff0f0;
font-size: 230%;
}
h2 {
border-top: red 5px solid;
border-bottom: red 1px solid;
padding-left: 8px;
background-color: #fff0f0;
}
h3 {
border-top: red 2px solid;
border-bottom: red 1px solid;
padding-left: 4px;
}
h4 {
border-top: red 1px solid;
padding-left: 4px;
background-color: #fff0f0;
}
h5 {
font-size: larger;
font-family: courier, verdana, arial, helvetica, sans-serif;
padding-top: 10px;
color: darkred;
}
pre {
font-family: monospace, courier, verdana, arial, helvetica, sans-serif;
font-size: 120%;
padding-right: 0.5em;
padding-left: 0.5em;
padding-top: 0.1ex;
padding-bottom: 0.1ex;
margin-left: 0.5em;
margin-right: 1.0em;
white-space: pre;
color: darkred;
background-color: #f3f3f3;
}
p img {
width: 32%;
margin: auto;
display: block;
}
div.figure div.figcaption {
width: 60%;
margin: auto;
display: block;
}
div.navi {
text-align: right;
margin-right: 1.0em;
}
div.contents {
margin-left: 10%;
}
img{
width: 30%;
margin: auto;
margin-top: 3.0em;
display: block;
}
figure figcaption{
width: 60%;
margin: auto;
margin-bottom: 3.0em;
display: block;
}
table{
border-top: 1px solid;
border-left: 1px solid;
border-collapse: collapse;
border-spacing: 0;
empty-cells: show;
text-align: center;
margin: auto;
}
th{
border-right: 1px solid;
border-bottom: 1px solid;
background-color: #fff0f0;
padding: 0.3em 1em;
}
td{
border-right: 1px solid;
border-bottom: 1px solid;
padding: 0.3em 1em;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment