How do I link my mex file to mkl?

1 visualización (últimos 30 días)
Jed
Jed el 18 de Nov. de 2015
Comentada: Steven Lord el 22 de Feb. de 2021
I am trying to create a mex file that uses MKL. I know that Matlab itself uses the MKL library for some of its computational routines (e.g., ffts), but perhaps it is a different version and there are some conflicts? In any case, I have written a C program that is structured like this:
<a bunch of code including a function called mkl_test>
int main()
{
mkl_test();
}
I can compile it and run it just fine. I then modify it into a mex function as follows:
#include <mex.h>
<a bunch of code including a function called mkl_test>
void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
mkl_test();
}
I can successully run the mex compilation, but when I attemp to run it, I get the following:
MKL FATAL ERROR: Cannot load neither libmkl_avx.so nor libmkl_def.so
... then Matlab crashes.
Any help would be greatly appreciated!

Respuestas (1)

Heiko Weichelt
Heiko Weichelt el 18 de Feb. de 2021
MATLAB uses Intel's MKL as BLAS and LAPACK implementation, not for FFT, however.
To see how to use those symbols inside a MEX fucntion, follow the instructions on https://www.mathworks.com/help/matlab/matlab_external/calling-lapack-and-blas-functions-from-mex-files.html.
Notice, that the bundled MKL library shipped with MATLAB only contains BLAS and LAPACK symbols and additional MKL symbols that those symbols depend on. MATLAB's MKL library does not contain all MKL symbols.
  3 comentarios
Jed
Jed el 22 de Feb. de 2021
Also... I think I ended up fixing this with static linking or something? I don't remember ... it was >5 years ago.
Steven Lord
Steven Lord el 22 de Feb. de 2021
As far as I remember we've been using the FFTW library for computing FFTs in MATLAB since about 2001. See this Cleve's Corner article.

Iniciar sesión para comentar.

Categorías

Más información sobre Write C Functions Callable from MATLAB (MEX Files) en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by