From aa278626b5e8609bd879e41386ea9b9e8d5d3f3d Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Mon, 18 Jul 2022 09:58:12 -0400 Subject: [PATCH 1/2] Use `max(1, Sys.CPU_THREADS)` BLAS threads for `aarch64`. None of the common ARM CPUs that come to mind have hyperthreading. --- 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 38f7b8588d1fa..e94a41dce3915 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -582,7 +582,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)) + if Sys.ARCH === :aarch64 + BLAS.set_num_threads(max(1, Sys.CPU_THREADS)) + else + BLAS.set_num_threads(max(1, Sys.CPU_THREADS ÷ 2)) + end end end From 2b33c6b46baabd9a9cbdc887e4e3c33861a05e91 Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Mon, 18 Jul 2022 14:06:22 -0400 Subject: [PATCH 2/2] Update LinearAlgebra.jl Use binarybuilder to normalize arch, and for now only use 1 BLAS thread per CPU thread for `Sys.isapple()` and `aarch64` --- stdlib/LinearAlgebra/src/LinearAlgebra.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/LinearAlgebra.jl b/stdlib/LinearAlgebra/src/LinearAlgebra.jl index e94a41dce3915..fa0aa9b9a8949 100644 --- a/stdlib/LinearAlgebra/src/LinearAlgebra.jl +++ b/stdlib/LinearAlgebra/src/LinearAlgebra.jl @@ -582,7 +582,7 @@ function __init__() Base.at_disable_library_threading(() -> BLAS.set_num_threads(1)) if !haskey(ENV, "OPENBLAS_NUM_THREADS") - if Sys.ARCH === :aarch64 + @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))