Skip to content

Commit 390503e

Browse files
MoelfSamuraiAku
andauthored
set default blas num threads to Sys.CPU_THREADS / 2 (#45412)
Set default blas num threads to Sys.CPU_THREADS / 2 in absence of OPENBLAS_NUM_THREADS Co-authored-by: SamuraiAku <[email protected]>
1 parent a5438f9 commit 390503e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stdlib/LinearAlgebra/src/LinearAlgebra.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ function __init__()
580580
end
581581
# register a hook to disable BLAS threading
582582
Base.at_disable_library_threading(() -> BLAS.set_num_threads(1))
583+
584+
if !haskey(ENV, "OPENBLAS_NUM_THREADS")
585+
BLAS.set_num_threads(max(1, Sys.CPU_THREADS ÷ 2))
586+
end
583587
end
584588

585589
end # module LinearAlgebra

0 commit comments

Comments
 (0)