william
william

Reputation: 131

OpenMP, R and MacOS

so I try to run a package called BTYDplus when I load it I got this warning

This data.table install has not detected OpenMP support. It will work but slower in single threaded mode.

I could run it without OpenMP but it is very slow, so I tried to install openMP by following this tutorial http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/ but I stuck at Enabling R to Compile Code with OpenMP on OS X part specifically when I try to run vim ~/.R/Makevars/. It resulted with "~/.R/Makevars/" Illegal file name.

any suggestion on how to tell R to use GCC ?

Upvotes: 13

Views: 5337

Answers (2)

Andrew M
Andrew M

Reputation: 540

Although it is possible to get openmp compilation working on a Mac Sierra by updating clang (not sure if newer versions of MacOS have fixed this by updating clang) as in Enable OpenMP support in clang in Mac OS X (sierra) it is also possible to get Apple's default clang to work. Simple add the following to ~/.R/Makevars

SHLIB_OPENMP_CFLAGS=-Xpreprocessor -fopenmp
SHLIB_OPENMP_CXXFLAGS=-Xpreprocessor -fopenmp

This takes advantage of special CXX/CFLAGS R packages ought to use when compiling OpenMP packages, and that

Apple Clang does allow you to process the OpenMP pragmas with -Xpreprocessor -fopenmp, and then you can manually link to the OpenMP library.

More details here.

Upvotes: 2

user9478968
user9478968

Reputation:

If you are using clang to compile OpenMP code you will need libomp. I found the easiest way to get it is through homebrew with brew install libomp.

Upvotes: 2

Related Questions