Skip to content

Android openblas: On entry to SGEMM parameter number 13 had an illegal value #1014

Closed

Description

@fengshikun

Hello, when I execute the function cblas_sgemm like this:

cblas_sgemm(CblasColMajor, GetT(transa), GetT(transb),
                m, n, k, alpha, A, lda, B, ldb, beta, C, ldc);

it will generate the error:

** On entry to SGEMM parameter number 13 had an illegal value

Could anyone tell me which parameter is wrong? thanks!

Activity

  1. ashwinyes commented on Nov 17, 2016

    @ashwinyes
    Contributor

    This error is hit at the following condition in interface/gemm.c
    if (args.ldc < args.m)

    Suggest you to check the values values of m and ldc. Make sure that ldc is not less than m.

    Thanks.

  2. fengshikun commented on Nov 18, 2016

    @fengshikun
    Author

    @ashwinyes ,thanks, yes, i have checked the parameters:

    static void gemm(Stream<cpu> *stream,
                              bool transa, bool transb,
                              int m, int n, int k, float alpha,
                              const float *A, int lda, const float *B, int ldb,
                              float beta, float *C, int ldc) {
        std::cout << "transa and transb is: "<<transa << " " << transb <<std::endl; 
        std::cout << "CblasColMajor is: " << CblasColMajor << std::endl;
        std::cout << "m , n ,k , lda, ldb, ldc  is " << m << " " << n << " " << k<< " "<< lda<<" "<<ldb << " "<< ldc << std::endl;
        cblas_sgemm(CblasColMajor, GetT(transa), GetT(transb),
                    m, n, k, alpha, A, lda, B, ldb, beta, C, ldc);
        if(m <= 36) {
            for(int i = 0; i < m * n; i++) {
                std::cout << C[i] << std::endl;
            }
        }
      }
    

    It print out like this:

    transa and transb is: 0 0
    CblasColMajor is: 102
    m , n ,k , lda, ldb, ldc  is 36 4 32 36 32 36
     ** On entry to SGEMM  parameter number 13 had an illegal value
    1.04778
    1.04814
    1.0485
    
    

    looks like ldc is already equal to m.

  3. martin-frbg commented on Nov 18, 2016

    @martin-frbg
    Collaborator

    Hm, strange. The coding in interface/gemm.c looks pretty much straightforward to me, the error message is generated before any significant computation or even shuffling of parameters has taken place. Also no other function called from there is even capable of generating this error message, and as it happens in generic code the problem would appear to affect all platforms - unless there is some memory corruption affecting the parameters "seen" by gemm.c.
    Can you check if the same problem happens on other architectures (e.g. x86) as well, or provide a
    standalone program that reproduces the error ? (Alternatively, try adding a printf statement before the
    check(s) in interface/gemm.c that result in "info" being set to 13 and rebuild OpenBLAS to see what passes for m and ldc there. At the very least that should tell if your code actually calls the openblas sgemm function or if it picks up some other local implementation on your system by mistake)

  4. fengshikun commented on Nov 19, 2016

    @fengshikun
    Author

    @martin-frbg , thanks for your reply, i add such piece code to interface/gemm.c

    nrowa = args.m;
        if (transa & 1) nrowa = args.k;
        nrowb = args.k;
        if (transb & 1) nrowb = args.n;
    
        info = -1;
    
        if (args.ldc < args.m) {
            fprintf(stderr, "error happens, m = %4d  n = %d  k = %d  lda = %4d  ldb = %4d  ldc = %4d\n",
             args.m, args.n, args.k, args.lda, args.ldb, args.ldc);
            info = 13;
        }
    

    Then strange thing happens, it print out like this:

    transa and transb is: 0 0
    CblasColMajor is: 102
    m , n ,k , lda, ldb, ldc  is 36 2 32 36 32 36
    error happens, m =   36  n = 2  k = 32  lda = 1117814816  ldb = 11109200  ldc =    0
     ** On entry to SGEMM  parameter number 13 had an illegal value
    1.04778
    1.04814
    1.0485
    

    I don't know why the parameters value changed when they were passed to gemm.c.

  5. ashwinyes commented on Nov 19, 2016

    @ashwinyes
    Contributor

    This basically looks like stack corruption.

    Which processor are you running this on? And can you print the values of all 14 arguments to SGEMM?

  6. brada4 commented on Nov 21, 2016

    @brada4
    Contributor

    WHat netlib blas says about your call?

  7. brada4 commented on Nov 25, 2016

    @brada4
    Contributor

    Looks like calling convention issue. Can you capture crash in gdb? (then t a a bt to get all backtraces)

  8. martin-frbg commented on Dec 21, 2016

    @martin-frbg
    Collaborator

    @fengshikun did you manage to solve this ?

  9. martin-frbg commented on Apr 5, 2017

    @martin-frbg
    Collaborator

    @fengshikun any updates on this ? Without more information it is not even clear if this is an OpenBLAS issue at all, so I am inclined to close this ticket.

  10. martin-frbg commented on Sep 29, 2017

    @martin-frbg
    Collaborator

    Closing as the related mxnet issue has been closed as well for lack of feedback. Please reopen if and when there is more information available.

  11. kyou2000 commented on Oct 30, 2024

    @kyou2000

    I have same problem, it is "On entry to SGEMM parameter number 10 had an illegal value", my m,n,k dim is 2,2,3. but when I set it to same dim, it will not cause this error, I need to calculate matrices of different shapes. How to fix it.

  12. martin-frbg commented on Oct 30, 2024

    @martin-frbg
    Collaborator

    See the definition of SGEMM in e.g. the Reference BLAS https://netlib.org/lapack/explore-html-3.6.1/db/dc9/group__single__blas__level3_gafe51bacb54592ff5de056acabd83c260.html or the Intel MKL - "parameter number 10" is ldb, the first ("leading") dimension of your array b, which must be at least as large as 'k' (or as large as 'n' if you are using the transpose of b)
    (I'm sure it would help if these functions would provide a clearer error message, but the standard was established over 40 years ago when computer hardware was quite different from today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions