Skip to content

Commit

Permalink
set default blas num threads to Sys.CPU_THREADS / 2 (#45412)
Browse files Browse the repository at this point in the history
Set default blas num threads to Sys.CPU_THREADS / 2 in absence of OPENBLAS_NUM_THREADS

Co-authored-by: SamuraiAku <61489439+SamuraiAku@users.noreply.github.com>
(cherry picked from commit 390503e)
  • Loading branch information
Moelf authored and KristofferC committed May 23, 2022
1 parent b8943ec commit a02630e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stdlib/LinearAlgebra/src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,10 @@ function __init__()
end
# register a hook to disable BLAS threading
Base.at_disable_library_threading(() -> BLAS.set_num_threads(1))

if !haskey(ENV, "OPENBLAS_NUM_THREADS")
BLAS.set_num_threads(max(1, Sys.CPU_THREADS ÷ 2))
end
end

end # module LinearAlgebra

0 comments on commit a02630e

Please sign in to comment.