[R-sig-Debian] Compiling R-2.11.0 with ATLAS-tuned BLAS and LAPACK
Dirk Eddelbuettel
edd at debian.org
Thu Jun 3 20:16:52 CEST 2010
On 2 June 2010 at 17:27, Paul Johnson wrote:
| Question: How does the R executable know which BLAS shared library to use.
|
| Answer: It uses whatever so name it was told to use at build time, and
| the dynamic linking mechanism of the OS helps it find the file.
The first matching entry wins, similar to how PATH is search, or how R uses
.libPaths()
| If you build R with a configure option that tells it to use an
| external BLAS like atlas and you do not have --enable-BLAS-shlib
| specified, then no libRblas.so is created, the R executable will look
| for the specific location of the BLAS library that it found at compile
| time.
|
| Here's what I see with the deb packages from CRAN
|
| $ ldd /usr/lib/R/bin/exec/R
| linux-vdso.so.1 => (0x00007fff9c9ff000)
| libR.so => /usr/lib/libR.so (0x00007fcfe9550000)
| libc.so.6 => /lib/libc.so.6 (0x00007fcfe91ce000)
| libblas.so.3gf => /usr/lib/libblas.so.3gf (0x00007fcfe8f32000)
|
| In Ubuntu 10.04 (lucid), the installation of R from CRAN (r-base,
| r-base-core, etc) causes the installation of the addon packages
| "libblas-dev" and "libblas3gf" and you see above that R is linked
| against it.
Sort of. libblase-dev comes from r-base-dev and is meant for compiling and
linking (eg when installing CRAN packages from source) but not needed just
to run R.
| In theory, according to README.Atlas.gz, it should be possible to have
| several BLAS library collections installed at once.
Yes. Just how you can have 'foo' in /bin, /usr/bin, /usr/local/bin, ~/bin,
/opt/foo/bin, ... etc pp
| From Atlas, we
| could have "base","sse", and "sse2". The docs say "sse2" is best.
sse, sse2, ... are old names that atlas package of yore used.
These days, on i386/amd64 we onl have atlas-base.
[...]
| Clearly, there is some dynamic linking "magic" going on so that the
| system knows which libatlas3gf.so.to use when R asks for it. I have
| not seen this before, were 2 identically named so files exist. But
| check the output of
|
| $ /sbin/ldconfig -p
|
|
| libblas.so.3gf (libc6,x86-64) => /usr/lib/atlas/libblas.so.3gf
| libblas.so.3gf (libc6,x86-64) => /usr/lib/libblas.so.3gf
|
| Hm. 2 libraries with the exact same name, the one in the atlas
| directory is found first, so R uses it. If I remove libatlas3gf-base,
| then, of course, the only one that is found is from libblas3gf.
Same as with PATH. No magic.
| Question: How can one experiment with other versions of BLAS?
|
| Answer: Either replace the file /usr/lib/libblas.so.3gf with some
| other shared object file, or rebuild R using --enable-BLAS-shlib and
| replace that.
Use LD_CONFIG_PATH or files *.conf in /etc/ld.so.conf.d/.
Besides Goto BLAS, you may also enjoy the (multithreaded-by-default) Intel
MKL Blas you can get via Ubuntu's 'revolution-mkl' package for amd64 and i386.
Hth.
--
Regards, Dirk
More information about the R-SIG-Debian
mailing list