User Tools

Site Tools


r

This is an old revision of the document!


R

The “R” statistical package is installed on the Razor cluster. We recommend the 3.3.1 version.

Here we have a quick benchmark for an older installed version of R that should be using MKL blas. It takes 413 elapsed seconds and is actually running the slow reference blas.

$ module purge; module load gcc/4.6.3 mkl/13.1.0 R/3.1.2-mkl
$ R -f bench2.r
R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
...
> set.seed(123)
> X <- Matrix(rnorm(9e6), 3000)
> print(system.time(for(i in 1:25) solve(X)))
   user  system elapsed 
411.935   0.382 413.278 

A newer version of R with the MKL blas properly linked is about 9 times faster in elapsed time.

$ export MKL_NUM_THREADS=1
$ R -f bench2.r
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
...
> set.seed(123)
> X <- Matrix(rnorm(9e6), 3000)
> print(system.time(for(i in 1:25) solve(X)))
   user  system elapsed 
 47.278   0.405  48.181 

With maximum threading it is another factor of 6 times faster.

$ export MKL_NUM_THREADS=16
$ R -f bench2.r
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
...
> set.seed(123)
> X <- Matrix(rnorm(9e6), 3000)
> print(system.time(for(i in 1:25) solve(X)))
   user  system elapsed 
132.876   2.945   8.536 

The program is very simple and actual programs will not show such dramatic speedups, but it is still very worthwhile to have the right version and threading for the computer you are using.

$ cat bench2.r
require(Matrix)
set.seed(123)
X <- Matrix(rnorm(9e6), 3000)
print(system.time(for(i in 1:25) solve(X)))

Installation of recent R versions on Centos-6 is involved, as multiple packages need to be updated first, and the procedure is mostly undocumented, so the installation needs to be derived from the error messages of a failed installation.

yum install libXt-devel libssh2-devel openssl-devel
/share/apps/zlib/zlib-1.25 already installed
cd temp-install-directory
wget http://tukaani.org/xz/xz-5.2.2.tar.gz
tar zxf xz-5*gz
cd xz-5.2.2
./configure --prefix=/share/apps/xz/5.2.2
make && make install

cd ..
wget https://sourceforge.net/projects/pcre/files/latest/download?source=files
mv down*es pcre-8.39.tar.bz2
tar jxf pcre*2
cd pcre-8.39
./configure --prefix=/share/apps/pcre/8.39 --enable-utf
make && make install

cd ..
wget https://curl.haxx.se/download/curl-7.50.0.tar.gz
tar zxf curl*gz
cd curl-7.50.0
./configure --prefix=/share/apps/curl/7.50.0 --with-zlib=/share/apps/zlib/zlib-1.25 --enable-libcurl-option --with-ssl=/usr/include/ssl --enable-http --with-libssh2
make && make install

cd ..
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar zxf bzip*gz
cd bzip2-1.0.6
vi Makefile (add -fPIC to cflags)
make install PREFIX=/share/apps/bzip2/1.0.6

cd ..
wget https://cran.r-project.org/src/base/R-3/R-3.3.1.tar.gz
tar zxf R-3.3.1.tar.gz
cd R-3.3.1
module load intel/14.0.3 mkl/14.0.3
IOPT="-O3 -xsse4.2 -axavx"
FC=ifort CC=icc CXX=icpc FCFLAGS="$IOPT" CFLAGS="-I/share/apps/zlib/zlib-1.2.5/include -I/share/apps/bzip2/1.0.6/include -I/share/apps/xz/5.2.2/include -I/share/apps/pcre/8.39/include -I/share/apps/curl/7.50.0/include  $IOPT" CXXFLAGS="$IOPT" ./configure --prefix=/share/apps/R/R-3.3.1/intel-14.0.3 --with-blas=no --with-lapack=no --enable-R-shlib --with-x --with-recommended-packages --with-tcltk CFLAGS="-I/share/apps/zlib/zlib-1.2.5/include -I/share/apps/bzip2/1.0.6/include -I/share/apps/xz/5.2.2/include -I/share/apps/pcre/8.39/include -I/share/apps/curl/7.50.0/include  $IOPT" LDFLAGS="-L/share/apps/zlib/1.2.5/lib -L/share/apps/bzip2/1.0.6/lib -L/share/apps/xz/5.2.2/lib -L/share/apps/pcre/8.39/lib -L/share/apps/curl/7.50.0/lib -Wl,-rpath-link,/share/apps/pcre/8.39/lib -Wl,-rpath-link,/share/apps/xz/5.2.2/lib -L$MKLROOT/intel64 -lmkl_lapack95_lp64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -liomp5"
make && make install
r.1469136119.txt.gz · Last modified: 2016/07/21 21:21 by root