Skip to content

Conversation

ywwry66
Copy link
Contributor

@ywwry66 ywwry66 commented Apr 11, 2025

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Related to #209091, #129648, #129100. Upstream has added support for buiding with libomp through OpenMathLib/OpenBLAS#5180, where one can also find multiple issues linked from downstream repositories that are caused by Homebrew's handling of OpenMP for OpenBLAS.

This change requires dependents of OpenBLAS also switched to libomp. For gromacs, cp2k and fftw, the switch seems relatively straightforward. However, I am not sure how to go about dynare. Currently, dynare is directly linked to libgomp and it also pulls in libomp through suite-sparse.

@github-actions github-actions bot added the long dependent tests Set a long timeout for dependent testing label Apr 11, 2025
@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch from a509697 to ff2aa4d Compare April 11, 2025 04:18
@ywwry66

This comment was marked as resolved.

@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch from ff2aa4d to 017f197 Compare April 11, 2025 21:01
@github-actions github-actions bot added the autosquash Automatically squash pull request commits according to Homebrew style. label Apr 11, 2025
@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch 3 times, most recently from af08516 to 8cb793b Compare April 19, 2025 16:25
@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch 2 times, most recently from 6450d0c to 7d01829 Compare April 19, 2025 20:10
@ywwry66
Copy link
Contributor Author

ywwry66 commented Apr 20, 2025

