Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install OpenMP version in R (Mac OS) #1136

Closed
ddydng opened this issue Apr 21, 2016 · 3 comments
Closed

How to install OpenMP version in R (Mac OS) #1136

ddydng opened this issue Apr 21, 2016 · 3 comments

Comments

@ddydng
Copy link

ddydng commented Apr 21, 2016

Greetings.

I need some help in understanding the instructions for installing OpenMP version in R (Mac OS). The following statement is quiet confusing to me:

Set the Makevars file in highest piority for R.

The point is, there are three Makevars : ~/.R/Makevars, xgboost/R-package/src/Makevars, and /usr/local/Cellar/r/3.2.0/R.framework/Resources/etc/Makeconf (the last one obtained by running file.path(R.home("etc"), "Makeconf") in R), and SHLIB_OPENMP_CXXFLAGS is not set by default!! After trying, it seems that the first one has highest piority (surprise!).

What does it mean by "Set the Makevars file in highest piority for R"? How can I deal with the priority? What shall I do to set the "SHLIB_OPENMP_CXXFLAGS" variable?

@jimthompson5802
Copy link

re: Makevars...I made the changes in ~/.R/Makevars. In addition to the SHLIB flags, I had to change to compiler to "clang-omp". For the compiler I used brew to install the version of clang that supported OpenMP.

@ddydng
Copy link
Author

ddydng commented Apr 23, 2016

I finally get this to work by using following code modified from @jimthompson5802 's answer. The code is put into ~/.R/Makevars:

CC=gcc-5
CXX=g++-5
CXX1X = g++-5

SHLIB_OPENMP_CFLAGS= -fopenmp
SHLIB_OPENMP_CXXFLAGS= -fopenmp
SHLIB_OPENMP_FCFLAGS= -fopenmp
SHLIB_OPENMP_FFLAGS= -fopenmp

In my case R would search/Library/Frameworks/R.framework/Resources/etc/Makeconf for necessary parameters undefined in ~/.R/Makevars. It would try to find the setting for CXX1X in Makeconf. So that is where the clang++ complier come from in the errors in my previous post.

I get a bunch of [-Wunused-variable] warnings but I guess it's fine. No OpenMP is not available warning this time.

Also since I have followed the official building instructions for mac os, I have gcc installed and with it I successfully built the "main" xgboost with OpenMP before. Thus I suggets for anyone who have followed the same instructions like me have their Makevars set up like this.

@renkun-ken
Copy link

In my case, I have to set up more CXX to make it work:

CC=gcc-7
CXX=g++-7
CXX1X=g++-7
CXX11=g++-7
CXX14=g++-7
CXX17=g++-7

SHLIB_OPENMP_CFLAGS= -fopenmp
SHLIB_OPENMP_CXXFLAGS= -fopenmp
SHLIB_OPENMP_FCFLAGS= -fopenmp
SHLIB_OPENMP_FFLAGS= -fopenmp

@tqchen tqchen closed this as completed Jul 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants