When attempting to use the cblas_dgemm() function, I am experiencing a segmentation fault. The segfault occurs only when running the code on a Linux machine (works on a Windows machine).
The code is set up as follows:
#define ML_ROWS_A 5
#define ML_COLS_B 7
#define ML_COLS_A 6
double a_d[ML_ROWS_A*ML_COLS_A], b_d[ML_COLS_A*ML_COLS_B], c_d[ML_ROWS_A*ML_COLS_B];
const double alpha = 1.0;
const double beta = 1.0;
int m = ML_ROWS_A;
int n = ML_COLS_B;
int n = ML_COLS_A;
cblas_dgemm( CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, alpha, a_d, k, b_d, n, beta, c_d, n );
If I add the calls:
int n_alloc;
mkl_mem_stat(&n_alloc);
Before calling cblas_dgemm(), the function works correctly (though no memory has been allocated through mkl calls). Similarly, if I instead allocate memory through an mkl call (such as mkl_calloc) before calling cblass_dgemm() the function works correctly (even though I do not actually pass the allocated memory to the function call). Can anyone explain why the segfault is occurring and why calling certain mkl functions before cblass_dgemm remedies the issue?