rstudio / r-builds

an opinionated environment for compiling R
GNU General Public License v3.0
100 stars 19 forks source link

Use FlexiBLAS on RHEL 9 for R 4.3.0 and above #163

Closed glin closed 1 year ago

glin commented 1 year ago

Resolves https://github.com/rstudio/r-builds/issues/154

Switch to externally-linked FlexiBLAS on RHEL 9 for compatibility with EPEL R, starting from R 4.3.0. FlexiBLAS defaults to OpenBLAS-OpenMP (and can be used to swap to any other BLAS), so it's not a huge change from the currently used OpenBLAS-pthreads.

R 4.2.3 and below continue to use shared BLAS (OpenBLAS) for backward compatibility.

I didn't change anything for RHEL 8 because EPEL 8 R's new BLAS configuration is no longer swappable, and I figured it was better to keep the flexibility/consistency.

For testing, CI should pass, and I've done some manual testing to confirm that R devel/4.3.0 now links to FlexiBLAS, and R 4.2.3 still links to R's internal BLAS:

$ /opt/R/devel/bin/R -s -e 'sessionInfo()'
R Under development (unstable) (2023-04-18 r84280)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Rocky Linux 9.0 (Blue Onyx)

Matrix products: default
BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP;  LAPACK version 3.9.0

$ ldd /opt/R/devel/lib/R/lib/libR.so | grep blas
    libflexiblas.so.3 => /lib64/libflexiblas.so.3 (0x00007fdc3815f000)

$ /opt/R/devel/bin/R CMD config BLAS_LIBS
-lflexiblas

$ /opt/R/devel/bin/R CMD config LAPACK_LIBS
-lflexiblas
$ /opt/R/4.2.3/bin/R CMD config BLAS_LIBS
-L/opt/R/4.2.3/lib/R/lib -lRblas

$ /opt/R/4.2.3/bin/R CMD config LAPACK_LIBS
-L/opt/R/4.2.3/lib/R/lib -lRlapack