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

Problem calling MKL VML from Matlab MEX extension

pbrown32
Beginner
402 Views
I am having problems calling MKL Vector Maths (VML) functions from a Matlab C++ extension (using Mex). For example, when calling vcMul, Matlab exits with the error:

MKL FATAL ERROR: /opt/intel/mkl/10.0.1.014/lib/32/libmkl_vml_def.so: undefined symbol: DftiCreateDescriptor

Strange as DftiCreateDescriptor is intended for use with the FFT, which I am not using!

I am using MKL 10.0.1.014 and icpc 10.1.011 on Ubuntu 7.04

I will explain what I have done in more detail so that hopefully(!) someone will be able to help.

I have a simple example with:

1) a shared library : cmult.so

This simply calls vcMul with two vectors and is built as follows:

icpc -c -o mult.o mult.cc -w1 -g -O -Wno-deprecated

icpc -shared -o libcmult.so mult.o -L. -Wl,--no-undefined -Wall -lstdc++ -lmkl_intel -lmkl_sequential -lmkl_vml_p4 -lmkl_p4 -lmkl_lapack -lpthread -lm

2) an executable testbrace : cmultexe

This is a simple testbrace that links to cmult.so and calls the multiplication function.

This works perfectly.

3) Matlab Mex function cmult.mexglx

The mex wrapper can call Intel IPP code with no problems, but if linked to cmult.so (using MKL) it gives the runtime error pasted near the start of this post.

Any help is very much appreciated.

I have tried many different linking options, including static linking (which I seem to remember from reading another post is not supported for a shared libraries using MKL 10.X (?)) but the results are always similar! I have also tried calling VML functions straight from the mex wrapper (i.e. without the additional .so as described in 1) ) but still no luck.





0 Kudos
1 Reply
malzfreund
Beginner
402 Views
I don't have experience calling VML functions from Matlab using MKL 10 versions. But with version 9.x.x, I can call VML routines provided by Intel MKL from C++/Fortran mex files without building a shared library.

Make sure the MKL lib is in your path and set the environment variable BLAS_VERSION so that your separately installed libraries are loaded as opposed to the ones shipped with Matlab. E.g.,

export BLAS_VERSION=libmkl.so:libvml.so:libguide.so

Also set LAPACK_VERBOSITY=1 to see if symbols are resolved as desired.

How does your mexopts.sh file look like/how do you build the mex file?
0 Kudos
Reply