Skip to content

Commit aea56a9

Browse files
authored
Ensure Distributed workers inherit threads spec properly (#49942)
1 parent 310f590 commit aea56a9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

stdlib/Distributed/src/cluster.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,6 +1317,20 @@ end
13171317

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

1320+
function get_threads_spec(opts)
1321+
if opts.nthreads > 0
1322+
@assert opts.nthreadpools >= 1
1323+
@assert opts.nthreads_per_pool != C_NULL
1324+
thr = "$(unsafe_load(opts.nthreads_per_pool))"
1325+
if opts.nthreadpools == 2
1326+
thr = "$(thr),$(unsafe_load(opts.nthreads_per_pool, 2))"
1327+
end
1328+
`--threads=$(thr)`
1329+
else
1330+
``
1331+
end
1332+
end
1333+
13201334
# Starts workers specified by (-n|--procs) and --machine-file command line options
13211335
function process_opts(opts)
13221336
# startup worker.
@@ -1331,7 +1345,7 @@ function process_opts(opts)
13311345
end
13321346

13331347
# Propagate --threads to workers
1334-
threads = opts.nthreads > 0 ? `--threads=$(opts.nthreads)` : ``
1348+
threads = get_threads_spec(opts)
13351349
gcthreads = opts.ngcthreads > 0 ? `--gcthreads=$(opts.ngcthreads)` : ``
13361350

13371351
exeflags = `$threads $gcthreads`

0 commit comments

Comments
 (0)