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

Linking MKL within Python-C++-C-Fortran 2003 program

lacek
Beginner
339 Views

[repost from: http://stackoverflow.com/questions/13951953/linking-intels-mkl-within-python-c-c-fortran-2003-program]

I am trying to link a program which nature is pretty complicated:

  • developed and run under Linux Fedora
  • main code written in fortran 2003 is heavily relies on Intel's MKL library and small pieces of ANSI C code
  • it has C++ interface (use iso_c_binding)
  • the c++ interface is accessed from python via boost.python

During the runtime I get the following text

MKL FATAL ERROR:Cannot load neither libmkl_avx.so nor libmkl_def.so

after which program stops.

I have checked that bothlibmkl_avx.soandlibmkl_def.soare in $LD_LIBRARY_PATH

The final linking is done via:

g++-g3-shared-Wl,-soname,libFrrBoost_rt.so interfejs.o t83.o gen_random2.o-L/opt/intel/composerxe/mkl/lib/intel64-lpython2.7-lifport-lifcore-lboost_python-Wl,--start-group-lmkl_sequential-lmkl_intel_lp64-lmkl_core-Wl,--end-group-o libFrrBoost_rt.so

libFrrBoost is the module that is linked, then

runningpython t83.py(in particular linker does not complain when preparing the binary file) which imports the module libFrrBoost causes the error.

Tried to google. All the info I found was connected with "usual programs" written in C/Fortran and simply including Intel's MKL. I am able to run this sort of programs with no problem. I think the MKL part of the linking line in the Makefile is equivalent in both cases, but there must be somewhere a hidden mystery. The problem was usually bad linking - which I do not see applicable (the libraries are exactly as in Intel's manual - Interface, Threading and computational libraries are pretty standard)

Used compilers:

ifort 12.1.0, icpc 12.1.0, python Python 2.7.1, icc 12.1.0 (the small C snippet also calls MKL, but)

ADDITION (due to a comment of HirstoIliev@Stackoverflow)

I have run the strace in this way:strace python t83.py; The result is (after grepping libmkl):

open("/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/libmkl_avx.so", O_RDONLY)=3

open("/usr/bin/libmkl_avx.so", O_RDONLY)=-1 ENOENT(No such file or directory) open("/opt/slurm-2.2.5/lib/libmkl_avx.so", O_RDONLY)=-1 ENOENT(No such file or directory)

open("/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64/libmkl_avx.so", O_RDONLY)=-1 ENOENT(No such file or directory)

open("/opt/intel/composer_xe_2011_sp1.7.256/debugger/lib/intel64/libmkl_avx.so", O_RDONLY)=-1 ENOENT(No such file or directory)

open("/opt/intel/composer_xe_2011_sp1.7.256/mkl/lib/intel64/libmkl_avx.so", O_RDONLY)=3

I understand that the specification for open is as in here an, in particular, as 3,4 are positive and indicate that open has found a file and assigned it file discriptors. I have verified that the file does exist in that place.

also this is "good" Intel compiler directory as:

czeslaw@stefan:~/prog/FoCpy3 $ which ifort/opt/intel/composer_xe_2011_sp1.7.256/bin/intel64/ifort

So the version is the same - aparently it is not a version issue.

Everything is the same forlibmkl_def.so.

DISCLAIMER: Although I may sound confident in what I write I am not. Every sentence should begin with "If I am not mistaken".

0 Kudos
2 Replies
lacek
Beginner
339 Views
It seems the solution is to link with -lmkl_rt instead of -lmkl_sequential -lmkl_intel_lp64 -lmkl_core. I do not see why one should give advantageous over te other. I am confused but that works (so far).
0 Kudos
barragan_villanueva_
Valued Contributor I
339 Views
Hi, In case of creating your libFrrBoost_rt.so which depends explicitly from mkl_intel_lp64 + mkl_sequential + mkl_core MKL dynamic libraries please try to locate libFrrBoost_rt together with all MKL dynamic libraires (required on run-time) in the same directory.
0 Kudos
Reply