Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is OpenMP available in High Sierra LLVM?

In the default LLVM provided by Apple in macOS 10.13, High Sierra, is OpenMP finally available? It has been available in main LLVM for more than a year now.

(another way to ask the question might be what version of LLVM is the new Apple LLVM based on)

like image 224
Henry Schreiner Avatar asked Jun 06 '17 02:06

Henry Schreiner


2 Answers

Standard Apple's clang supports OpenMP. They just disabled the driver option. But you can use the frontend option instead this way: clang -Xclang -fopenmp <you_program> -I <path to omp.h> -L <path to libomp.dylib> -lomp

Also, you need to set DYLD_LIBRARY_PATH environmental variable: export DYLD_LIBRARY_PATH=<path to libomp.dylib>

How to get/build libomp.

$ cd
$ svn co http://llvm.org/svn/llvm-project/openmp/trunk libomp
$ cd libomp
$ mkdir build && cd build
$ cmake -DCMAKE_INSTALL_PREFIX=~/libomp/openmp
$ make && make install

After this directory ~/libomp/openmp will have 2 subdirs: include and lib, which should be used as the path to omp.h and the path to libomp.dylib correspondingly.

See also my answer to Is C++ compilable with OpenMP and boost on MacOS?

like image 114
Alexey Bataev Avatar answered Oct 31 '22 23:10

Alexey Bataev


No, it is not (officially). The Apple LLVM is roughly based on 4.0, but the OpenMP module is left out. You can even see a remaining OpenMP option in the help to set offloading targets, but it does not support OpenMP.

$ clang++ --help | grep openmp
  -fopenmp-targets=<value>

Apple, adding OpenMP would be a huge boon to science researchers!

Note: Brew has support for building the OpenMP library! Use:

brew install libomp

A patch has been accepted into CMake that will allow users to get the correct compile and linking line OpenMP in CMake 3.12 if they use the targets system.

like image 27
Henry Schreiner Avatar answered Nov 01 '22 01:11

Henry Schreiner