c++intel-mklcblas

mkl cblas_dgemm wrong parameter


I tried to use mkl cblas_dgemm to compute matrix matrix multiplication.

As I know, lda, ldb, ldc should be the number of columns for simple row major matrix. I tried to do following:

double a[3 * 2] = { 1,2,3,4,5,6 };      // 3 x 2 matrix
double b[2 * 4] = { 1,2,3,4,5,6,7,8 };  // 2 x 4 matrix
double c[3 * 4] = { 0, };               // 3 x 4 matrix

// c <- 1.0 * (a*b) + 0.0 * c
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 3, 2, 4, 1.0, a, 2, b, 4, 0.0, c, 4);
//            rowmajor       no trans      no trans    m  k  n  alph A lda B ldb beta C ldc

but it gave me an error message and c is not updated.

Intel MKL ERROR: Parameter 9 was incorrect on entry to cblas_dgemm.

Parameter 9 is lda

what is wrong with my code?


Solution

  • I was wrong. The argument ordering is m,n,k as commented above