Does BLAS / ATLAS / MKL / OPENBLAS accelerate the R package written in C / C ++?

I found that using one of BLAS / ATLAS / MKL / OPENBLAS would give speed improvement in R. However, would it improve R package that is written in C or C ++? for example, R Glmnet is implemented in FORTRAN and R. rpart is implemented in C ++. Will only install BLAS / ... etc. Will Improve Lead Time? or do we need to rebuild (create new C code) a BLAS / ... based package etc.

+3


source to share


1 answer


It is often said, including in a comment here, that "you need to recompile R" to use a different BLAS or LAPACK library. It is not right.

You don't need to recompile R as long as it's built against the BLAS and LAPACK shared library versions.



I have a package and vignette on CRAN that takes advantage of this fact to provide a base platform where different BLAS and LAPACK versions are timed to each by simply installing different (one command in Debian / Ubuntu) and running tests - it's so easy that its can be automated in such a package.

The results from this package will provide an indication of possible speed differences. Exactly how they work depends on your computer, your data (size), your problem, etc. But if, say, your problem is using LAPACK functions that can take advantage of multithreading, then installing OpenBLAS might help. This is true for any R package that uses LAPACK, since they will use the same LAPACK installation that is being accessed and are subject to change.

+9


source







All Articles