Documented MKL crash

Documented MKL crash

I have created a small case that demonstrates that MKL crashes when used from MATLAB. 

The MATLAB mex file should be created using MATLAB r2013a on linux64x86. The key is if the mex file, which is a shared object, is linked with libiomp5 then MKL crashes. If the mex file is linked without it works fine. You can reproduce the crash as follows

  1. Edit i.e. adjust paths.
  2. sh
  3. matlab
  4. testgemm
  5. MATLAB should crash now.

Try it again but remove -liomp5 in 
Why does it crash when libiomp5 is linked into the mex file? 

The system does not allow me to attached the needed files on this post but will try in the reply.


9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


It looks the files are not upload yet. Since Matlab itself is also using Intel MKL internally, to avoid conflicts with some other version MKL, it is suggested to build one customer DLL , then link the MKL to that customer DLL.  Could you check these two articles for the steps:

It takes windows at the example, it also has similar tools is also at mkl/tools/builder

Also have a check if you have other versions of openmp libraries from the matlab?


Our customers hate when we increase the number of DLLs in our product We try the best to keep the number of DLLs down.

Note openmp is not used as all in the mex file or in the test example. All I check if it is matter whether with link it or not.

I have tried uploading again.


Downloadapplication/zip crash.zip1.34 KB

The links you refrence is for Windows and seems to somewhat legacy information. Note my initial post explicit says Linux. The example has uploaded now.

I have now posted this issue on Premier support since I did not get any reply here. I will summarize the findings here if anything comes out of it.


I am trying to find the matlab to reproduce this problem. Also I have a few questions when I review your test code here:
1)The code is actually linking with libmkl_sequential.a, the sequential MKL libraries, so it actually does not need to add the –liomp5. Is the OpenMP runtime library added only for testing?
2)In the previous post, the list the code is crash bellow  when adding OpenMP:
Is this still the code where it crash now? This code is actually not related to the OpenMP.
3)It looks you want to test whether OpenMP library is link it or not. Matlab is internally also using OpenMP, and include OpenMP libraries, so the system may have two copies of OpenMP libraries. Have you check if the OpenMP library you are linking with (the OpenMP with the MKL) is the same one when the cod is running?


I do understand that OpenMP is used for nothing in the code. This is a small illustrative example based on some real world code which is way more complicated. The code is very small and should be very easy to check whether we call mkl_disable_fast_mm(). As far as I remeber we do not.

Can you reproduce the crash? I think it would nice to understand why it crash even if we do something wrong because then we understand the assumptions behind OpenMP and MKL better.

I am not sure if MATLAB uses the same version on OpenMP. You can see my  my blog post about why your reply about whether MATLAB and my application uses the same OpenMP library is one I hate. If that is an issue then we cannot OpenMP in the library we sell to our customers. 

As far I understand we should be able to link with another version of MKL than MATLAB when we link with the static sequential version. Am I wrong on this assumption?



>>As far I understand we should be able to link with another version of MKL than MATLAB when we link with the static sequential versionYes, this is true.


As to reproduce this problem, I am working with MKL code owner to have some further code review, and locate some more info.  Now we are still working on to setup the matlab machine.




Leave a Comment

Please sign in to add a comment. Not a member? Join today