On entry to SGEMM, parameter 10 had an illegal value

4,545 views
Skip to first unread message

Sean Duggan

unread,
Aug 14, 2013, 10:04:42 AM8/14/13
to openbla...@googlegroups.com
I'm probably missing something obvious, but I'm trying to get the provided Windows binaries working in a program compiling in visual studio. As a test bed, I have a 4x5 (row-major) matrix multiplied by a 5x4 matrix. As I understand the documentation at http://developer.apple.com/library/mac/DOCUMENTATION/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/c/func/cblas_sgemm, that should be:
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 5, 1, &(A[0][0]), 4, &(B[0][0]), 5, 0, &(C[0][0]), 4);

However, when I try that, I get an error message of "On entry to SGEMM, parameter 10 had an illegal value". Looking at the source code, I think that this is the relevant bit that determines the error message:

nrowb = args.k;
  if (transb & 1) nrowb = args.n;
....
if (args.ldb < nrowb)  info = 10;

Above, K is 5, as is ldb. 5 is not less than 5, so I shouldn't be getting this error message. Does anyone have a potential explanation?

Zhang Xianyi

unread,
Aug 14, 2013, 10:38:22 AM8/14/13
to Sean Duggan, openbla...@googlegroups.com
Hi Sean,

I think lda and ldb are wrong.

You can try this.

cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 5, 1, &(A[0][0]), 5, &(B[0][0]), 4, 0, &(C[0][0]), 4);



2013/8/14 Sean Duggan <sean....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "OpenBLAS-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openblas-user...@googlegroups.com.
To post to this group, send email to openbla...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sean Duggan

unread,
Aug 14, 2013, 11:13:51 AM8/14/13
to Zhang Xianyi, openbla...@googlegroups.com
That did the trick. Am I mis-understanding the description of the parameters? It seemed like a 5x4 matrix would have 5 as its value for the first dimension, and it seems like the text above would be more likely to trigger it, providing a value where ldb actually is less than K.
--
Sean Duggan                Sean....@gmail.com
"It's easy to win forgiveness for being wrong; being right is what gets you into real trouble." -Bjarne Stroustrup

Sean Duggan

unread,
Aug 15, 2013, 3:05:09 PM8/15/13
to openbla...@googlegroups.com, Zhang Xianyi
Just to confuse things, it looks like the last parameter is based off of the number of rows to get it to work. Quick question when doing a transpose, do you change any of the parameters other than the last one, to indicate the size of the end matrix? To give a concrete example, without transposition, I have the following without transposing anything:
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, A.rows(), B.cols(), A.cols(), 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, A.rows());

If I were transposing the first, and  multiplying it  which of the following works?
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.rows(), B.cols(), A.cols(), 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, A.rows());
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.cols(), B.cols(), A.cols(), 1, ptrA, A.rows(), ptrB, B.cols(), 0, ptrC, A.rows());
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.cols(), B.cols(), A.cols(), 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, A.rows());
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.rows(), B.cols(), A.cols(), 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, A.cols());
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.cols(), B.cols(), A.cols(), 1, ptrA, A.rows(), ptrB, B.cols(), 0, ptrC, A.cols());
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, A.cols(), B.cols(), A.cols(), 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, A.cols());

Essentially, I don't know if I'm supplying the size of the A matrix before or after transpose and whether one needs to tell the function call to handle the final matrix differently.

On Wednesday, August 14, 2013 11:13:51 AM UTC-4, Sean Duggan wrote:
That did the trick. Am I mis-understanding the description of the parameters? It seemed like a 5x4 matrix would have 5 as its value for the first dimension, and it seems like the text above would be more likely to trigger it, providing a value where ldb actually is less than K.
On Wed, Aug 14, 2013 at 10:38 AM, Zhang Xianyi <traits...@gmail.com> wrote:
Hi Sean,

I think lda and ldb are wrong.

You can try this.

cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 5, 1, &(A[0][0]), 5, &(B[0][0]), 4, 0, &(C[0][0]), 4);



