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

Unable to set TARGET when building OpenBlas #77

Closed
kfuseini opened this issue Aug 23, 2021 · 4 comments
Closed

Unable to set TARGET when building OpenBlas #77

kfuseini opened this issue Aug 23, 2021 · 4 comments

Comments

@kfuseini
Copy link

Hi,

I'm running into an issue where I am unable to compile my project (which depends on ndarray, which in turn depends on open-blas v0.10.4) due to the cpu not being detected properly (Intel(R) Xeon(R) Silver 4310 CPU). I have already tried setting the OPENBLAS_TARGET environment variable with no success:

$ OPENBLAS_TARGET=SANDYBRIDGE cargo build --features cuda,rayon --release
   Compiling openblas-src v0.10.4
error: failed to run custom build command for `openblas-src v0.10.4`

Caused by:
  process didn't exit successfully: `/home/ubuntu/project/target/release/build/openblas-src-932ce4274540924a/build-script-build` (exit status: 101)
  --- stderr
  getarch_2nd.c: In function ‘main’:
  getarch_2nd.c:14:35: error: ‘SGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘SBGEMM_DEFAULT_UNROLL_M’?
     14 |     printf("SGEMM_UNROLL_M=%d\n", SGEMM_DEFAULT_UNROLL_M);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   SBGEMM_DEFAULT_UNROLL_M
  getarch_2nd.c:14:35: note: each undeclared identifier is reported only once for each function it appears in
  getarch_2nd.c:15:35: error: ‘SGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘SBGEMM_DEFAULT_UNROLL_N’?
     15 |     printf("SGEMM_UNROLL_N=%d\n", SGEMM_DEFAULT_UNROLL_N);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   SBGEMM_DEFAULT_UNROLL_N
  getarch_2nd.c:16:35: error: ‘DGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_M’?
     16 |     printf("DGEMM_UNROLL_M=%d\n", DGEMM_DEFAULT_UNROLL_M);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_M
  getarch_2nd.c:17:35: error: ‘DGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_N’?
     17 |     printf("DGEMM_UNROLL_N=%d\n", DGEMM_DEFAULT_UNROLL_N);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_N
  getarch_2nd.c:21:35: error: ‘CGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_M’?
     21 |     printf("CGEMM_UNROLL_M=%d\n", CGEMM_DEFAULT_UNROLL_M);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_M
  getarch_2nd.c:22:35: error: ‘CGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_N’?
     22 |     printf("CGEMM_UNROLL_N=%d\n", CGEMM_DEFAULT_UNROLL_N);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_N
  getarch_2nd.c:23:35: error: ‘ZGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_M’?
     23 |     printf("ZGEMM_UNROLL_M=%d\n", ZGEMM_DEFAULT_UNROLL_M);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_M
  getarch_2nd.c:24:35: error: ‘ZGEMM_DEFAULT_UNROLL_N’ undeclared (first use in this function); did you mean ‘XGEMM_DEFAULT_UNROLL_N’?
     24 |     printf("ZGEMM_UNROLL_N=%d\n", ZGEMM_DEFAULT_UNROLL_N);
        |                                   ^~~~~~~~~~~~~~~~~~~~~~
        |                                   XGEMM_DEFAULT_UNROLL_N
  getarch_2nd.c:71:50: error: ‘SGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘SBGEMM_DEFAULT_Q’?
     71 |     printf("#define SLOCAL_BUFFER_SIZE\t%ld\n", (SGEMM_DEFAULT_Q * SGEMM_DEFAULT_UNROLL_N * 4 * 1 *  sizeof(float)));
        |                                                  ^~~~~~~~~~~~~~~
        |                                                  SBGEMM_DEFAULT_Q
  getarch_2nd.c:72:50: error: ‘DGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘GEMM_DEFAULT_Q’?
     72 |     printf("#define DLOCAL_BUFFER_SIZE\t%ld\n", (DGEMM_DEFAULT_Q * DGEMM_DEFAULT_UNROLL_N * 2 * 1 *  sizeof(double)));
        |                                                  ^~~~~~~~~~~~~~~
        |                                                  GEMM_DEFAULT_Q
  getarch_2nd.c:73:50: error: ‘CGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘CGEMM_DEFAULT_R’?
     73 |     printf("#define CLOCAL_BUFFER_SIZE\t%ld\n", (CGEMM_DEFAULT_Q * CGEMM_DEFAULT_UNROLL_N * 4 * 2 *  sizeof(float)));
        |                                                  ^~~~~~~~~~~~~~~
        |                                                  CGEMM_DEFAULT_R
  getarch_2nd.c:74:50: error: ‘ZGEMM_DEFAULT_Q’ undeclared (first use in this function); did you mean ‘ZGEMM_DEFAULT_R’?
     74 |     printf("#define ZLOCAL_BUFFER_SIZE\t%ld\n", (ZGEMM_DEFAULT_Q * ZGEMM_DEFAULT_UNROLL_N * 2 * 2 *  sizeof(double)));
        |                                                  ^~~~~~~~~~~~~~~
        |                                                  ZGEMM_DEFAULT_R
  make: *** [Makefile.prebuild:74: getarch_2nd] Error 1
  Makefile:160: *** OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail..  Stop.

  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NonZeroExitStatus { status: 2 }', /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/openblas-src-0.10.4/build.rs:150:45
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Is it possible to set the target variable or am I running into a separate build issue?

