I'm working with OpenBLAS on Windows and am experiencing crashes. I'm using test code bellow (entire program), taken from Intel MKL from here (I slightly modified it). The same problem is with other function calls. With step by step debugging, the crash occurs after return 0
in main. The loop that outputs the matrix print the correct result.
double *A, *B, *C;
int m, n, k, i, j;
double alpha, beta;
m = 2, k = 2, n = 2;
alpha = 1.0; beta = 0.0;
A = (double *) malloc(m*k*sizeof(double));
B = (double *) malloc(k*n*sizeof(double));
C = (double *) malloc(m*n*sizeof(double));
for (i = 0; i < (m*k); i++) A[i] = (double) (i + 1);
for (i = 0; i < (k*n); i++) B[i] = (double) (-i - 1);
for (i = 0; i < (m*n); i++) C[i] = (double) 0.0;
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,
m, n, k, alpha, A, k, B, n, beta, C, n);
printf("\n Top left corner of matrix C: \n");
for (i = 0; i<min(m, 6); i++)
{
for (j = 0; j<min(n, 6); j++)
printf("%12.5G", C[j + i*n]);
printf("\n");
}
free(A);
free(B);
free(C);
The crash occurs after exit(mainret)
is executed.
#else /* !defined (_WINMAIN_) && defined (_CRT_APP) */
if ( !managedapp )
{
#ifndef _CRT_APP
exit(mainret);
#else
_exit_app();
#endif /* _CRT_APP */
#if !defined(_WINMAIN_) && defined(_CRT_APP)
/* WINAPI_FAMILY_APP "Windows" applications should never reach here,
* but Console applications will if they do not exit the process.
* So, terminate the process for Console apps only
*/
ExitProcess(mainret);
#endif
}
The first thing I thought of was ESP value, which might get corrupted if function calling conventions do not match (I'm using prebuilt MinGW OpenBLAS 0.2.14 libraries), but all ESP checks in debug build pass successfully. I'm using MSVC++ compiler and built assembly is 32-bit.
How can I pinpoint the problem more precisely or what might be the cause behind this crashes?