Skip to content

Commit

Permalink
Ensure Distributed workers inherit threads spec properly (#49942)
Browse files Browse the repository at this point in the history
(cherry picked from commit aea56a9)
  • Loading branch information
kpamnany authored and KristofferC committed Jun 27, 2023
1 parent 118915f commit 3460774
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion stdlib/Distributed/src/cluster.jl
Expand Up @@ -1317,6 +1317,20 @@ end

write_cookie(io::IO) = print(io.in, string(cluster_cookie(), "\n"))

function get_threads_spec(opts)
if opts.nthreads > 0
@assert opts.nthreadpools >= 1
@assert opts.nthreads_per_pool != C_NULL
thr = "$(unsafe_load(opts.nthreads_per_pool))"
if opts.nthreadpools == 2
thr = "$(thr),$(unsafe_load(opts.nthreads_per_pool, 2))"
end
`--threads=$(thr)`
else
``
end
end

# Starts workers specified by (-n|--procs) and --machine-file command line options
function process_opts(opts)
# startup worker.
Expand All @@ -1331,7 +1345,9 @@ function process_opts(opts)
end

# Propagate --threads to workers
exeflags = opts.nthreads > 0 ? `--threads=$(opts.nthreads)` : ``
threads = get_threads_spec(opts)

exeflags = `$threads`

# add processors
if opts.nprocs > 0
Expand Down

0 comments on commit 3460774

Please sign in to comment.