@IvanUkhov
Copy link
Member

Hello, in order to confirm that his is a problem with the Rust create, please try to compile OpenBLAS from source as it is described in its repository.

@nemosupremo
Copy link
Contributor

nemosupremo commented Aug 24, 2021

@IvanUkhov

I'm able to compile OpenBLAS 0.3.14 successfully (this is same machine as listed in OP).

$ git clone https://github.com/xianyi/OpenBLAS.git
$ cd OpenBLAS/
$ git checkout v0.3.14
$ make # generates same error as above
getarch_2nd.c: In function ‘main’:
getarch_2nd.c:14:35: error: ‘SGEMM_DEFAULT_UNROLL_M’ undeclared (first use in this function); did you mean ‘SBGEMM_DEFAULT_UNROLL_M’?
   14 |     printf("SGEMM_UNROLL_M=%d\n", SGEMM_DEFAULT_UNROLL_M);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~
      |                                   SBGEMM_DEFAULT_UNROLL_M
Makefile:160: *** OpenBLAS: Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for the detail..  Stop.
$ make TARGET=SANDYBRIDGE
make[1]: Leaving directory '/home/ubuntu/OpenBLAS/exports'

 OpenBLAS build complete. (BLAS CBLAS LAPACK LAPACKE)

This output shows I'm able to build OpenBLAS 0.3.14 successfully, from source, when specifying the TARGET variable. My guess here is OPENBLAS_TARGET isn't being detected properly?

For reference here is what version of openblas our project is using:

$ cargo tree | grep openblas
│   │   ├── openblas-src v0.10.4
│   │   │   └── openblas-build v0.1.1

@IvanUkhov
Copy link
Member

IvanUkhov commented Aug 25, 2021

When #[cfg(not(target_os = "linux"))], OPENBLAS_TARGET is processed directly in build.rs :

https://github.com/blas-lapack-rs/openblas-src/blob/master/openblas-src/build.rs#L170

When not, it is done in openblas-build:

https://github.com/blas-lapack-rs/openblas-src/blob/master/openblas-build/src/build.rs#L35

However, I don’t see that the target is populated. Probably, it has to be done still in build.rs somewhere here:

https://github.com/blas-lapack-rs/openblas-src/blob/master/openblas-src/build.rs#L95

Similarly to:

https://github.com/blas-lapack-rs/openblas-src/blob/master/openblas-src/build.rs#L203

However, it is probably worth checking with the author.

@termoshtt, where should OPENBLAS_* environment variables should be handled according to the original design?

@termoshtt
Copy link
Member

$OPENBLAS_TARGET is now handled #78

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

No branches or pull requests

4 participants