Skip to content

check for systems pre-configured to use OpenMP - #294

Merged
eddelbuettel merged 1 commit into
masterfrom
feature/openmp-detect-macos
May 5, 2020
Merged

eddelbuettel merged 1 commit into
masterfrom
feature/openmp-detect-macos

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Closes #290.

With this PR, RcppArmadillo should enable OpenMP if it detects that OpenMP appears to work "out of the box", without any extra flags. Output on my machine:

kevinushey@Kevins-MBP:~/r/pkg/RcppArmadillo [feature/openmp-detect-macos]
$ R CMD config CPPFLAGS && R CMD config LDFLAGS && R CMD INSTALL --preclean .
-I/usr/local/opt/libomp/include -Xclang -fopenmp
-L/usr/local/lib -L/usr/local/opt/libomp/lib -lomp
* installing to library ‘/Users/kevinushey/Library/R/4.0/library’
* installing *source* package ‘RcppArmadillo’ ...
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -mmacosx-version-min=10.13 -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... clang++ -mmacosx-version-min=10.13 -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ -mmacosx-version-min=10.13 -std=gnu++11 accepts -g... (cached) yes
checking whether R can compile programs using OpenMP already... yes
checking LAPACK_LIBS... R-supplied partial LAPACK found
configure: WARNING: Some complex-valued LAPACK functions may not be available
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/kevinushey/Library/R/4.0/library/Rcpp/include' -I/usr/local/opt/libomp/include -Xclang -fopenmp  -I../inst/include  -fPIC  -Wall -g -O2  -c RcppArmadillo.cpp -o RcppArmadillo.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/kevinushey/Library/R/4.0/library/Rcpp/include' -I/usr/local/opt/libomp/include -Xclang -fopenmp  -I../inst/include  -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/kevinushey/Library/R/4.0/library/Rcpp/include' -I/usr/local/opt/libomp/include -Xclang -fopenmp  -I../inst/include  -fPIC  -Wall -g -O2  -c fastLm.cpp -o fastLm.o
clang++ -mmacosx-version-min=10.13 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -L/usr/local/opt/libomp/lib -lomp -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/Cellar/gcc/9.3.0_1/lib/gcc/9/gcc/x86_64-apple-darwin19/9.3.0/../../.. -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/kevinushey/Library/R/4.0/library/00LOCK-RcppArmadillo/00new/RcppArmadillo/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (RcppArmadillo)

This PR works by just calling R CMD SHLIB on a C++ script using OpenMP. If we can compile and link that file directly, then we can skip the other OpenMP checks.

Comment thread .gitignore
.Rproj.user
.Rhistory
.RData
inst/include/RcppArmadilloConfigGenerated.h

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because these are generated by their corresponding .in files, I think we can just .gitignore them.

Comment thread configure.ac
can_use_openmp="no"

## Check if R is configured to compile programs using OpenMP out-of-the-box.
AC_MSG_CHECKING([whether R can compile programs using OpenMP already])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That trailing 'already' looks a little wooden, I may reword that 'eventually',

Comment thread configure.ac
fi

## Use R to set CXX and CXXFLAGS
R=${R_HOME}/bin/R

@eddelbuettel eddelbuettel May 5, 2020 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One can do this, and then use R as below, I found it helpful to to keep the longer ${R_HOME}/bin/R
to remind myself of the many time KH had to remind me to not use use R from the path. So weak personal preference for the longer form.

@eddelbuettel
eddelbuettel merged commit f29a24f into master May 5, 2020
@eddelbuettel

eddelbuettel commented May 5, 2020 •

Copy link
Copy Markdown
Member

It also leaves three files around, we may want to remove those straight from configure.ac once
the right variable is set.

In other words, for me TMPDIR is empty by default so that dance over there does not happen :-/

@eddelbuettel
eddelbuettel deleted the feature/openmp-detect-macos branch May 6, 2020 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RcppArmadillo with macOS and OpenMP In a Post R 4.0.0 World

2 participants