Skip to content

Commit

Permalink
Ensure Distributed workers inherit threads spec properly
Browse files Browse the repository at this point in the history
  • Loading branch information
kpamnany committed May 23, 2023
1 parent c470dc3 commit ffdf7a9
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,30 @@ end

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

@static if VERSION >= v"1.9.0" # has threadpools
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
else # no threadpools
function get_threads_spec(opts)
if opts.nthreads > 0
`--threads=$(opts.nthreads)`
else
``
end
end
end

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

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

exeflags = `$threads $gcthreads`
Expand Down

0 comments on commit ffdf7a9

Please sign in to comment.