Compiling r with mkl (with mulithreads support)

I compiled R by referring to these guides:

http://www.r-bloggers.com/compiling-64-bit-r-2-10-1-with-mkl-in-linux/

http://cran.r-project.org/doc/manuals/R-admin.html#MKL

But for matrix algebra R does not use all available CPUs.

I tried both:

MKL="-L${MKL_LIB_PATH} -lmkl_gf_lp64 -lmkl_gnu_thread \ -lmkl_core -fopenmp -lpthread" 

and

 MKL=" -L${MKL_LIB_PATH} \ -Wl,--start-group \ ${MKL_LIB_PATH}/libmkl_gf_lp64.a \ ${MKL_LIB_PATH}/libmkl_gnu_thread.a \ ${MKL_LIB_PATH}/libmkl_core.a \ -Wl,--end-group \ -lgomp -lpthread" 

Options.

How can I get R to use all available processors?

How to check if R uses MKL or not?

+4
source share
3 answers

I would like to add my procedure for compiling R 3.0.1 with MKL libraries. I am using Debian 7.0 on the core of the i7 intel processor, 8G RAM. First, I installed the MKL libraries, after I set the MKL related environment variables (MKLROOT and LD_LIBRARY_PATH) with this command:

 >source /opt/intel/mkl/bin/mklvars.sh intel64 

So, I used the following options for. / configure:

 >./configure --enable-R-shlib --enable-threads=posix --with-lapack --with-blas="-fopenmp -m64 -I$MKLROOT/include -L$MKLROOT/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm" 

and completed the installation with make and make install.

As a reference, I made a product between two 5000 x 5000 matrix products without MKL and received:

expired 57.455 0.104 29.033

and after compilation:

expired 15.993 0.176 4.333

real win!

+6
source

(not a real answer: I do not use MKL, I use OpenBlas as a common BLAS, as described in the R-admin guide .)

  • As a quick check to see if optimized BLAS is being used, I am doing matrix multiplication. Even if only 1 core is used, it should be faster for optimized BLAS than for standard BLAS R.

  • To check how many cores are in use, I look at top (or usage / CPU usage graph) during matrix multiplication.

  • In the past, there were problems with the proximity of the processor, so BLAS runs $ n $ threads, but they all work on the same core, see Parallel processing in R is limited .
    r-devel (3.0.0-to-be) has a function for setting processor proximity.

+1
source

All Articles