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>
  • Loading branch information
2 people authored and pchintalapudi committed May 25, 2022
1 parent 843b954 commit 6c3f554
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 @@ -580,6 +580,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 6c3f554

Please sign in to comment.