separate set_parallel_mthread(N::Int, workers::Bool)
This commit is contained in:
parent
6f0f1d5cc6
commit
788da99d82
19
CPUselect.jl
19
CPUselect.jl
@ -9,16 +9,10 @@ function cpuinfo_physicalcores()
|
|||||||
return maxcore + 1
|
return maxcore + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function set_parallel_mthread(parsed_args; workers=false)
|
function set_parallel_mthread(N::Int, workers::Bool)
|
||||||
|
|
||||||
if parsed_args["cpus"] == nothing
|
|
||||||
N = cpuinfo_physicalcores()
|
|
||||||
else
|
|
||||||
N = parsed_args["cpus"]
|
|
||||||
if N > cpuinfo_physicalcores()
|
if N > cpuinfo_physicalcores()
|
||||||
warn("Number of specified cores exceeds the physical core count. Performance may suffer.")
|
warn("Number of specified cores exceeds the physical core count. Performance may suffer.")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if workers
|
if workers
|
||||||
addprocs(N)
|
addprocs(N)
|
||||||
@ -28,5 +22,14 @@ function set_parallel_mthread(parsed_args; workers=false)
|
|||||||
BLAS.set_num_threads(N)
|
BLAS.set_num_threads(N)
|
||||||
info("Using $N threads in BLAS.")
|
info("Using $N threads in BLAS.")
|
||||||
|
|
||||||
return N
|
end
|
||||||
|
|
||||||
|
function set_parallel_mthread(parsed_args::Dict; workers=false)
|
||||||
|
if parsed_args["cpus"] == nothing
|
||||||
|
N = cpuinfo_physicalcores()
|
||||||
|
else
|
||||||
|
N = parsed_args["cpus"]
|
||||||
|
end
|
||||||
|
|
||||||
|
set_parallel_mthread(N, workers)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user