The failures on macOS 15-arm64 can be reproduced on my Sequoia macbook with the current OpenBLAS bottle, so they are not related to this PR.

  1. arpack: Minitest::Assertion: Expected /reached/ to match " ** On entry to DLASCL parameter number 4 had an illegal value\n ** On entry to DLASCL parameter number 4 had an illegal value\n \n Error with _naupd, info = -9999\n Check the documentation of _naupd\n \n". (failed regression check for 3.9.1 on macos sequoia opencollab/arpack-ng#469)
  2. mlpack: /opt/homebrew/include/cereal/types/tuple.hpp:98:41: error: a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw] (Fix instances of -Wmissing-template-arg-list-after-template-kw. USCiLab/cereal#835)

There is an error I didn't see before:

  • shtools: make: *** [run-fortran-tests-no-timing] Error 137 (GH Runner out of memory? Cannot reproduce locally.)

@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch from 7d01829 to 3fb931b Compare April 20, 2025 04:54
@github-actions github-actions bot removed the autosquash Automatically squash pull request commits according to Homebrew style. label Apr 20, 2025
@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch 2 times, most recently from d5ace47 to 23b371f Compare April 21, 2025 15:06
@ywwry66 ywwry66 changed the title openblas: test cmake build openblas: use cmake Apr 21, 2025
@ywwry66 ywwry66 force-pushed the openblas_use_cmake branch 3 times, most recently from d8e8d7a to 5d8ee9a Compare April 21, 2025 20:36
@ywwry66 ywwry66 changed the title openblas: use cmake openblas: use cmake and depend on libomp Apr 23, 2025
@ywwry66
Copy link
Contributor Author

ywwry66 commented Apr 23, 2025

Should switching to libomp for dependents be done in this same PR or in separate PRs?

@ywwry66
Copy link
Contributor Author

ywwry66 commented Apr 25, 2025

fftw's makefile does not support libomp directly, and its cmake system is not feature complete, e.g., no mpi support. Changes to cmake were not very well received upstream. So I am not sure how to proceed here. Ping @carlocab and @cho-m for suggestions.

Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label May 17, 2025
@ywwry66
Copy link
Contributor Author

ywwry66 commented May 19, 2025

Keep the PR open for now.

@github-actions github-actions bot removed the stale No recent activity label May 19, 2025
Copy link
Contributor

github-actions bot commented Jun 9, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@cho-m cho-m mentioned this pull request Aug 14, 2025
@cho-m cho-m force-pushed the openblas_use_cmake branch 3 times, most recently from b217704 to fd454ee Compare August 15, 2025 00:11
@cho-m
Copy link
Member

cho-m commented Aug 15, 2025

Added some workarounds for dependents. Not ideal though, e.g.

  • fftw will overlink to libomp. Shouldn't impact functionality and loading overhead should be minor but would be better to only have the _omp dylibs linked
  • dynare needs some patching to build as Meson doesn't allow using GCC with OpenMP. And dynare cannot be built with LLVM/Clang due to OpenMP and decomposition compiler error llvm/llvm-project#33025

Would likely need further testing to make sure the OpenMP support is actually functional.

@cho-m cho-m force-pushed the openblas_use_cmake branch from fd454ee to 97d619e Compare August 17, 2025 16:12
@cho-m cho-m added the maintainer feedback Additional maintainers' opinions may be needed label Aug 18, 2025
@cho-m cho-m force-pushed the openblas_use_cmake branch from 97d619e to 11ce622 Compare August 19, 2025 13:00
@cho-m cho-m force-pushed the openblas_use_cmake branch from 11ce622 to e86a5fc Compare August 28, 2025 23:47
@cho-m
Copy link
Member

cho-m commented Aug 30, 2025

Will need to rebase for gromacs.
Also will split out some unrelated changes to make easier to review.

@cho-m cho-m force-pushed the openblas_use_cmake branch from e86a5fc to 18ffbc1 Compare August 31, 2025 02:58
@ywwry66
Copy link
Contributor Author

ywwry66 commented Aug 31, 2025

Just a word of caution: the OpenBLAS upstream is considering reverting the change that has added and streamlined OpenMP customization enabled by cmake's built-in module (ref. OpenMathLib/OpenBLAS#5413). If that is merged, it will also invalidate this PR, at least in its current form.

@cho-m
Copy link
Member

cho-m commented Aug 31, 2025

A Makefile workaround could be:

# Workaround to use OpenMP with Apple Clang
if ENV.compiler == :clang
  inreplace "Makefile.system", "+= -fopenmp", "+= -Xpreprocessor -fopenmp"
  inreplace "Makefile.install" do |s|
    s.gsub! ":= -fopenmp", ":= -Xpreprocessor -fopenmp"
    s.gsub! "+= -lgomp", "+= -L#{Formula["libomp"].opt_lib} -lomp"
  end
end

Can't comment if this functionally behaves as expected. But at least no mixed linkage

brew linkage openblas
System libraries:
  /usr/lib/libSystem.B.dylib
Homebrew libraries:
  /opt/homebrew/opt/gcc/lib/gcc/current/libgfortran.5.dylib (gcc)
  /opt/homebrew/opt/gcc/lib/gcc/current/libquadmath.0.dylib (gcc)
  /opt/homebrew/opt/libomp/lib/libomp.dylib (libomp)
PKG_CONFIG_PATH=/opt/homebrew/opt/openblas/lib/pkgconfig pkgconf --cflags openblas
-I/opt/homebrew/Cellar/openblas/0.3.30/include -Xpreprocessor -fopenmpPKG_CONFIG_PATH=/opt/homebrew/opt/openblas/lib/pkgconfig pkgconf --libs openblas
-L/opt/homebrew/Cellar/openblas/0.3.30/lib -lopenblasPKG_CONFIG_PATH=/opt/homebrew/opt/openblas/lib/pkgconfig pkgconf --libs --static openblas
-L/opt/homebrew/Cellar/openblas/0.3.30/lib -lopenblas -lpthread -lgfortran -lpthread -lgfortran -L/opt/homebrew/opt/libomp/lib -lomp

@cho-m cho-m mentioned this pull request Sep 7, 2025
6 tasks
@cho-m
Copy link
Member

cho-m commented Sep 7, 2025

Experimenting with Makefile alternative in

@ywwry66
Copy link
Contributor Author

ywwry66 commented Sep 7, 2025

I am trying to keep the upstream cmake improvements from being reverted so hopefully we don't need the Makefile alternative.

BTW, does the arrayfire test failure on Linux X86_64 need to be addressed?

@cho-m
Copy link
Member

cho-m commented Sep 7, 2025

BTW, does the arrayfire test failure on Linux X86_64 need to be addressed?


Also noting that I will be updating openblas test in separate PR to run cpp_thread_test to verify OpenMP is still functional:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-linux-self-hosted Build on Linux self-hosted runner CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-no-fail-fast-deps Continue dependent tests despite failing GitHub Actions matrix tests. long build Set a long timeout for formula testing long dependent tests Set a long timeout for dependent testing maintainer feedback Additional maintainers' opinions may be needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants