Repository navigation
Use Accelerate for BLAS/LAPACK on Apple Silicon - #75
Merged
Merged
Conversation
Homebrew OpenBLAS is built against LLVM libomp while gfortran uses libgomp, so one process carries two OpenMP runtimes. OpenBLAS 0.3.31-0.3.33 returned wrong DGEMM results when called from gfortran OpenMP threads (OpenMathLib/OpenBLAS#5825, fixed in 0.3.34). Accelerate keeps a single OpenMP runtime. A gfortran OpenMP DGEMM reproducer built with these settings agrees across 1, 4 and 8 threads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Apple Silicon,
activate.shpointed builds at Homebrew OpenBLAS. That library uses LLVM libomp, while gfortran codes use libgomp, so threaded Fortran codes load two OpenMP runtimes. With OpenBLAS 0.3.31-0.3.33 this gave silently wrong DGEMM results from inside gfortran!$omploops (OpenMathLib/OpenBLAS#5825, fixed in 0.3.34), first seen as thread-count-dependent results in GVEC.This switches
BLAS_LIBRARIES/LAPACK_LIBRARIESto the Accelerate framework and setsBLA_VENDOR=Apple. Intel Macs and Linux are unchanged.Checked locally: a CMake gfortran OpenMP build of the DGEMM reproducer with these settings links only Accelerate and libgomp and agrees across 1, 4 and 8 threads (relative error 0). Existing build trees keep their cached BLAS until reconfigured.
Chris&AI