From 788da99d823829ea2948b8b07b5663b16f998b21 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Wed, 8 Aug 2018 00:16:05 +0200 Subject: [PATCH] separate set_parallel_mthread(N::Int, workers::Bool) --- CPUselect.jl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/CPUselect.jl b/CPUselect.jl index 8321f65..aad3f23 100644 --- a/CPUselect.jl +++ b/CPUselect.jl @@ -9,15 +9,9 @@ function cpuinfo_physicalcores() return maxcore + 1 end -function set_parallel_mthread(parsed_args; workers=false) - - if parsed_args["cpus"] == nothing - N = cpuinfo_physicalcores() - else - N = parsed_args["cpus"] - if N > cpuinfo_physicalcores() - warn("Number of specified cores exceeds the physical core count. Performance may suffer.") - end +function set_parallel_mthread(N::Int, workers::Bool) + if N > cpuinfo_physicalcores() + warn("Number of specified cores exceeds the physical core count. Performance may suffer.") end if workers @@ -28,5 +22,14 @@ function set_parallel_mthread(parsed_args; workers=false) BLAS.set_num_threads(N) 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