Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Douglas_Rudd
Beginner
256 Views

mkl_rt has no way to specify fortran interface

I am attempting to compile the python libraries numpy and scipy using the GNU compiler and using MKL for the blas library.  Explicitly linking to the appropriate fortran interface library using -lmkl_gf_lp64 -lmkl_core -lmkl_sequential -lpthread causes the failure to find mkl_avx and mkl_def bug.

Instead, the code links fine when -lmkl_rt is used, but then complex blas functions fail with segfaults.The attached fortran program illustrates this problem (exists for MKL 10.3 and 11):

[bash]
$ gfortran test_cdotu.f -lmkl_gf_lp64 -lmkl_core -lmkl_sequential -lpthread
$ ./a.out
(  2.0000000    ,  0.0000000    )
$ gfortran test_cdotu.f -lmkl_rt -lpthread
$ ./a.out
Segmentation fault
$ ifort test_cdotu.f -lmkl_rt -lpthread
$ ./a.out
 (2.000000,0.0000000E+00)
[/bash]

0 Kudos
4 Replies
Gennady_F_Intel
Moderator
256 Views

I see segmentation fault with 11.1 version too:

[root@nntssg118-x64 u499188]# ./a.out 
Intel(R) Math Kernel Library Version 11.1.1 Product Build 20131010 for Intel(R) 64 architecture applications                                                                                          Segmentation fault (core dumped)

the problem is escalated and we will back to you if any updates.

 

Gennady_F_Intel
Moderator
256 Views

Hello.  We confirmed the bug into MKL with gfortran. As a temporary workarond the problem you can try to add options "-ff2c -fno-second-underscore" and check if it will help.  We will keep you update when the fix would be available in the product version of MKL.

Douglas_Rudd
Beginner
256 Views

Hi Gennady, Thanks for your comment, I should have added the following to the bug report. -ff2c corrects the problem with the complex blas functions, but then breaks the non-complex functions in a much more dangerous way (the values returned are incorrect rather than generating a crash). The attached code adds a real function to the previous test example. [bash] $ gfortran test_cdotu_sdot.f -lmkl_gf_lp64 -lmkl_core -lmkl_sequential -lpthread $ ./a.out 2.0000000 ( 2.0000000 , 0.0000000 ) $ gfortran test_cdotu_sdot.f -lmkl_rt -lpthread $ ./a.out Segmentation fault $ gfortran test_cdotu_sdot.f -lmkl_rt -lpthread -ff2c -fno-second-underscore $ ./a.out 0.0000000 ( 2.0000000 , 0.0000000 ) [/bash] I am currently using a set of wrapper functions that translate the complex fortran blas functions to cblas functions, and this allows the use of -lmkl_rt without the -ff2c flag. These were developed by the scipy team to fix similar issues with the blas library on OS X, and I'll let them know of the possible workaround.
Gennady_F_Intel
Moderator
256 Views

The fix is available since MKL 11.1.3, and also present in MKL 11.2.x line.  Please use proper environment setting:
export MKL_INTERFACE_LAYER=LP64,GNU 

it works on my side. here is the output I see:

gfortran test_cdotu_sdot.f -lmkl_rt -lpthread -o 2.out

export MKL_INTERFACE_LAYER=LP64,GNU
./2.out
   2.00000000     (  2.00000000    ,  0.00000000    )

 

 

Reply