[R] Enable OpenMP with AppleClang in XGBoost R package #5240
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up to #5232. This PR uses Autoconf to detect the availability of OpenMP library (
libomp
) on Mac OSX. This is done by compiling the following program with command${CC} -o conftest conftest.c /usr/local/lib/libomp.dylib -Xclang -fopenmp
:Implication: Now Mac users can simply run
install.packages('xgboost')
and enjoy the performance of multiple threads, as long as they first installlibomp
package from Homebrew.I tested this change as follows:
R CMD INSTALL .
on my Macbook Pro. A sample XGBoost training job runs with all 4 threads:libomp
Homebrew and ranR CMD INSTALL .
again. A prominent warning shows up, as I intended:Aside from the warning, XGBoost compiles successfully. The sample job ran without a problem, albeit this time with a single thread.
Note to reviewer: you should only review
configure.ac
. Theconfigure
script is generated fromconfigure.ac
whenautoconf
is run.