Pivot array changes between Debug and Release builds when using DGETRF (Intel Fortran + MKL)

Hi everyone,

I’m facing an issue where the pivot array (IPIV) changes between Debug and Release builds when calling DGETRF in Visual Studio. In the Release build, IPIV sometimes differs, which leads to incorrect or unstable results from DGETRS and the calculations that follow. I’m using Intel OneAPI with MKL (sequential).

If I enable the “Check Stack Frame” option and set it to Yes, the results between Debug and Release become consistent, but this makes the Release build much slower.

I’m trying to understand why this discrepancy occurs and whether there’s a more efficient way to fix it without affecting performance.

I’m happy to share more details such as code snippets, build settings, or compiler options if needed.

Thank you in advance for any help or suggestions. I’ll be glad to share more details (code snippet, build settings, etc.) if needed.

Thanks in advance for any insights!

Hi @Sban welcome to the community!

A couple of things. First, have you calculated the condition number of your matrix? You might have a weird matrix and changing from debug to release is exacerbating this problem.

Second, have you tried using OpenBLAS or another LAPACK implementation? In the worst case scenario, you can build your own NetlibLapack and check against the reference.

My guess is that your matrix is weird.

Cheers