Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Compiling R 3.0.2 with MKL

Benjamin_D_1
Beginner
1,132 Views

I'm not sure if R compiled correctly with MKL:

When I do ldd on R I don't see any reference to MKL

benjamin@benjamin-Lenovo-IdeaPad-Y510P:/opt/intel/mkl/tools$ ldd /usr/lib/R/bin/exec/R
    linux-vdso.so.1 =>  (0x00007fff641fe000)
    libR.so => /usr/lib/libR.so (0x00007ffad94d8000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ffad92bb000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffad8efa000)
    libblas.so.3gf => /usr/lib/libblas.so.3gf (0x00007ffad8c60000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ffad8964000)
    libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007ffad8721000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007ffad84e4000)
    liblzma.so.5 => /usr/lib/x86_64-linux-gnu/liblzma.so.5 (0x00007ffad82c2000)
    libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007ffad80b1000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ffad7ea9000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffad7ca5000)
    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007ffad7a96000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ffad9a35000)
    libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007ffad786f000)

Some info on how I compiled R with MKL:

 benjamin@benjamin-Lenovo-IdeaPad-Y510P:/opt/intel/mkl/tools$ ./mkl_link_tool -check_mkl_presence

       Intel(R) Math Kernel Library (Intel(R) MKL) Link Tool v4.0
       ==========================================================

Unknown mode. Specify -libs, -opts, -env or compilation line

Configuration
=============

MKL version:            11.1
OS:                     lnx
Architecture:           intel64
Compiler:               intel_f
Linking:                dynamic
Interface layer:        lp64
Parallel:               yes
OpenMP library:         iomp5

benjamin@benjamin-Lenovo-IdeaPad-Y510P:/opt/intel/mkl/tools$ ./mkl_link_tool -check_mkl_presence -libs -opts -env

       Intel(R) Math Kernel Library (Intel(R) MKL) Link Tool v4.0
       ==========================================================

Output
======

Compiler option(s):
 -I/opt/intel/composer_xe_2013_sp1.0.080/mkl/include

Linking line:
 -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -openmp -lpthread -lm

Environment variable(s):
export LD_LIBRARY_PATH=/opt/intel/composer_xe_2013_sp1.0.080/mkl/../compiler/lib/intel64:/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64:$LD_LIBRARY_PATH;

This was the actual command I ran to configure R:

 ./configure --enable-R-shlib --enable-threads=posix --with-lapack --with-blas=-fopenmp -m64 -I/opt/intel/composer_xe_2013_sp1.0.080/mkl/include -L/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64 -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm

In my config.log file I do see:

configure:29696: checking whether double complex BLAS can be used
configure:29767: result: yes


However, right after that I see:

configure:29787: checking whether the BLAS is complete
conftest.c: In function 'blas_set':
conftest.c:11:3: warning: implicit declaration of function 'dasum_' [-Wimplicit-function-declaration]
conftest.c:12:3: warning: implicit declaration of function 'daxpy_' [-Wimplicit-function-declaration]


... lots more of these ...

/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_core.so: undefined reference to `logf'
... lots more of these ...
/opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_core.so: undefined reference to `expf'
collect2: ld returned 1 exit status
configure:29911: result: no

 

 

 

 

 

 

0 Kudos
9 Replies
TimP
Honored Contributor III
1,132 Views
Did you look at the final link command? Mkl_gf is for gfortran. You didn't say you intended to mix gfortran and icc.
0 Kudos
Benjamin_D_1
Beginner
1,132 Views

I tried to re-install but this time with intel compiler (and correct link command) but I still don't have MKL linked! This was my 2nd attempt at config: ./configure --with-blas=-DMKL_ILP64 -openmp -I/opt/intel/composer_xe_2013_sp1.2.144/mkl/include  -L/opt/intel/composer_xe_2013_sp1.2.144/mkl/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -liomp5 -lpthread -lm --with-lapack

0 Kudos
VipinKumar_E_Intel
1,132 Views

Benjamin,

  Please follow these steps for building with Intel compilers and Intel MKL.

$export AR=”xiar”

$export LD=”xild”

Set the Intel MKL and OpenMP library paths

$MKL_LIB_PATH=’/opt/intel/composer_xe_2013_sp1/mkl/lib/intel64’

$OMP_LIB_PATH=’/opt/intel/lib/intel64’

$export LD_LIBRARY_PATH=${MKL_LIB_PATH}:${OMP_LIB_PATH}

$MKL=" -L${MKL_LIB_PATH} -L${OMP_LIB_PATH} -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core  -liomp5 -lpthread"

 

Edit config.site by making changes for C/C++ and FORTRAN compilers and its options related lines as shown below:

CC=’icc –std=c99’

CFLAGS=’-O3 –ipo –xavx –openmp’

F77=’ifort’

FFLAGS=’-O3 –ipo –xavx –openmp’

CXX=’icpc’

CXXFLAGS=’-O3 –ipo –xavx –openmp’

$./configure --with-blas="$MKL" --with-lapack

Check the config.log to see if Intel® MKL was working during the configuration test.

configure:29075: checking for dgemm_ in -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread

configure:29096: icc -std=c99 -o conftest -O3 -ipo -openmp -xHost  -I/usr/local/include  -L/usr/local/lib64 conftest.c -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread  -lifport -lifcoremt -limf -lsvml -lm -lipgo -liomp5 -lirc -lpthread -lirc_s -ldl -lrt -ldl -lm  >&5

