Xgboost: How to install OpenMP version in R (Mac OS)

Created on 22 Apr 2016  ·  3Comments  ·  Source: dmlc/xgboost

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?

Most helpful comment

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

All 3 comments

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.

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.

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

RanaivosonHerimanitra picture RanaivosonHerimanitra  ·  3Comments

matthewmav picture matthewmav  ·  3Comments

colinsongf picture colinsongf  ·  4Comments

XiaoxiaoWang87 picture XiaoxiaoWang87  ·  3Comments

vkuznet picture vkuznet  ·  3Comments