I'm new to Magma and I'm trying to use it in Matlab via a mex-files, but I ran into some troubles with it.

First of all, as far as I can tell everything is installed correctly (on a 64bit Linux machine) and all the tests and examples that come with Magma run fine. Also, when I put together some simple tests in C++ (i.e. creating random complex matrices and calcuting the eigenvalues with magma_zgeev) everything works. However, if I try to do the same test in a mex-file, Matlab completely crashes with a segmentation violation at the point where the mex-file calls magma_zgeev. Here's the stack trace:

- Code: Select all
`Stack Trace (from fault):`

[ 0] 0x00007f7f867b02fb /opt/intel/mkl/lib/intel64/libmkl_avx2.so+10638075 mkl_lapack_ps_avx2_xzlange+00000187

[ 1] 0x00007f7f64eda080 /usr/local/MATLAB/R2014b/bin/glnxa64/mkl.so+03129472 mkl_lapack_ps_xzlange+00000224

[ 2] 0x00007f7f64d6280d /usr/local/MATLAB/R2014b/bin/glnxa64/mkl.so+01591309 mkl_lapack_zlange+00001821

[ 3] 0x00007f8035e1a623 /usr/local/MATLAB/R2014b/bin/glnxa64/../../sys/os/glnxa64/libiomp5.so+00558627 __kmp_invoke_microtask+00000147

[ 4] 0x00007f8035df2f64 /usr/local/MATLAB/R2014b/bin/glnxa64/../../sys/os/glnxa64/libiomp5.so+00397156

[ 5] 0x00007f8035df1e02 /usr/local/MATLAB/R2014b/bin/glnxa64/../../sys/os/glnxa64/libiomp5.so+00392706

[ 6] 0x00007f8035e1a8d9 /usr/local/MATLAB/R2014b/bin/glnxa64/../../sys/os/glnxa64/libiomp5.so+00559321

[ 7] 0x00007f80492f90a4 /lib64/libpthread.so.0+00032932

[ 8] 0x00007f804902e02d /lib64/libc.so.6+00938029 clone+00000109

From this I gathered that Matlab is switching from it's own copy of MKL to Intel MKL, which I installed separately, and that there is some mismatch happening between the two implementations of MKL. I noticed that Matlab's MKL version is 11.1.1 and the one that is installed separately is version 11.3.3. So, I'm not quite sure what to do next from this point... I guess I could try to update Matlab to possibly get Matlab's MKL to version 11.3.3, but I would assume that that would not be an elegant way since Matlab would still be loading libraries from two different places. On the other hand, I read on the Mathworks forums that there are some ways to force Matlab into using the external MKL by setting some environment variables like LD_LIBRARY_PATH or BLAS_VERSION, but people from Mathworks support generally seem to discourage this method on their forums and I'm also not sure what exactly I should set them to in this case.

So is there some proper way to avoid such conflicts of the libraries when using Magma in Matlab?

Best regards,

Jens