Skip to content

Commit 95b6488

Browse files
authored
Merge pull request #24443 from JuliaLang/amitm/del_dist
Move Distributed to stdlib
2 parents 3af34b3 + 5b0ba79 commit 95b6488

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+877
-791
lines changed

base/client.jl

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,10 @@ function process_options(opts::JLOptions)
291291
# remove filename from ARGS
292292
global PROGRAM_FILE = arg_is_program ? shift!(ARGS) : ""
293293

294-
# startup worker.
295-
# opts.startupfile, opts.load, etc should should not be processed for workers.
296-
if opts.worker == 1
297-
# does not return
298-
if opts.cookie != C_NULL
299-
start_worker(unsafe_string(opts.cookie))
300-
else
301-
start_worker()
302-
end
303-
end
304-
305-
# add processors
306-
if opts.nprocs > 0
307-
addprocs(opts.nprocs)
308-
end
309-
# load processes from machine file
310-
if opts.machinefile != C_NULL
311-
addprocs(load_machine_file(unsafe_string(opts.machinefile)))
294+
# Load Distributed module only if any of the Distributed options have been specified.
295+
if (opts.worker == 1) || (opts.nprocs > 0) || (opts.machinefile != C_NULL)
296+
eval(Main, :(using Distributed))
297+
invokelatest(Main.Distributed.process_opts, opts)
312298
end
313299

314300
# load ~/.juliarc file
@@ -323,8 +309,12 @@ function process_options(opts::JLOptions)
323309
println()
324310
elseif cmd == 'L'
325311
# load file immediately on all processors
326-
@sync for p in procs()
327-
@async remotecall_wait(include, p, Main, arg)
312+
if nprocs() == 1
313+
include(Main, arg)
314+
else
315+
@sync for p in invokelatest(Main.procs)
316+
@async invokelatest(Main.remotecall_wait, include, p, Main, arg)
317+
end
328318
end
329319
end
330320
end
@@ -353,21 +343,6 @@ function load_juliarc()
353343
nothing
354344
end
355345

356-
function load_machine_file(path::AbstractString)
357-
machines = []
358-
for line in split(read(path, String),'\n'; keep=false)
359-
s = split(line, '*'; keep = false)
360-
map!(strip, s, s)
361-
if length(s) > 1
362-
cnt = all(isdigit, s[1]) ? parse(Int,s[1]) : Symbol(s[1])
363-
push!(machines,(s[2], cnt))
364-
else
365-
push!(machines,line)
366-
end
367-
end
368-
return machines
369-
end
370-
371346
import .Terminals
372347
import .REPL
373348

base/deprecated.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,40 @@ export conv, conv2, deconv, filt, filt!, xcorr
12611261
@deprecate_moved watch_file "FileWatching" true true
12621262
@deprecate_moved FileMonitor "FileWatching" true true
12631263

1264+
@eval @deprecate_moved $(Symbol("@spawn")) "Distributed" true true
1265+
@eval @deprecate_moved $(Symbol("@spawnat")) "Distributed" true true
1266+
@eval @deprecate_moved $(Symbol("@fetch")) "Distributed" true true
1267+
@eval @deprecate_moved $(Symbol("@fetchfrom")) "Distributed" true true
1268+
@eval @deprecate_moved $(Symbol("@everywhere")) "Distributed" true true
1269+
@eval @deprecate_moved $(Symbol("@parallel")) "Distributed" true true
1270+
1271+
@deprecate_moved addprocs "Distributed" true true
1272+
@deprecate_moved CachingPool "Distributed" true true
1273+
@deprecate_moved clear! "Distributed" true true
1274+
@deprecate_moved ClusterManager "Distributed" true true
1275+
@deprecate_moved default_worker_pool "Distributed" true true
1276+
@deprecate_moved init_worker "Distributed" true true
1277+
@deprecate_moved interrupt "Distributed" true true
1278+
@deprecate_moved launch "Distributed" true true
1279+
@deprecate_moved manage "Distributed" true true
1280+
@deprecate_moved nworkers "Distributed" true true
1281+
@deprecate_moved pmap "Distributed" true true
1282+
@deprecate_moved procs "Distributed" true true
1283+
@deprecate_moved remote "Distributed" true true
1284+
@deprecate_moved remotecall "Distributed" true true
1285+
@deprecate_moved remotecall_fetch "Distributed" true true
1286+
@deprecate_moved remotecall_wait "Distributed" true true
1287+
@deprecate_moved remote_do "Distributed" true true
1288+
@deprecate_moved rmprocs "Distributed" true true
1289+
@deprecate_moved workers "Distributed" true true
1290+
@deprecate_moved WorkerPool "Distributed" true true
1291+
@deprecate_moved RemoteChannel "Distributed" true true
1292+
@deprecate_moved Future "Distributed" true true
1293+
@deprecate_moved WorkerConfig "Distributed" true true
1294+
@deprecate_moved RemoteException "Distributed" true true
1295+
@deprecate_moved ProcessExitedException "Distributed" true true
1296+
1297+
12641298
@deprecate_moved crc32c "CRC32c" true true
12651299

