Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove openblas set_num_threads in julia __init__ #42442

Merged
merged 2 commits into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,9 @@ end
if is_primary_base_module
function __init__()
# try to ensuremake sure OpenBLAS does not set CPU affinity (#1070, #9639)
if !haskey(ENV, "OPENBLAS_MAIN_FREE") && !haskey(ENV, "GOTOBLAS_MAIN_FREE")
if !haskey(ENV, "OPENBLAS_MAIN_FREE")
ENV["OPENBLAS_MAIN_FREE"] = "1"
end
# And try to prevent openblas from starting too many threads, unless/until specifically requested
if !haskey(ENV, "OPENBLAS_NUM_THREADS") && !haskey(ENV, "OMP_NUM_THREADS")
cpu_threads = Sys.CPU_THREADS::Int
if cpu_threads > 8 # always at most 8
ENV["OPENBLAS_NUM_THREADS"] = "8"
elseif haskey(ENV, "JULIA_CPU_THREADS") # or exactly as specified
ENV["OPENBLAS_NUM_THREADS"] = cpu_threads
end # otherwise, trust that openblas will pick CPU_THREADS anyways, without any intervention
end
# for the few uses of Libc.rand in Base:
Libc.srand()
# Base library init
Expand Down
1 change: 0 additions & 1 deletion stdlib/Distributed/test/distributed_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,6 @@ function test_add_procs_threaded_blas()
@warn "Skipping blas num threads tests due to unsupported blas version"
return
end
@test master_blas_thread_count <= 8 # check that Base set the environment variable in __init__ before LinearAlgebra dlopen'd it

# Test with default enable_threaded_blas false
processes_added = addprocs_with_testenv(2)
Expand Down