Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When run Eigen with Openblas , ** On entry to DGEMM parameter number 13 had an illegal value #4232

Closed
wenxingguo opened this issue Sep 19, 2023 · 11 comments

Comments

@wenxingguo
Copy link

When I run the following code using Eigen3.4 and openblas I get an error

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

environment: windows10 with mingw64
if compile without fortran, the error disappear.

#define EIGEN_USE_BLAS
#include <sys/time.h>
#include <Eigen/Dense>
#include <iostream>

int main(int argc, char* argv[])
{
    struct timeval t1, t2;
    double timeuse;
    gettimeofday(&t1, NULL);
    Eigen::MatrixXd M1, M2;
    M1.resize(10, 10);
    M2.resize(10, 10);
    Eigen::MatrixXd M3 = M1 * M2;

    gettimeofday(&t2, NULL);
    timeuse = (t2.tv_sec - t1.tv_sec)
        + (double)(t2.tv_usec - t1.tv_usec) / 1000000.0;

    std::cout << "time = " << timeuse << std::endl;
    return 0;
}
@martin-frbg
Copy link
Collaborator

Strange, Fortran code should play no role in OpenBLAS' DGEMM call itself. The error message suggests that the dimension of M3 is too small (leading dimension smaller than the number of rows in M1) - I notice that your sample code omits dimensioning of M3 and assigning any values in M1, M2.

@wenxingguo
Copy link
Author

Strange, Fortran code should play no role in OpenBLAS' DGEMM call itself. The error message suggests that the dimension of M3 is too small (leading dimension smaller than the number of rows in M1) - I notice that your sample code omits dimensioning of M3 and assigning any values in M1, M2.

When I make M1 and M2 both 10000by10000, the time consumption is 0.141997 seconds. This is obviously wrong, because when I use mkl+Eigen3 or matlab, the time consumption is 6-7 seconds.

@wenxingguo
Copy link
Author

The same problem also occurs on Freebsd13

@martin-frbg
Copy link
Collaborator

0.14 seconds is probably about right for showing the error message, but this does not tell us anything. Are you using the exact same code (and Eigen version) with MKL ? And which version of OpenBLAS, did you compile it yourself or use a precompiled package ? There is a build-time option to compile everything with 8-byte "long" values for integer arguments instead of the usual 4 bytes, which will corrupt function arguments when it is mismatched with what the other parts of the code use.

@wenxingguo
Copy link
Author

Yes I used the same code, just replaced the macro EIGEN_USE_BLAS with EIGEN_USE_MKL_ALL
The following is my cmake command to compile openblas-0.3.24
The version of Eigen is 3.4.0

Under Release build type, when I change M1 and M2 to MatrixXf, the program crush directly and does not give any output. In Debug mode, ** On entry to DGEMM parameter number 13 had an illegal value continues to appear. This is a strange question.

The following is my cmake command to compile openblas
cmake -G"Ninja" -DCMAKE_BUILD_TYPE=Release -DTARGET=GENERIC -DDYNAMIC_ARCH=ON -DCMAKE_INSTALL_PREFIX=C:/opt/Openblas -DBINARY=64 -DINTERFACE64=1 -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DUSE_THREAD=ON -DNUM_THREADS=64 -DUSE_OPENMP=ON ./

@martin-frbg
Copy link
Collaborator

Does Eigen require OpenBLAS to be built with "long" integer (the INTERFACE64=1 option) ?

@brada4
Copy link
Contributor

brada4 commented Sep 20, 2023

It uses '* int' for dimension sizes in blas.h header wrapping fortran blas. Means lp64 ie 32bit integer dimensions. Also dont build cblas, eigen intercepts that and inlines small fixed calls as macros.

@wenxingguo
Copy link
Author

Does Eigen require OpenBLAS to be built with "long" integer (the INTERFACE64=1 option) ?

Yes, this works when I set -DINTERFACE64=0, but I don't know what this parameter represents

@wenxingguo
Copy link
Author

Does Eigen require OpenBLAS to be built with "long" integer (the INTERFACE64=1 option) ?

Yes, this works when I set -DINTERFACE64=0, but I don't know what this parameter represents

#1763

@martin-frbg
Copy link
Collaborator

see Makefile.rule for (short) explanation of parameters - with INTERFACE64=1 you make every C "int" into a "long" that takes up 8 bytes (64bits) instead of the normal 4. The advantage is that it can store larger numbers, so you can address huge arrays with it - but all parts of a program must use the same size value or you get read errors and crashes.

@brada4
Copy link
Contributor

brada4 commented Sep 20, 2023

That random link does not pertain eigen.
You have to use 32bit integers as eigen expects. See blas/blas.h in eigen's source tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants