Skip to content
Closed
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
14 changes: 13 additions & 1 deletion src/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -823,14 +823,17 @@ function versioninfo(io::IO=stdout)
return nothing
end

function __init__()
# This OncePerProcess does not yield a useful value, but it causes side-effects (configuring LBT / BLAS)
# which should only last for the duration of the current process.
const initialize_lbt = Base.OncePerProcess{Nothing}() do
try
verbose = parse(Bool, get(ENV, "LBT_VERBOSE", "false"))
BLAS.lbt_forward(OpenBLAS_jll.libopenblas_path; clear=true, verbose)
BLAS.check()
catch ex
Base.showerror_nostdio(ex, "WARNING: Error during initialization of module LinearAlgebra")
end

# register a hook to disable BLAS threading
Base.at_disable_library_threading(() -> BLAS.set_num_threads(1))

Expand All @@ -842,6 +845,15 @@ function __init__()
BLAS.set_num_threads(max(1, @ccall(jl_effective_threads()::Cint) ÷ 2))
end
end

return nothing
end

function __init__()
initialize_lbt()
end

# Initialize eagerly, so that LinearAlgebra is available for sysimage builds (incl. `--trim`)
initialize_lbt()

end # module LinearAlgebra
Loading