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 <[email protected]>
  • Loading branch information
Moelf and SamuraiAku authored May 22, 2022
1 parent a5438f9 commit 390503e
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 390503e

Please sign in to comment.