2013/8/14 Sean Duggan <sean....@gmail.com>
I'm probably missing something obvious, but I'm trying to get the provided Windows binaries working in a program compiling in visual studio. As a test bed, I have a 4x5 (row-major) matrix multiplied by a 5x4 matrix. As I understand the documentation at http://developer.apple.com/library/mac/DOCUMENTATION/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/c/func/cblas_sgemm, that should be:
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, 4, 5, 1, &(A[0][0]), 4, &(B[0][0]), 5, 0, &(C[0][0]), 4);

However, when I try that, I get an error message of "On entry to SGEMM, parameter 10 had an illegal value". Looking at the source code, I think that this is the relevant bit that determines the error message:

nrowb = args.k;
  if (transb & 1) nrowb = args.n;
....
if (args.ldb < nrowb)  info = 10;

Above, K is 5, as is ldb. 5 is not less than 5, so I shouldn't be getting this error message. Does anyone have a potential explanation?

--
You received this message because you are subscribed to the Google Groups "OpenBLAS-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openblas-users+unsubscribe@googlegroups.com.
To post to this group, send email to openblas-users@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Sean Duggan

unread,
Aug 16, 2013, 2:13:20 PM8/16/13
to openbla...@googlegroups.com, Zhang Xianyi
Alright. I've figured it out. This is what I wound up with for my helper function which takes in our Matrix class and transpose arguments and ejects a result:
  int A_m = (tranA ? A.cols() : A.rows() );
  int A_n = (tranA ? A.rows() : A.cols() );
  int B_m = (tranB ? B.cols() : B.rows() );
  int B_n = (tranB ? B.rows() : B.cols() );
  if (A_n != B_m)
    ISI_THROW(IllegalArgumentException("Mismatch between source matrices sizes"));

  this -> resize(A_m, B_n, 0);

  Float* ptrA = A.el_[0];
  Float* ptrB = B.el_[0];
  Float* ptrC = this->el_[0];

  cblas_sgemm(CblasRowMajor, tranA ? CblasTrans : CblasNoTrans, tranB ? CblasTrans : CblasNoTrans, 
    A_m, B_n, A_n, 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, B_n);

So, in short, the first set of dimensions needs to be converted for the transposed dimensions, the latter set don't, and need to refer to columns when using C++ Row Major arrays.

Zhang Xianyi

unread,
Aug 17, 2013, 11:56:29 AM8/17/13
to Sean Duggan, openbla...@googlegroups.com
Sorry for the late reply.


2013/8/17 Sean Duggan <sean....@gmail.com>

Alright. I've figured it out. This is what I wound up with for my helper function which takes in our Matrix class and transpose arguments and ejects a result:
  int A_m = (tranA ? A.cols() : A.rows() );
  int A_n = (tranA ? A.rows() : A.cols() );
  int B_m = (tranB ? B.cols() : B.rows() );
  int B_n = (tranB ? B.rows() : B.cols() );
  if (A_n != B_m)
    ISI_THROW(IllegalArgumentException("Mismatch between source matrices sizes"));

  this -> resize(A_m, B_n, 0);

  Float* ptrA = A.el_[0];
  Float* ptrB = B.el_[0];
  Float* ptrC = this->el_[0];

  cblas_sgemm(CblasRowMajor, tranA ? CblasTrans : CblasNoTrans, tranB ? CblasTrans : CblasNoTrans, 
    A_m, B_n, A_n, 1, ptrA, A.cols(), ptrB, B.cols(), 0, ptrC, B_n);

So, in short, the first set of dimensions needs to be converted for the transposed dimensions, the latter set don't, and need to refer to columns when using C++ Row Major arrays.

Yes, you are right.


m

INTEGER. Specifies the number of rows of the matrix op(A) and of the matrix C. The value of m must be at least zero.


n

INTEGER. Specifies the number of columns of the matrix op(B) and the number of columns of the matrix C.


k

INTEGER. Specifies the number of columns of the matrix op(A) and the number of rows of the matrix op(B).



The m,n,k need change with transpose.

Xianyi
Reply all
Reply to author
Forward
0 new messages