I am trying to optimize a lot of matrix calculations in MKL that requires me to allocate large blocks of memory using something like :
double* test_matrix = (double*)mkl_malloc(n * sizeof(double), 64).
Recently, I have been finding a lot of memory allocation errors that are popping up - which are hard to replicate and even harder to debug. I am worried that there is some internal header data that MKL puts into the heap that I am not accounting for using my current method.
Is there an "official" way of passing a subset of a MKL matrix into another function? Passing a copy would definitely increase my overhead too much. I am currently giving a reference of to the matrix subset like this:
double* a = (double*)mkl_malloc(4 * 4 * sizeof(double), 64);
double* b = (double*)mkl_malloc(4 * 4 * sizeof(double), 64);
double* c = (double*)mkl_malloc(2 * 2 * sizeof(double), 64);
... fill in values for a and b ...
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 2, 2, 2, 1, &a[2], 4, &b[2], 4, 0, c, 2);
cout << "Result is: "<< c[0] << c[1] << c[2] << c[3] << endl;