6

The BLAS section in R installation and administration manual says that when R is built from source, with configuration parameter --without-blas, it will build Netlib's reference BLAS into a standalone shared library at R_HOME/lib/libRblas.so, along side the standard R shared library R_HOME/lib/libR.so. This makes it easier for user to switch and benchmark different tuned BLAS in R environment. The guide suggests that researcher might use symbolic link to libRblas.so to achieve this, and this article gives more details on this.

On contrary, when simply installing a pre-compiled binary version of R, either from R CRAN's mirrors or Ubuntu's repository (for linux user like me), in theory it should be more difficult to switch between different BLAS without rebuilding R, because a pre-compiled R version is configured with --with-blas = (some blas library). We can easily check this, either by reading configuration file at R_HOME/etc/Makeconf, or check the result of R CMD config BLAS_LIBS. For example, on my machine it returns -lblas, so it is linked to reference BLAS at build time. As a result, there is no R_HOME/lib/libRblas.so, only R_HOME/lib/libR.so.

However, this R-blog says that it is possible to switch between difference BLAS, even if R is not installed from source. The author tried the ATLAS and OpenBLAS from ubuntu's repository, and then use update-alternatives --config to work around. It is also possible to configure and install tuned BLAS from source, add them to "alternatives" through update-alternatives --install, and later switch between them in the same way. The BLAS library (a symbolic link) in this case will be found at /usr/lib/libblas.so.3, which is under both ubuntu and R's LD_LIBRARY_PATH. I have tested and this does work! But I am very surprised at how R achieves this. As I said, R should have been tied to the BLAS library configured at building time, i.e., I would expect all BLAS routines integrated into R_HOME/lib/libR.so. So why is it still possible to change BLAS via /usr/lib/libblas.so.3?

Thanks if someone can please explain this.

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
  • 1
    I once tried to explain all this in [this vignette](https://cloud.r-project.org/web/packages/gcbd/vignettes/gcbd.pdf) to the [gcbd](https://cloud.r-project.org/web/packages/gcbd/index.html) package. On Debian and Ubuntu is just works as seen by that package... – Dirk Eddelbuettel May 04 '16 at 20:15
  • I don't have time to debug your local issue, nor do I have enough information but I would think that something goes wrong with your setup / `configure` options. Make sure you _also_ request dynamic linking. – Dirk Eddelbuettel May 04 '16 at 20:41
  • This can be hair-splittingly complicated. Maybe one easier bet for you would be to replicate something a la gbcd on a Debian/Ubuntu box and then try to insert your locally built R to test the setup. Good luck! – Dirk Eddelbuettel May 04 '16 at 21:04

0 Answers0