#29084 closed defect (fixed)

Make fflas_ffpack detect and use system openblas on Arch

Reported by: arojas Owned by:
Priority: major Milestone: sage-9.1
Component: build Keywords:
Cc: dimpase, vdelecroix Merged in:
Authors: Antonio Rojas Reviewers: Dima Pasechnik, Matthias Koeppe
Report Upstream: N/A Work issues:
Branch: 06f46eb (Commits, GitHub, GitLab) Commit: 06f46ebaa41a620016d8e04c8c27045acbcd3ae0
Dependencies: #29051, #29071 Stopgaps:

Status badges

Description (last modified by arojas)

The fflas-ffpack spkg-install passes the output of pkg-config --libs cblas as link flags. The fflas-ffpack uses these flags in its configure script to detect whether openblas is being used, by testing for the openblas_set_num_threads function. This doesn't work on Arch when using system openblas, since cblas is not provided by openblas. We fix this by also adding the output of pkg-config --libs blas to the link flags.

Change History (25)

comment:1 Changed 20 months ago by arojas

  • Branch set to u/arojas/make_fflas_ffpack_detect_and_use_system_openblas_on_arch

comment:2 Changed 20 months ago by arojas

  • Authors set to Antonio Rojas
  • Cc dimpase vdelecroix added
  • Commit set to 06f46ebaa41a620016d8e04c8c27045acbcd3ae0
  • Component changed from PLEASE CHANGE to build
  • Dependencies set to #29071
  • Description modified (diff)
  • Status changed from new to needs_review
  • Type changed from PLEASE CHANGE to defect

New commits:

06f46ebAdd blas to fflas_ffpack linked libraries so that openblas is picked up on Arch

comment:3 Changed 20 months ago by dimpase

  • Reviewers set to Dima Pasechnik
  • Status changed from needs_review to positive_review

looks good to me.

Last edited 20 months ago by dimpase (previous) (diff)

comment:4 Changed 20 months ago by dimpase

plesase also see https://trac.sagemath.org/ticket/29088#comment:13 - it might be relevant to Arch in particular.

comment:5 follow-up: Changed 20 months ago by mkoeppe

  • Status changed from positive_review to needs_info

Is this ticket needed? Also the current branch on #29071 seems to do the job for Arch Linux.

comment:6 Changed 20 months ago by mkoeppe

  • Dependencies changed from #29071 to #29051, #29071

comment:7 in reply to: ↑ 5 ; follow-up: Changed 20 months ago by arojas

  • Status changed from needs_info to positive_review

Replying to mkoeppe:

Is this ticket needed? Also the current branch on #29071 seems to do the job for Arch Linux.

Yes, this is a different issue. #29071 fixes fflas-ffpack building when using system openblas, but fflas-ffpack configure script still doesn't detect openblas being used (so the generic blas code is compiled, without specific openblas optimizations). This is what this ticket fixes.

comment:8 in reply to: ↑ 7 ; follow-up: Changed 20 months ago by mkoeppe

Replying to arojas:

Replying to mkoeppe:

Is this ticket needed? Also the current branch on #29071 seems to do the job for Arch Linux.

Yes, this is a different issue. #29071 fixes fflas-ffpack building when using system openblas, but fflas-ffpack configure script still doesn't detect openblas being used (so the generic blas code is compiled, without specific openblas optimizations). This is what this ticket fixes.

Thanks for the explanation. How does one recognize this situation in the logs?

In https://github.com/mkoeppe/sage/actions/runs/32186055 I ran the branch of #29071. See archlinux logs at https://github.com/mkoeppe/sage/suites/424292952/artifacts/1395949

Part of the fflas configure log:

-----------------------------------------------
     START  FFLAS-FFPACK CONFIG                
-----------------------------------------------
checking for OpenMP... yes
Detecting SIMD instruction set
SSE enabled
SSE2 enabled
SSE3 enabled
SSSE3 enabled
SSE4.1 enabled
SSE4.2 enabled
AVX enabled
AVX2 enabled
AVX512F enabled
AVX512VL enabled
AVX512DQ enabled
FMA3 enabled
FMA4 disabled
-----------------------------------------------
...
checking for GIVARO usability... yes
checking for use of MKL... no 
checking for BLAS... found CBLAS
checking for USER LAPACK... yes (lapack)
checking if this is OpenBLAS... yes
checking for OPENBLAS numthreads... none specified (using default value 1)

comment:9 in reply to: ↑ 8 ; follow-up: Changed 20 months ago by arojas

Replying to mkoeppe:

In https://github.com/mkoeppe/sage/actions/runs/32186055 I ran the branch of #29071. See archlinux logs at https://github.com/mkoeppe/sage/suites/424292952/artifacts/1395949

That build is not using system openblas, because you don't have the Arch cblas package installed - so Sage's openblas is being compiled, in which case this patch doesn't make any difference.

If you have Arch openblas, lapack and cblas packages installed, without this patch fflas-ffpack configure should print

checking if this is OpenBLAS... no