conftest.c(210): warning #266: function "dgemm_" declared implicitly

  dgemm_()

  ^

configure:29096: $? = 0

configure:29103: result: yes

configure:29620: checking whether double complex BLAS can be used

configure:29691: result: yes

configure:29711: checking whether the BLAS is complete

  1. Now, run make to build and install R with the Intel®  Compiler and Intel® MKL:

$make && make install

 

To check the correct installation, run ldd and it should show something like below.

 

$ ldd ./bin/exec/R

        linux-vdso.so.1 =>  (0x00007fff2a1ff000)

        libmkl_intel_lp64.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_intel_lp64.so (0x00007f7d89bf9000)

        libmkl_intel_thread.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_intel_thread.so (0x00007f7d88b5e000)

        libmkl_core.so => /opt/intel/composer_xe_2013_sp1.0.080/mkl/lib/intel64/libmkl_core.so (0x00007f7d87630000)

--Vipin

 

0 Kudos
Benjamin_D_1
Beginner
1,132 Views

Vipin,

I get the following error in config.log

configure:6150: checking whether the C compiler works
configure:6172: icc -std=c99 -O3 –ipo –xavx –openmp -I/usr/local/include -L/usr/local/lib conftest.c  >&5
icc: error #10236: File not found:  '–ipo'
icc: error #10236: File not found:  '–xavx'
icc: error #10236: File not found:  '–openmp'

0 Kudos
Benjamin_D_1
Beginner
1,132 Views

I figured out the previous error. When I copy pasted your commands from this website the encoding on the ' - ' character did not get translated correctly. Very difficult error to catch!

0 Kudos
Benjamin_D_1
Beginner
1,132 Views

Vipin,

I am still having a problem with the install. After I do make, I do a make check to see if make was okay and I get the following error:

running code in 'reg-packages.R' ...make[3]: *** [reg-packages.Rout] Error 1

when I look at tests/reg-packages.Rout.fail I see:

unable to load shared object '/home/benjamin/R/x86_64-unknown-linux-gnu-library/3.0/lattice/libs/lattice.so':
  libR.so: cannot open shared object file: No such file or directory

 

0 Kudos
Benjamin_D_1
Beginner
1,132 Views

I figured out the problems. I had some leftover libraries present in my home directory from previous R installs. Getting rid of those and re-compile from source made everything work. Thank you!

0 Kudos
Benjamin_D_1
Beginner
1,132 Views

I am now having a problem installing packages, I get the following errors:

> install.packages("setwidth")
Installing package into ‘/usr/local/lib/R/site-library
(as lib is unspecified)
Selection: 77
trying URL 'http://streaming.stat.iastate.edu/CRAN/src/contrib/setwidth_1.0-3.tar.gz'
Content type 'application/x-gzip' length 3789 bytes
opened URL
==================================================
downloaded 3789 bytes

* installing *source* package setwidth ...
** package setwidth successfully unpacked and MD5 sums checked
** libs
icc -std=c99 -I/usr/local/lib/R/include -DNDEBUG  -I/usr/local/include    -fpic  -O3 -ipo -xavx -openmp  -c setwidth.c -o setwidth.o
In file included from setwidth.c(4):
/usr/local/lib/R/include/R_ext/eventloop.h(73): error: identifier "fd_set" is undefined
  extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask);
                                                                  ^
... more of the same ...

                  ^

compilation aborted for setwidth.c (code 2)
make: *** [setwidth.o] Error 2
ERROR: compilation failed for package setwidth
* removing ‘/usr/local/lib/R/site-library/setwidth

The downloaded source packages are in
    ‘/tmp/RtmpXuQs4W/downloaded_packages
Warning message:
In install.packages("setwidth") :
  installation of package setwidth had non-zero exit status
0 Kudos
Benjamin_D_1
Beginner
1,132 Views

I am now having a problem installing packages, I get the following errors:

> install.packages("setwidth") Installing package into ‘/usr/local/lib/R/site-library’ (as ‘lib’ is unspecified) Selection: 77 trying URL 'http://streaming.stat.iastate.edu/CRAN/src/contrib/setwidth_1.0-3.tar.gz' Content type 'application/x-gzip' length 3789 bytes opened URL ================================================== downloaded 3789 bytes * installing *source* package ‘setwidth’ ... ** package ‘setwidth’ successfully unpacked and MD5 sums checked ** libs icc -std=c99 -I/usr/local/lib/R/include -DNDEBUG -I/usr/local/include -fpic -O3 -ipo -xavx -openmp -c setwidth.c -o setwidth.o In file included from setwidth.c(4): /usr/local/lib/R/include/R_ext/eventloop.h(73): error: identifier "fd_set" is undefined extern InputHandler *getSelectedHandler(InputHandler *handlers, fd_set *mask); ^ ... more of the same ... ^ compilation aborted for setwidth.c (code 2) make: *** [setwidth.o] Error 2 ERROR: compilation failed for package ‘setwidth’ * removing ‘/usr/local/lib/R/site-library/setwidth’ The downloaded source packages are in ‘/tmp/RtmpXuQs4W/downloaded_packages’ Warning message: In install.packages("setwidth") : installation of package ‘setwidth’ had non-zero exit status

0 Kudos
Reply