For data.table install, if you plan on using multiple threads, you have to enable it during installation/compilation. When loading the package, you will see a warning that says
data.table 1.x.x using 1 threads (see ?getDTthreads).
********
This installation of data.table has not detected OpenMP support. It should still work but in single-threaded mode. This is a Mac.
********
Just go to this link:
https://github.com/Rdatatable/data.table/wiki/Installation
0. May need to install gfortran
brew install gfortran
and these lines are needed in ~/.R/makevars file:
LDFLAGS += -L/opt/homebrew/opt/libomp/lib -lomp
CPPFLAGS += -I/opt/homebrew/opt/libomp/include -Xclang -fopenmp
1.
curl -O https://mac.r-project.org/openmp/openmp-16.0.4-darwin20-Release.tar.gz
sudo tar fvx openmp-16.0.4-darwin20-Release.tar.gz -C /
This command will put these files in /usr/local/lib and /usr/local/include
You can inspect the downloaded tar.gz file by uncompressing it and see how it is structured.
2.
PKG_CPPFLAGS='-Xclang -fopenmp' PKG_LIBS=-lomp R CMD INSTALL /Users/ashish/downloads/data.table-1.15.4.tar.gz
Just use the above command to install it with flags to detect the openMP install.
Next time you use the package, it should use multiple threads. Check this under R prompt after loading data.table package:
library(data.table)
getDTthreads()
No comments:
Post a Comment