and with this patch it should print

checking if this is OpenBLAS... yes

comment:10 Changed 20 months ago by mkoeppe

Thank you!

comment:11 in reply to: ↑ 9 Changed 20 months ago by mkoeppe

Replying to arojas:

Replying to mkoeppe:

In https://github.com/mkoeppe/sage/actions/runs/32186055 I ran the branch of #29071. See archlinux logs at https://github.com/mkoeppe/sage/suites/424292952/artifacts/1395949

That build is not using system openblas, because you don't have the Arch cblas package installed - so Sage's openblas is being compiled, in which case this patch doesn't make any difference.

If you have Arch openblas, lapack and cblas packages installed, ...

Thanks. I have added these packages now to the "standard" configuration by https://git.sagemath.org/sage.git/commit/?id=23c6334cf2927a4d917a27b3963471e8242d86a3 in #29053/#29087. Running my GH Actions test runner on the branch of this ticket (on top of #29051, #29071): https://github.com/mkoeppe/sage/actions/runs/32381825, archlinux-latest-standard no longer decides to build openblas.

Now I see in fflas-ffpack config:

checking for use of MKL... no 
checking for BLAS... found CBLAS
checking for USER LAPACK... no 
checking if this is OpenBLAS... yes

Without the branch of this ticket, i.e., only using #29051, #29071, I indeed see

checking for BLAS... found CBLAS
checking for USER LAPACK... no 
checking if this is OpenBLAS... no

-- like you said. Great!

Version 0, edited 20 months ago by mkoeppe (next)

comment:12 follow-up: Changed 20 months ago by mkoeppe

  • Status changed from positive_review to needs_info

However, there's some trouble with ubuntu-trusty-minimal in fflas_ffpack. It installs correctly in the run without this ticket, but has a build error with this ticket.

comment:13 Changed 20 months ago by dimpase

Which run are you referring to?

comment:14 in reply to: ↑ 12 Changed 20 months ago by arojas

Replying to mkoeppe:

However, there's some trouble with ubuntu-trusty-minimal in fflas_ffpack. It installs correctly in the run without this ticket, but has a build error with this ticket.

The error is caused by having a too old GCC, I don't see how those could be related to this ticket. Where can I see the fflas-ffpack log of the successful build?

comment:16 follow-up: Changed 20 months ago by mkoeppe

My guess is that pkg-config --cflags is injecting the compiler flags that the system gcc does not understand. Would using pkg-config --cflags-only-I be enough to take care of archlinux?

comment:17 in reply to: ↑ 16 Changed 20 months ago by arojas

Replying to mkoeppe:

My guess is that pkg-config --cflags is injecting the compiler flags that the system gcc does not understand. Would using pkg-config --cflags-only-I be enough to take care of archlinux?

That's not the case, the output of pkg-config --cflags can be seen in the logs:

Using --with-blas-libs='-L/sage/local/lib -lopenblas  ' '--with-blas-cflags=-I/sage/local/include  '

That being said, the --cflags change is not needed at all, that change was made simply to be consistent with the --libs line.

comment:18 Changed 20 months ago by dimpase

I think

2020-01-29T01:30:39.8971740Z g++: error: unrecognized command line option '-mavx512f'
2020-01-29T01:30:39.8972021Z g++: error: unrecognized command line option '-mavx512vl'
2020-01-29T01:30:39.8972319Z g++: error: unrecognized command line option '-mavx512dq'

in the log is an indication that fflas_ffpack's configure emits these flags, but compiler, gcc 4.8.4, does not understand them, it's too old. So that's a bug in fflas_ffpack - or, if you prefer, a case to bump up the minimal compiler version for Sage

comment:19 follow-up: Changed 20 months ago by mkoeppe

It's conceivable that this error only shows up depending on what specific processor it gets to run. This can probably vary from run to run on the cloud.

comment:20 in reply to: ↑ 19 Changed 20 months ago by dimpase

Replying to mkoeppe:

It's conceivable that this error only shows up depending on what specific processor it gets to run. This can probably vary from run to run on the cloud.

absolutely.

comment:21 follow-up: Changed 20 months ago by mkoeppe

  • Status changed from needs_info to positive_review

I'm setting this ticket back to "positive review" and will open a separate issue for this.

comment:22 Changed 20 months ago by mkoeppe

Thanks everyone for your patience!

comment:23 in reply to: ↑ 21 Changed 20 months ago by mkoeppe

Replying to mkoeppe:

I'm setting this ticket back to "positive review" and will open a separate issue for this.

This is now #29102: fflas_ffpack installation error on new CPUs with old compilers

comment:24 Changed 20 months ago by mkoeppe

  • Reviewers changed from Dima Pasechnik to Dima Pasechnik, Matthias Koeppe

comment:25 Changed 20 months ago by vbraun

  • Branch changed from u/arojas/make_fflas_ffpack_detect_and_use_system_openblas_on_arch to 06f46ebaa41a620016d8e04c8c27045acbcd3ae0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.