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

Building R with MKL

syk
Beginner
675 Views

Hello,

I am new to intel c++ compiler. 

Further to installation of 2017 intel c++ composer edition, I am trying to build R with Intel MKL, following this link

https://software.intel.com/content/www/us/en/develop/articles/using-intel-mkl-with-r.html

In particular, 

"building R with GNU gcc and GNU gfortran, to use the GNU OpenMP* threaded version of Intel® MKL in R on a Linux operating system"

=====

$ MKL="-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm"

$ MKL="-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm"

...

checking for dgemm_ in -Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm... no
configure: error: BLAS was specified but not available

=======

When I check R config.log, I find 

=====

configure:41233: checking for dgemm_ in -Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm
configure:41255: /usr/local/bin/gcc-10 -o conftest -g -O2 -fpic -I/usr/local/include -L/usr/local/lib64 conftest.c -Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm -L/usr/lib/gcc/x86_64-redhat-linux/4.8.2 -lgfortran -lm -lquadmath -lrt -ldl -lm >&5
/bin/ld: cannot find -lmkl_gf_lp64
/bin/ld: cannot find -lmkl_gnu_thread
/bin/ld: cannot find -lmkl_core

========

I realise there isn't "libmkl_gf_lp64.so" in /opt/intel directory, which  I learn is "LP64 interface library for the GNU Fortran compilers"

 

To build R with Intel MKL, I wonder if I need to buy Intel fortran compiler to have the libmkl_gf_lp64.so library.

 

thanks,

ss

 

 

0 Kudos
5 Replies
GouthamK_Intel
Moderator
562 Views

Hi Samuel,

Could you please go to /opt/intel/<composer_xe_XXXX>/mkl/lib/intel64

to see if you have the libmkl_gf_lp64.a and libmkl_gf_lp64.so in the directory?  if no, then you may need to reinstall MKL.

If you have only libmk_gf_lp64.a, then please use the static link (Option C)as shown in the article.

https://software.intel.com/content/www/us/en/develop/articles/using-intel-mkl-with-r.html

Please revert to us once you check the above-mentioned details.


Regards

Goutham


syk
Beginner
540 Views

Hello Goutham,

Thank you for your help.

Yes. I eventually install psxe cluster linux 2017update 8 and found libmkl_gf_lp64.a and libmkl_gf_lp64.so installed.

I did not know at the first place "-lmkl_gf_lp64" does need interface library for gnu fortran. Now I learnt it.

BTW, I wonder why this R configure script don't return "LAPACK(MKL)" at the "External libraries: .." line. I can make R without any error and sure that BLAS (MKL) is fine.

But I am not sure if R lapack library is linked to MKL lapack.

====

$ ./configure CC=/usr/local/bin/gcc-10 CXX=/usr/local/bin/g++-10 --with-blas="-L/opt/intel/compilers_and_libraries_2017.8.262/linux/mkl/lib/intel64_lin -Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm" --with-lapack --enable-R-profiling --enable-memory-profiling --enable-R-shlib --enable-BLAS-shlib --enable-java --enable-long-double --with-readline --with-pcre1 --with-tcltk --with-cairo --with-libpng --with-jpeglib --with-libtiff --with-ICU --with-x

...

R is now configured for x86_64-pc-linux-gnu

Source directory: .
Installation directory: /usr/local

C compiler: /usr/local/bin/gcc-10 -g -O2
Fortran fixed-form compiler: gfortran -g -O2

Default C++ compiler: /usr/local/bin/g++-10 -std=gnu++11 -g -O2
C++14 compiler: /usr/local/bin/g++-10 -std=gnu++14 -g -O2
C++17 compiler: /usr/local/bin/g++-10 -std=gnu++17 -g -O2
C++20 compiler: /usr/local/bin/g++-10 -std=gnu++20 -g -O2
Fortran free-form compiler: gfortran -g -O2
Obj-C compiler:

Interfaces supported: X11, tcltk
External libraries: pcre1, readline, BLAS(MKL), curl
Additional capabilities: PNG, JPEG, TIFF, NLS, cairo, ICU
Options enabled: shared R library, shared BLAS, R profiling, memory profiling

Capabilities skipped:
Options not enabled:

Recommended packages: yes

=========

 

GouthamK_Intel
Moderator
457 Views

Hi Samuel,

We are working on your issue internally, we will get back to you soon.


Regards

Goutham


Khang_N_Intel
Employee
373 Views

Hi Samuel,


Have you tried the R command sessionInfo()?

> sessionInfo()


If R is linked to MKL correctly you will see something like this:

R version....

...

Matrix products: default

BLAS/LAPACK: /optintel/oneapi/mkl/2021.2.0/lib/intel64/libmkl_rt.so.1

...

locale:

...


Best,

Khang


Khang_N_Intel
Employee
370 Views

Sorry, typo:

It should be something like this:

R version....

...

Matrix products: default

BLAS/LAPACK: /opt/intel/oneapi/mkl/2021.2.0/lib/intel64/libmkl_rt.so.1

...

locale:

...


Reply