12661300
@deprecate_moved DateTime "Dates" true true

base/event.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ end
2323
2424
Block the current task until some event occurs, depending on the type of the argument:
2525
26-
* [`RemoteChannel`](@ref) : Wait for a value to become available on the specified remote
27-
channel.
28-
* [`Future`](@ref) : Wait for a value to become available for the specified future.
2926
* [`Channel`](@ref): Wait for a value to be appended to the channel.
3027
* [`Condition`](@ref): Wait for [`notify`](@ref) on a condition.
3128
* `Process`: Wait for a process or process chain to exit. The `exitcode` field of a process

base/exports.jl

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export
1717
Markdown,
1818
Threads,
1919
Iterators,
20-
Distributed,
2120
Broadcast,
2221

2322
# Types
@@ -1241,38 +1240,7 @@ export
12411240
nzrange,
12421241
nnz,
12431242

1244-
# Distributed module re-exports
1245-
@spawn,
1246-
@spawnat,
1247-
@fetch,
1248-
@fetchfrom,
1249-
@everywhere,
1250-
@parallel,
1251-
1252-
addprocs,
1253-
CachingPool,
1254-
clear!,
1255-
ClusterManager,
1256-
default_worker_pool,
1257-
init_worker,
1258-
interrupt,
1259-
launch,
1260-
manage,
1243+
# Minimal set of Distributed exports - useful for a program to check if running
1244+
# in distributed mode or not.
12611245
myid,
1262-
nprocs,
1263-
nworkers,
1264-
pmap,
1265-
procs,
1266-
remote,
1267-
remotecall,
1268-
remotecall_fetch,
1269-
remotecall_wait,
1270-
remote_do,
1271-
rmprocs,
1272-
workers,
1273-
WorkerPool,
1274-
RemoteChannel,
1275-
Future,
1276-
WorkerConfig,
1277-
RemoteException,
1278-
ProcessExitedException
1246+
nprocs

base/loading.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ end
276276
# require always works in Main scope and loads files from node 1
277277
const toplevel_load = Ref(true)
278278

279+
myid() = isdefined(Main, :Distributed) ? invokelatest(Main.Distributed.myid) : 1
280+
nprocs() = isdefined(Main, :Distributed) ? invokelatest(Main.Distributed.nprocs) : 1
281+
279282
"""
280283
require(module::Symbol)
281284
@@ -301,12 +304,9 @@ function require(mod::Symbol)
301304
# After successfully loading, notify downstream consumers
302305
if toplevel_load[] && myid() == 1 && nprocs() > 1
303306
# broadcast top-level import/using from node 1 (only)
304-
@sync for p in procs()
307+
@sync for p in invokelatest(Main.procs)
305308
p == 1 && continue
306-
@async remotecall_wait(p) do
307-
require(mod)
308-
nothing
309-
end
309+
@async invokelatest(Main.remotecall_wait, ()->(require(mod); nothing), p)
310310
end
311311
end
312312
for callback in package_callbacks

0 commit comments

Comments
 (0)