OpenMP Support in Xcode 5 and later
I have a proprietary library (>150,000 lines) of quantum mechanics C++ code that relies on OpenMP for parallisation. This code used to compile fine with Xcode 4.6 and its' real GCC compiler, but the LLVM compiler that ships with Xcode 5 doesn't seem to support OpenMP. My code is developed on a Mac but needs to be portable to non-Apple hardware such as massively parallel supercomputers, so re-writing the code is not an option. Does anyone know of a suitable compiler that can be used? Many thanks for any help.
I come back from my comment as I tested hpc.sourceforge.net and it is working like a charm for me.
Simply untar the archive as explained:
sudo tar -xvf gcc-4.8-bin.tar -C /
Update your .profile to use by default the hpc compiled version of gcc if you want.
Compile your program with option -fopenmp then link it with option -lgomp.
“Does anyone know of a suitable compiler that can be used?”
The Intel compilers on MacOS support OpenMP, as they do on other platforms.
Of course, they cost money, but they may be worth it.
(Full disclosure: I work for Intel on the OpenMP runtime used by the compiler)
See Clang + OpenMP Setup in Xcode. The steps are basically:
- Install Homebrew.
- Install llvm with
brew install llvm.
- “Build Settings” and then “Editor” » “Add Build Setting” » “Add User-Defined Setting” with key of
CCand value of
- Search for “Enable Modules” and turn that off.
/usr/local/opt/llvm/libto “Library Search Paths”.
/usr/local/opt/llvm/lib/clang/7.0.1/includeto “Header Search Paths”. (The version number may vary based upon your installation.)
-fopenmpcompilation flag to “Other C Flags”.
- Turn off “Enable Index-While-Building Functionality”.
/usr/local/opt/llvm/lib/libiomp5.dylibto “Build Phases” » “Link Binary with Libraries”.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News