From f3bc6bf09e1dd98a449b419bb121be18c3c56656 Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Wed, 20 Jul 2022 04:16:13 -0400 Subject: [PATCH] Use `max(1, Sys.CPU_THREADS)` BLAS threads for apple `aarch64`. (#46085) (cherry picked from commit 97df6db548520227a9585e69a7bff8d6583af183) --- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index e8c2de0ac056a..86e07e118c708 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -583,7 +583,11 @@ function __init__() 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)) + @static if Sys.isapple() && Base.BinaryPlatforms.arch(Base.BinaryPlatforms.HostPlatform()) == "aarch64" + BLAS.set_num_threads(max(1, Sys.CPU_THREADS)) + else + BLAS.set_num_threads(max(1, Sys.CPU_THREADS ÷ 2)) + end end end