Quote:
Originally Posted by Geist
Do I enable or disable this to use the openBLAS library I have on my system?
|
If you build R with the SlackBuild variable R_SHLIB set to yes then R builds its own libRblas.so in /usr/lib64/R/lib and /usr/lib64/R/bin/exec/R links with this:
Code:
/usr/lib64/R/bin/exec> objdump -x R | grep NEED
NEEDED libR.so
NEEDED libRblas.so
NEEDED libgomp.so.1
NEEDED libpthread.so.0
NEEDED libc.so.6
VERNEED 0x0000000000400768
VERNEEDNUM 0x0000000000000001
If you build with R_SHLIB set to no then it doesn't built any optimised BLAS library.
If, like me, you have OpenBLAS installed then you need to change the contents of blas_shlib in the Slackbuild from this
Code:
blas_shlib="--enable-BLAS-shlib"
to this
Code:
blas_shlib="--with-blas --with-lapack"
You can also add an "else" condition that checks for the openblas_config header file, which is what I do. If you build with the above modification you don't get /usr/lib64/R/bin/exec/R linked with an internal blas library:
Code:
/usr/lib64/R/bin/exec> objdump -x R | grep NEED
NEEDED libR.so
NEEDED libgomp.so.1
NEEDED libpthread.so.0
NEEDED libc.so.6
VERNEED 0x0000000000400760
VERNEEDNUM 0x0000000000000001
However libR.so is now linked with your external OpenBLAS library:
Code:
/usr/lib64/R/lib> ldd libR.so
linux-vdso.so.1 (0x00007fff66be7000)
libopenblas.so.0 => /usr/lib64/libopenblas.so.0 (0x00007f1a81772000)
libgfortran.so.5 => /usr/lib64/libgfortran.so.5 (0x00007f1a812b6000)
..
..
..
Code:
ls -lA /usr/lib64/libopenblas.so*
lrwxrwxrwx 1 root root 22 Jul 18 11:42 /usr/lib64/libopenblas.so -> libopenblasp-r0.3.6.so
lrwxrwxrwx 1 root root 22 Jul 18 11:42 /usr/lib64/libopenblas.so.0 -> libopenblasp-r0.3.6.so
Addendum:
It seems that you can also just append "--with-blas --with-lapack" to blas_shlib="--enable-BLAS-shlib" and then R is built with a libRblas.so that is linked with libopenblas.
Code:
Package R-3.6.0_icu4c64.2-x86_64-1 upgraded with new package /tmp/R-3.6.0_icu4c64.2_openblas0.3.6-x86_64-1.txz.
/usr/lib64/R/bin/exec> objdump -x R | grep NEED
NEEDED libR.so
NEEDED libRblas.so
NEEDED libgomp.so.1
NEEDED libpthread.so.0
NEEDED libc.so.6
VERNEED 0x0000000000400768
VERNEEDNUM 0x0000000000000001
/usr/lib64/R/bin/exec> ldd ../../lib/libRblas.so
linux-vdso.so.1 (0x00007ffe1f5fe000)
libopenblas.so.0 => /usr/lib64/libopenblas.so.0 (0x00007f7c91924000)
I think some benchmarks would be required to determine the outcome of the build methods at this point. One thing I don't like about this result is that it links with the older libgfortran.so.4 (I made a compat package from gcc-7.3 because various math libraries as well as Octave link with libgfortran) for some reason instead of linking with libgfortran.so.5 which is what libgfortran.so points to.