MATLAB: Matrix multiply crashes Matlab 2014a on a AMD A6-1450 APU, under either Windows 8.1 64-bit or Linux 64-bit

2014a crashintelMATLAB

Attempting to run the following function in Matlab 2014a 64-bit under Windows 8.1 64-bit crashes Matlab (the crash has occurred on all 5 attempts):
function matrix_multiply_crashes_matlab
weights = rand([8 5]);
samples = rand([1024 8]);
output = samples * weights;
end
From stepping in the debugger, the crash happens in the matrix multiply. After the crash Matlab doesn't appear to report a stack dump, I just get a Windows "MATLAB (R2014a) has stopped working dialogue:
Running the same function in Matlab 2014a 64-bit under Linux 64-bit (CentOS 6.5) doesn't cause Matlab to crash.

Best Answer

On further investigation:
1) The MATLAB crash was occurring inside the Intel Math Kernel library version 11.0.5 used by MATLAB 2014a.
2) Creating a standalone C test program for the cblas_dgemm function in the Intel Math Kernel library version 11.0.5 crashed with an illegal instruction on the AMD A6-1450 APU based machine in the same way as MATLAB 2014a crashed when the matrix multiply was used.
3) While setting the environment variable MKL_CBWR=AVX prevented the Intel Math Kernel library from crashing. However, when the cblas_dgemm test program was run under the opcodemix example from the Intel PIN tool ( https://software.intel.com/en-us/articles/pin-a-dynamic-binary-instrumentation-tool ) no AVX instructions were reported as being executed - see the attached opcodemix_MKL_CBWR-AVX.txt
4) As another workaround found that setting the environment variable MKL_DEBUG_CPU_TYPE=4 prevented the crashed and caused AVX instructions to be used by the Intel Math Kernel library - see the attached opcodemix_MKL_DEBUG_CPU_TYPE-4.txt
The conclusion in that the crash is due to the Intel Math Kernel library used by MATLAB 2014a, rather than code which MathWorks have written.
Related Question