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

Netlib BLAS functions don't work correctly #271

Closed
opervush opened this issue Jan 27, 2023 · 3 comments
Closed

Netlib BLAS functions don't work correctly #271

opervush opened this issue Jan 27, 2023 · 3 comments

Comments

@opervush
Copy link

Summary

This problem happened when we link Netlib BLAS and use oneMKL backend with compile-time dispatching. If we link -lonemkl_blas_xxx before -lcblas then cblas_gemm function (from Netlib) doesn't work correctly. We don't see any errors or warnings, but the output matrix doesn't even changed after test.

Version

latest, git hash 45c43ed

Environment

  • oneMKL 2022.2
  • Netlib BLAS 3.9.1
  • Ubuntu 20.04.2 LTS
  • Intel(R) oneAPI DPC++/C++ Compiler 2022.2.0

Steps to reproduce

reproducer.zip

  • clone the repo
  • build oneMKL Interfaces with only oneMKL backend
  • build Netlib BLAS library
  • build the reproducer with the following string: icpx -fsycl -I${CBLASROOT}/include/ -I${ONEMKLROOT}/include/ gemm_usm.cpp -o gemm_usm.out -L${ONEMKLROOT}/lib -lonemkl_blas_mklcpu -L${CBLASROOT}/lib/ -lcblas
  • run gemm_usm.out

Observed behavior

Output:
C[0] = 1 C[1] = 1 C[2] = 1 C[3] = 1 C[4] = 1 C[5] = 1 C[6] = 1 C[7] = 1 C[8] = 1 C[9] = 1

Expected behavior

Output:
C[0] = 1.58397 C[1] = 1.69333 C[2] = 0.511891 C[3] = 0.30601 C[4] = 0.239454 C[5] = 1.61384 C[6] = 0.5664 C[7] = 1.13597 C[8] = 2.24034 C[9] = 1.33806

We can get the correct output in case of link line: icpx -fsycl -I${CBLASROOT}/include/ -I${ONEMKLROOT}/include/ gemm_usm.cpp -o gemm_usm.out -L${CBLASROOT}/lib/ -lcblas -L${ONEMKLROOT}/lib -lonemkl_blas_mklcpu or icpx -fsycl -I${CBLASROOT}/include/ -I${ONEMKLROOT}/include/ gemm_usm.cpp -o gemm_usm.out -L${ONEMKLROOT}/lib -lonemkl -L${CBLASROOT}/lib/ -lcblas

@mmeterel
Copy link
Contributor

@dnhsieh-intel I know you fixed the symbol conflict issue between BLAS CPU backends and Netlib reference library in #251. However, this looks like we still have some issues for some cases. Do you want to take a look at this one?

@dnhsieh-intel
Copy link
Contributor

Sure! Let me check.

@dnhsieh-intel
Copy link
Contributor

Hi @opervush, here are my observations, although they don't fully explain what happened.

First, since libcblas depends on libblas, the problem can be resolved by adding -lblas to the link line, that is:

icpx -fsycl -I${CBLASROOT}/include/ -I${ONEMKLROOT}/include/ gemm_usm.cpp -o gemm_usm.out -L${ONEMKLROOT}/lib -lonemkl_blas_mklcpu -L${CBLASROOT}/lib -lcblas -lblas

It's mysterious to me that -lblas was linked using the two workable link lines you mentioned without including it explicitly.

I saw the following warning when I compiled it the first time, but not afterwards:

/usr/bin/ld: warning: libblas.so.3, needed by <netlib_path>/lib//libcblas.so, not found (try using -rpath or -rpath-link)

Please try if adding -lblas works for you.

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

4 participants