[Rd] Build R with MKL and ICC

Martyn Plummer plummerm at iarc.fr
Mon Sep 7 12:22:09 CEST 2015


On Sat, 2015-09-05 at 11:53 +0200, arnaud gaboury wrote:
> On Fri, Sep 4, 2015 at 5:58 PM, Martyn Plummer <plummerm at iarc.fr> wrote:
> > On Wed, 2015-09-02 at 20:49 +0200, arnaud gaboury wrote:
> >> On Wed, Sep 2, 2015 at 7:35 PM, arnaud gaboury <arnaud.gaboury at gmail.com> wrote:
> >> > After a few days of reading and headache, I finally gave a try at
> >> > building R from source with Intel MKL and ICC. Documentation and posts
> >> > on this topic are rather incomplete, sometime fantasist et do not give
> >> > much explanations about configure options.
> >> > As I am not sure if mine is correct, I would appreciate some advices and hints.
> >> >
> >> > OS: Fedora 22
> >> > parallel_studio_xe_2016
> >> > Hardware : 8 Thread(s) per core: 2 Vendor ID: GenuineIntel Model name:
> >> > Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz - Sandybridge
> >> > R-3.2.2
> >> >
> >> > Here is my build configuration:
> >> >
> >> > -------------------------------------------------------
> >> > source /opt/intel/compilers_and_libraries_2016/linux/mkl/bin/mklvars.sh intel64
> >> > source /opt/intel/bin/compilervars.sh intel64
> >> > _mkllibpath=$MKLROOT/lib/intel64
> >> > _icclibpath=$MKLROOT/linux/compiler/lib
> >> > export LD_LIBRARY_PATH=${_mkllibpath}:${_icclibpath}
> >> > export MKL="-L${_mkllibpath} -L${_icclibpath} -lmkl_intel_lp64
> >> > -lmkl_intel_thread -lmkl_core  -liomp5 -lpthread"
> >> > export CC="icc"
> >> > export F77="ifort"
> >> > export CXX="icpc"
> >> > export AR="xiar"
> >> > export LD="xild"
> >> > export CFLAGS="-O3 -ipo -openmp -parallel -xAVX"
> >> > export CXXFLAGS="-O3 -ipo -openmp -parallel -xAVX"
> >> > export FFLAGS="-O3 -ipo -openmp -parallel -xAVX"
> >> > export MAIN_LDFLAGS='-openmp'
> >> > ./configure --with-lapack --with-blas="$MKL" --enable-R-shlib
> >> > --enable-memory-profiling --enable-openmp --enable-BLAS-shlib
> >> > --enable-lto F77=${F77} FC=${F77}
> >> > ------------------------------------------------------------
> >> >
> >> > After I run ./configure, it seems from config.log everything is fine:
> >> >
> >> > checking for dgemm_ in
> >> > result: yes
> >> >
> >> > checking whether double complex BLAS can be used
> >> > result: yes
> >> >
> >> > checking whether the BLAS is complete
> >> > result: yes
> >> >
> >> > The only error I can see is ld complaining about not finding -lRblas
> >> > ----------------------------------------------------------------------------
> >> >
> >> > Then run $ make with no errors.
> >> > Now, with no $ make install, I get this:
> >> >
> >> > --------------------------------------------------------------------
> >> > $ ldd bin/exec/R
> >> > linux-vdso.so.1 (0x00007ffe073f3000)
> >> > libR.so => /usr/lib64/R/lib/libR.so (0x00007f43939e6000)
> >> > libRblas.so => not found
> >> > libm.so.6 => /lib64/libm.so.6 (0x00007f43936de000)
> >> > libiomp5.so => /opt/intel/compilers_and_libraries_2016.0.109/linux/compiler/lib/intel64/libiomp5.so
> >> > (0x00007f439339c000)
> >> > libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4393185000)
> >> > libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4392f69000)
> >> > libc.so.6 => /lib64/libc.so.6 (0x00007f4392ba8000)
> >> > libdl.so.2 => /lib64/libdl.so.2 (0x00007f43929a4000)
> >> > libblas.so.3 => /lib64/libblas.so.3 (0x00007f439274b000)
> >> > libgfortran.so.3 => /lib64/libgfortran.so.3 (0x00007f439241f000)
> >> > libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007f43921e0000)
> >> > libreadline.so.6 => /lib64/libreadline.so.6 (0x00007f4391f96000)
> >> > libtre.so.5 => /lib64/libtre.so.5 (0x00007f4391d85000)
> >> > libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f4391b15000)
> >> > liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f43918ef000)
> >> > libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f43916de000)
> >> > libz.so.1 => /lib64/libz.so.1 (0x00007f43914c8000)
> >> > librt.so.1 => /lib64/librt.so.1 (0x00007f43912c0000)
> >> > libicuuc.so.54 => /lib64/libicuuc.so.54 (0x00007f4390f2e000)
> >> > libicui18n.so.54 => /lib64/libicui18n.so.54 (0x00007f4390ad7000)
> >> > libgomp.so.1 => /lib64/libgomp.so.1 (0x00007f43908b5000)
> >> > /lib64/ld-linux-x86-64.so.2 (0x00005557e2243000)
> >> > libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f439068a000)
> >> > libicudata.so.54 => /lib64/libicudata.so.54 (0x00007f438ec5f000)
> >> > libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f438e8dc000)
> >> > -----------------------------------------------------------------------------------------------
> >> >
> >> >
> >> > Now a few questions:
> >> >
> >> EDIT
> >> > 1- am I not supposed to see these libraries in the list ?
> >> > libmkl_intel_lp64.so
> >> > libmkl_intel_thread.so
> >> > libmkl_core.so
> >
> > You are looking in the wrong place. With the option --enable-BLAS-shlib,
> > R is linked to MKL via the library libRblas.so which you will find in
> > the directory "lib" after building R.
> 
> 
> Right.
> $ ls lib
> libRblas.so*  libRlapack.so*  libR.so*
> 
> $ ldd bin/exec/R returns
> ....
> libRblas.so => not found
> 
> Shall I let things like that or tell R the path to libRblas.so ?

No that is not a problem. R knows where to find these libaries even if
they are not on the linker path. 

Your only problem is to tell R where the Intel libraries are at runtime,
typically by setting/modifying LD_LIBRARY_PATH before launching R, e.g.
on my desktop I use 

export LD_LIBRARY_PATH=/opt/intel/composerxe/lib/intel64:/opt/intel/composerxe/mkl/lib/intel64/

Martyn

> >> > Or do I need to run $make install before ldd?
> >> >
> >> > 2- when visiting Intel MKL link advisor[0], here is what I get as
> >> > configure and make options:
> >> > Linking: -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core
> >> > -lmkl_intel_thread -lpthread -lm
> >> > Compiler options:  -DMKL_ILP64 -qopenmp -I${MKLROOT}/include
> >> >
> >> > What is the difference between -openmp and -qopenmp? Shall I use
> >> > indeed the above compiler options?
> >
> > The option -qopenmp replaces -openmp, which is deprecated. This is in
> > the man page for icc.
> >
> > Martyn
> >
> >> > Thank you for help in this difficult topic for me.
> >> >
> >> > --
> >> >
> >> > google.com/+arnaudgabourygabx
> >>
> >>
> >>
> 
> 

-----------------------------------------------------------------------
This message and its attachments are strictly confidenti...{{dropped:8}}



More information about the R-devel mailing list