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

Compiling R with serial MKL (failed due to zdotu error?)

Thomas_U_
Beginner
670 Views

Hi!

I'm trying to get R 3.0.1 to compile using composer_xe_2013.2.146 using the serial MKL. I followed the instructions from http://software.intel.com/en-us/articles/using-intel-mkl-with-r , yet at the configure-step, I get

checking whether double complex BLAS can be used... no

configure then goes on to compile R without linking the MKL (i.e., the resulting binary uses R's own BLAS implementation, which offers subpar performance).

Searching around the web, it would appear that I am far from the only one having run this issue, yet I was unable to find any solutions for it. (I found an old discussion about the topic here: http://software.intel.com/en-us/forums/topic/326016 ; ... yet it didn't include any solution steps, and in fact I believe in the end the user ended up with an R version that didn't even link with the MKL).

I investigated the configure-failure, and it stems from the following failed test:

a Fortran-file (the attached conftestf.f) calls zdotu, and checks the results against a manual dot-product. It sets a failure flag if the zdotu-result and the manual dot-product don't match. This is then called from the C file  conftest.c (I'm assuming to test Fortran<>C interfacing or something), which returns the failure-flag as a return code.

I've attached the files to this post (slightly modified so the failure flag gets printed to stdout). I compile the files with:

export LIBDIR="/apps/intel/compiler/composer_xe_2013.2.146/mkl/lib/intel64/:/apps/intel/compiler/composer_xe_2013.2.146/compiler/lib/intel64/"

ifort -c conftestf.f -L$LIBDIR -lmkl_gf_lp64 -lmkl_sequential -lmkl_core
icc -c conftest.c -L$LIBDIR -lmkl_gf_lp64 -lmkl_sequential -lmkl_core
icc conftestf.o conftest.o -o conftest -L$LIBDIR -lmkl_gf_lp64 -lmkl_sequential -lmkl_core
./conftest

The call to ./conftest will print out the failure flag, which on my machine will always output 1. This makes the configure-test fail and leads R to ignore the MKL I want to link it with.

For full reference, this is how I call ./configure:


/apps/intel/compiler/composer_xe_2013.2.146/bin/compilervars_global.sh intel64
/apps/intel/compiler/composer_xe_2013.2.146/mkl/bin/vars/mklvars.sh intel64
export CC='icc -std=c99 '
export F77='ifort '
export CXX='icpc '
export FC='ifort '
export CPPFLAGS="-O3 -DNDEBUG -g -march=native "
export CFLAGS=$CPPFLAGS
export FCFLAGS=$CPPFLAGS
export FFLAGS=$CPPFLAGS

export MKL_LIB_PATH=/apps/intel/compiler/composer_xe_2013.2.146/mkl/lib/intel64:/apps/intel/compiler/composer_xe_2013.2.146/compiler/lib/intel64/
export LD_LIBRARY_PATH=$MKL_LIB_PATH
export MKL=" -L${MKL_LIB_PATH} -lmkl_gf_lp64 -lmkl_sequential -lmkl_core "
./configure --with-blas="$MKL" --enable-threads=posix --with-lapack --enable-memory-profiling --enable-R-shlib

0 Kudos
6 Replies
Thomas_U_
Beginner
670 Views

I forgot to add:  any help in resolving this issue / any pointers on how to get R to compile with the serial MKL would be very appreciated! :)

0 Kudos
VictoriyaS_F_Intel
670 Views

Hello Thomas,

It seems there is a bug in MKL link line you are using. Please try to build ./conftest using following commands:

export MKL_ROOT=/apps/intel/compiler/composer_xe_2013.2.146

ifort -c conftestf.f
icc -c conftest.c
icc -o conftest -L${MKL_ROOT}/mkl/lib/intel64 conftestf.o conftest.o -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread
./conftest

Please also change MKL environment variable before calling ./configure as follows:

export MKL=" -L${MKL_LIB_PATH} -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread "

There is a very useful tool that could be used to check the correctness of MKL link line: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/

Thanks,

Victoriya 

 

0 Kudos
Ying_H_Intel
Employee
670 Views

Hi Thomas,

I update the forum of 326016 today and saw your question here. Thanks a lot for the test case, which help us expose all of the problems actually.

As victoriya reply, you have 2 problems in the build.

1. The key problem :  the interface :  mk_gf_lp64  vs. mkl_intel_lp64.

libmkl_gf_lp64  is for LP64 interface library for the GNU Fortran compilers.

and libmkl_intel_lp64 is for intel compilers.

So when you call intel fotran compiler , the libmkl_intel_lp64 should be used.

some user may just have icc, thus they have to gfortran +icc + mkl_gf.

2. the MKL_LIB_PATH.

the ld (linker) actully don't recognize
-L/apps/intel/compiler/composer_xe_2013.2.146/mkl/lib/intel64:/apps/intel/compiler/composer_xe_2013.2.146/compiler/lib/intel64/.  Which use link two path.

It is wrong syntax,  you may need  either


-L/apps/intel/compiler/composer_xe_2013.2.146/mkl/lib/intel64   ( -L/apps/intel/compiler/composer_xe_2013.2.146/compiler/lib/intel64/ can be removed as you are using sequential library)

or don't do the MKL_LIB_PATH setting, as you have done by

>source mklvars.sh intel64, which do right setting including LD_LIBRARY_PATH ( which are used in run time) and LIBRARY_PATH (which are used in build time) , both the two env allow use the symbol :

( /apps/intel/compiler/composer_xe_2013.2.146/mkl/bin/vars/mklvars.sh intel64,  can you check the folder, by default, it is /apps/intel/compiler/composer_xe_2013.2.146/mkl/bin//mklvars.sh intel64)

Hope it helps, 

Best Regards,

Ying

0 Kudos
Thomas_U_
Beginner
670 Views

Thanks a lot Victoryia, the testcase runs through now and R seems to compile just fine.

@ Ying:

thank you for having taken the time to explain what was wrong with the link part.

0 Kudos
jagla__bernd
Beginner
670 Views

I cannot find libmk_gf_lp64.dylib on my Mac (High Sierra). I have installed mkl_2018.3.185 twice already and it seems not be there (anymore). Also, the mkl_link_line_advisor doesn't use it either... I guess things have changed since 2013. Nonetheless, I still cannot run the configure test correctly that is provided in R and get a  segmentation fault 11 after successful compilation and linking.

It would be great if you could still comment... Thx

0 Kudos
Ying_H_Intel
Employee
670 Views

Hi Jagla, 

I guess, the problem is that we don't have gfotraned supported for Mac. so you can't find it.  if possible, could you  try or use Intel Compiler C and fotran + MKL together  : https://software.intel.com/en-us/articles/build-r-301-with-intel-c-compiler-and-intel-mkl-on-linux

Best Regards,

Ying

 

0 Kudos
Reply