Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
18 Views

cblas_cgemm problems when m < k

Hi everybody,
I'm trying to use cblas_cgemm in order to perform the operation C = scale*A*conj(A').

Here is the relavent section of code:
assume that m, n, and k are defined with specific values
m = n (because I am doing A*conj(A'))
k is independent of m or n

vector A;
A.resize(m,k);
initialize(A); // populate A w/ some values
int scale = some initial value;
MKL_Complex8 mkl_c8_zero; mkl_c8_zero.real = 0; mkl_c8_zero.imag = 0;

cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasConjTrans, m, n, k, &scale, &A[0], m, &A[0], n, &mkl_c8_zero, &R[0], m);

I run cblas_cgemm in a loop, with k changing but m & n remaining constant. When m < k, cblas gives an error: "Parameter 9 upon entry to cblas_cgemm incorrect."

Here is a sample output of the loop, showing the values of m, n, k, lda, and ldb and the errors. If no error is shown, it means that the cblas_cgemm executed properly.
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 7: lda = 10: ldb = 10
m = 10: n = 10: k = 8: lda = 10: ldb = 10
m = 10: n = 10: k = 9: lda = 10: ldb = 10
m = 10: n = 10: k = 10: lda = 10: ldb = 10
m = 10: n = 10: k = 11: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 12: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 11: lda = 10: ldb = 10

MKL ERROR: Parameter 9 was incorrect on entry to cblas_cgemm
m = 10: n = 10: k = 10: lda = 10: ldb = 10
m = 10: n = 10: k = 9: lda = 10: ldb = 10
m = 10: n = 10: k = 8: lda = 10: ldb = 10
m = 10: n = 10: k = 7: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10
m = 10: n = 10: k = 6: lda = 10: ldb = 10

I have tried changing the ldb parameter to k, but I get the same errors at the same times...

Any assistance would be appreciated.

Thanks,
Kiran
0 Kudos
1 Reply
Highlighted
Black Belt
18 Views

See the example cblas_cgemmx.c in the MKL examples\cblas\source directory. In particular, see these lines (around line-100):

[cpp]      if( order == CblasRowMajor ) {
lda=cmaxa;
ldb=cmaxb;
ldc=cmaxc;
} else {
lda=rmaxa;
ldb=rmaxb;
ldc=rmaxc;
}
[/cpp]


When you use CblasRowMajor order for storing matrices, the arguments ldA, ldB, ldC should be the maximum row-lengths of A, B and C, in contrast to the values that would be given if CblasColMajor were used, when they would be the maximum column-lengths.

I think that the MKL documentation should make this requirement clearer, since C/C++ programmers should not be expected to know about the Fortran conventions for storing matrices

When you post code related to a difficulty that you are trying to overcome, please post complete code that is ready to be fed to the compiler, since it is only then that someone here can reproduce the problem; doing so is often the initial step towards finding a solution.
0 Kudos