OS X OpenMP older instructions - PetaVision/OpenPV GitHub Wiki
This page gives alternate instructions for installing OpenMP on Macs whose Apple-supplied compilers do not yet support OpenMP. We prefer the main instructions but if you run into problems with OpenMP using those instructions, you might try these instructions instead.
The difference between the instructions on this page and the main page is that,
instead of using sudo make install for the OpenMP library, additional lines are
added to ~/.bash_profile or ~/.profile.
###Install the OMP-compatible version of Clang (this part agrees with the main instructions) ###############
Download the most recent pre-built binary for Mac OS X from http://llvm.org/releases/download.html.
Make a note of the location of the downloaded file and the filename. In what follows, we will
be using the filename clang+llvm-3.7.0-x86_64-apple-darwin.tar.xz, the most recent version as of
this writing; modify as necessary. To extract the downloaded .xz file using the command line,
you will need the xz program, which can be installed using Homebrew.
brew install xz
cd ${HOME}
mkdir clang_omp
cd clang_omp
cp /path/to/clang+llvm-3.7.0-x86_64-apple-darwin.tar.xz .
unxz clang+llvm-3.7.0-x86_64-apple-darwin.tar.xz
tar xf clang+llvm-3.7.0-x86_64-apple-darwin.tar
cd clang+llvm-3.7.0-x86_64-apple-darwin/bin
ln -s clang cc
ln -s clang++ c++
###Install the OMP library ###############
Download the most recent version of the Intel OpenMP Runtime Library from https://www.openmprtl.org/download#stable-releases.
Make a note of the location of the downloaded file. In what follows, we will be using libomp_20151009_oss.tgz,
the most recent version as of this writing; modify as necessary.
cd ${HOME}/clang_omp
tar xf /path/to/libomp_20151009_oss.tgz
cd libomp_oss
cmake .
make
Note that there is no sudo make install command. Instead of copying the
header and library files into /usr/local, we will modify environmental variables
so that the OMP-compatible clang finds the needed header and library files.
###Update necessary environmental variables ###############
Open your ~/.bash_profile (or ~/.profile, whichever one you use) and append these lines to the end of the file:
export PATH=$HOME/clang_omp/clang+llvm-3.7.0-x86_64-apple-darwin/bin:$PATH
export C_INCLUDE_PATH=$HOME/clang_omp/clang+llvm-3.7.0-x86_64-apple-darwin/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$HOME/clang_omp/clang+llvm-3.7.0-x86_64-apple-darwin/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=$HOME/clang_omp/clang+llvm-3.7.0-x86_64-apple-darwin/lib:$LIBRARY_PATH
export DYLD_LIBRARY_PATH=$HOME/clang_omp/clang+llvm-3.7.0-x86_64-apple-darwin/lib:$DYLD_LIBRARY_PATH
export C_INCLUDE_PATH=$HOME/clang_omp/libomp_oss/exports/common/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$HOME/clang_omp/libomp_oss/exports/common/include:$CPLUS_INCLUDE_PATH
export LIBRARY_PATH=$HOME/clang_omp/libomp_oss/exports/mac_32e/lib.thin:$LIBRARY_PATH
export DYLD_LIBRARY_PATH=$HOME/clang_omp/libomp_oss/exports/mac_32e/lib.thin:$DYLD_LIBRARY_PATH
If you have any open terminal windows, run source ~/.bash_profile in each of them.
Test by running which clang and which clang++ to verify that clang and clang++ resolve
to the versions just installed.
When you run cmake or ccmake, you will need to set PV_OPENMP_COMPILER_FLAG to "-fopenmp=libiomp5" to have the compiler look for the OpenMP Runtime library.