1

I have been scratching my head for more than a week, with no answer to my issue. I want to build R from cran source with Intel MKL1 as a shared library. Here is the small script I use to test my configuration:

#! /bin/sh
export MKL=/opt/intel/compilers_and_libraries_2016.0.109/linux/mkl
MKL=" -L${_mkllibpath} \
-Wl,--start-group \
    -lmkl_gf_lp64 \
    -lmkl_gnu_thread \
    -lmkl_core \
-Wl,--end-group \
-lgomp -lpthread"

./configure --prefix=/usr \
--libdir=/usr/lib \
--datarootdir=/usr/share \
rsharedir=/usr/share/R/ \
rincludedir=/usr/include/R/ \
rdocdir=/usr/share/doc/R/ \
--with-blas="${MKL}" \
--with-lapack \
--enable-R-shlib 

make -j4

This small script do the following:

  1. build R with gcc and gfortran on x86_64
  2. build R with gnu threads
  3. export the path to Intel MKL libraries
  4. dynamically link BLAS to intel MKL

Now the part where I start getting mad. On one system, Archlinux, the build will let me with the following output from ldd ran inside the build directory

$ ldd bin/exec/R
.....
libmkl_gf_lp64.so => /opt/intel/mkl/lib/intel64/libmkl_gf_lp64.so    (0x00007f7707797000)
libmkl_core.so => /opt/intel/mkl/lib/intel64/libmkl_core.so (0x00007f7705c2a000)
libmkl_gnu_thread.so => /opt/intel/mkl/lib/intel64/libmkl_gnu_thread.so (0x00007f7704ed3000)
libimf.so => /opt/intel/lib/libimf.so (0x00007f7704814000)
libintlc.so.5 => /opt/intel/lib/libintlc.so.5 (0x00007f770284b000)
.......

This is exactly what I am looking for. Now, same script with Intel MKL installed in same path, run on Fedora22.

$ ldd bin/exec/R
linux-vdso.so.1 (0x00007ffe9a9c5000)
libR.so => /usr/lib64/R/lib/libR.so (0x00007f45d9b69000)
libgomp.so.1 => /lib64/libgomp.so.1 (0x00007f45d9947000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f45d972a000)
libc.so.6 => /lib64/libc.so.6 (0x00007f45d936a000)
libblas.so.3 => /lib64/libblas.so.3 (0x00007f45d9111000)
libgfortran.so.3 => /lib64/libgfortran.so.3 (0x00007f45d8de5000)
......

As seen, not links at all to Intel MKL.

I have played with all kinds of make options, with LD_PATHS, with linker options etc; I have checked environment varaibles; I have checked ldconfig cache; etc. Still impossible to get the correct linking with Fedora.

I would appreciate any hints, where to look at for finding the root of my issue.

gabx
  • 472
  • 2
  • 7
  • 18

1 Answers1

1

After many tries, below is the correct script to build R-cran with Intel MKL and ICC:

#! /bin/sh

source /opt/intel/compilers_and_libraries_2016.0.109/linux/bin/mklvars intel64 
source /opt/intel/bin/compilervars.sh intel64 
_icclibpath=/opt/intel/compilers_and_libraries_2016.0.109/linux/compiler/intel64/                    
_mkllibpath=${MKLROOT}/lib/intel64/
MKL=" -L${_mkllibpath} -lmkl_rt -lpthread"

export CC="icc"
export CXX="icpc"
export AR="xiar"
export LD="xild"
export F77="ifort"

export CFLAGS="-g -O3 -xHost -I${MKLROOT}/include"
export CXXFLAGS="-g -O3 -xHost -I${MKLROOT}/include"
export FFLAGS="-I${MKLROOT}/include"
export FCFLAGS="-I${MKLROOT}/include"

# shared libs
./configure --with-blas="${MKL}" --enable-R-shlib --enable-BLAS-shlib
# static libs
#./configure --with-blas="${MKL}" --with-lapack

make -j4

NOTE:

  1. the script is writen for Parallel studio 2016. Change path accordingly if composerxe 2015.
  2. libRlib and libRblas can be build as shared or static librairies.
  3. More options can be added to configure.
  4. Best is to source mklvars and compilervars in a script so it won't polluated your shell environment once the build is done.
gabx
  • 472
  • 2
  • 7
  • 18