Skip to content

Commit ffdf7a9

Browse files
committed
Ensure Distributed workers inherit threads spec properly
1 parent c470dc3 commit ffdf7a9

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

stdlib/Distributed/src/cluster.jl

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

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

1320+
@static if VERSION >= v"1.9.0" # has threadpools
1321+
function get_threads_spec(opts)
1322+
if opts.nthreads > 0
1323+
@assert opts.nthreadpools >= 1
1324+
@assert opts.nthreads_per_pool != C_NULL
1325+
thr = "$(unsafe_load(opts.nthreads_per_pool))"
1326+
if opts.nthreadpools == 2
1327+
thr = "$(thr),$(unsafe_load(opts.nthreads_per_pool, 2))"
1328+
end
1329+
`--threads=$(thr)`
1330+
else
1331+
``
1332+
end
1333+
end
1334+
else # no threadpools
1335+
function get_threads_spec(opts)
1336+
if opts.nthreads > 0
1337+
`--threads=$(opts.nthreads)`
1338+
else
1339+
``
1340+
end
1341+
end
1342+
end
1343+
13201344
# Starts workers specified by (-n|--procs) and --machine-file command line options
13211345
function process_opts(opts)
13221346
# startup worker.
@@ -1331,7 +1355,7 @@ function process_opts(opts)
13311355
end
13321356

13331357
# Propagate --threads to workers
1334-
threads = opts.nthreads > 0 ? `--threads=$(opts.nthreads)` : ``
1358+
threads = get_threads_spec(opts)
13351359
gcthreads = opts.ngcthreads > 0 ? `--gcthreads=$(opts.ngcthreads)` : ``
13361360

13371361
exeflags = `$threads $gcthreads`

0 commit comments

Comments
 (0)