[Rd] Build R with MKL and ICC

arnaud gaboury arnaud.gaboury at gmail.com
Wed Sep 2 19:35:27 CEST 2015

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
Hardware : 8 Thread(s) per core: 2 Vendor ID: GenuineIntel Model name:
Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz - Sandybridge

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
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
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:

1- am I not supposed to see something like this in the ldd command return?
libmkl_intel_lp64.so => /opt/intel....
libmkl_intel_thread.so => /opt/intel/....
libmkl_core.so => /opt/intel/...

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?

Thank you for help in this difficult topic for me.



More information about the R-devel mailing list