Skip to content

Commit 77fe2c2

Browse files
authored
Merge pull request #582 from JuliaParallel/distributednext
Add support for DistributedNext
2 parents 546f2d1 + 85602cd commit 77fe2c2

File tree

10 files changed

+87
-17
lines changed

10 files changed

+87
-17
lines changed

Diff for: Project.toml

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ version = "0.18.13"
66
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
77
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
88
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
9+
DistributedNext = "fab6aee4-877b-4bac-a744-3eca44acbb6f"
910
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1213
MemPool = "f9f48841-c794-520a-933b-121f7ba6ed94"
1314
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
1415
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
16+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1517
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
1618
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1719
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
@@ -47,15 +49,17 @@ Adapt = "4.0.4"
4749
Colors = "0.12, 0.13"
4850
DataFrames = "1"
4951
DataStructures = "0.18"
52+
DistributedNext = "1.0.0"
5053
Distributions = "0.25"
5154
GraphViz = "0.2"
5255
Graphs = "1"
5356
JSON3 = "1"
5457
MacroTools = "0.5"
55-
MemPool = "0.4.6"
58+
MemPool = "0.4.11"
5659
OnlineStats = "1"
5760
Plots = "1"
5861
PrecompileTools = "1.2"
62+
Preferences = "1.4.3"
5963
PythonCall = "0.9"
6064
Requires = "1"
6165
ScopedValues = "1.1"
@@ -64,12 +68,3 @@ StatsBase = "0.28, 0.29, 0.30, 0.31, 0.32, 0.33, 0.34"
6468
TaskLocalValues = "0.1"
6569
TimespanLogging = "0.1"
6670
julia = "1.9"
67-
68-
[extras]
69-
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
70-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
71-
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
72-
GraphViz = "f526b714-d49f-11e8-06ff-31ed36ee7ee0"
73-
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
74-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
75-
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"

Diff for: lib/TimespanLogging/Project.toml

+4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ version = "0.1.0"
55

66
[deps]
77
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
8+
DistributedNext = "fab6aee4-877b-4bac-a744-3eca44acbb6f"
9+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
810
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
911

1012
[compat]
13+
DistributedNext = "1.0.0"
14+
Preferences = "1.4.3"
1115
julia = "1"

Diff for: lib/TimespanLogging/src/core.jl

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
using Distributed
1+
import Preferences: @load_preference, @set_preferences!
2+
if @load_preference("distributed-package") == "DistributedNext"
3+
using DistributedNext
4+
else
5+
using Distributed
6+
end
7+
28
import Profile
39
import Base.gc_num
410

@@ -16,6 +22,18 @@ ProfilerResult(samples, lineinfo, tasks::Vector{Task}) =
1622
ProfilerResult(samples, lineinfo, tasks::Nothing) =
1723
ProfilerResult(samples, lineinfo, map(Base.pointer_from_objref, UInt[]))
1824

25+
"""
26+
set_distributed_package!(value[="Distributed|DistributedNext"])
27+
28+
Set a [preference](https://github.com/JuliaPackaging/Preferences.jl) for using
29+
either the Distributed.jl stdlib or DistributedNext.jl. You will need to restart
30+
Julia after setting a new preference.
31+
"""
32+
function set_distributed_package!(value)
33+
@set_preferences!("distributed-package" => value)
34+
@info "TimespanLogging.jl preference has been set, restart your Julia session for this change to take effect!"
35+
end
36+
1937
"""
2038
Timespan
2139

Diff for: src/Dagger.jl

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import MemPool
88
import MemPool: DRef, FileRef, poolget, poolset
99

1010
import Base: collect, reduce
11-
import Distributed
12-
import Distributed: Future, RemoteChannel, myid, workers, nworkers, procs, remotecall, remotecall_wait, remotecall_fetch
1311

1412
import LinearAlgebra
1513
import LinearAlgebra: Adjoint, BLAS, Diagonal, Bidiagonal, Tridiagonal, LAPACK, LowerTriangular, PosDefException, Transpose, UpperTriangular, UnitLowerTriangular, UnitUpperTriangular, diagind, ishermitian, issymmetric
@@ -33,6 +31,17 @@ import TimespanLogging: timespan_start, timespan_finish
3331

3432
import Adapt
3533

34+
# Preferences
35+
import Preferences: @load_preference, @set_preferences!
36+
37+
if @load_preference("distributed-package") == "DistributedNext"
38+
import DistributedNext
39+
import DistributedNext: Future, RemoteChannel, myid, workers, nworkers, procs, remotecall, remotecall_wait, remotecall_fetch, check_same_host
40+
else
41+
import Distributed
42+
import Distributed: Future, RemoteChannel, myid, workers, nworkers, procs, remotecall, remotecall_wait, remotecall_fetch, check_same_host
43+
end
44+
3645
include("lib/util.jl")
3746
include("utils/dagdebug.jl")
3847

@@ -96,6 +105,21 @@ include("utils/logging-events.jl")
96105
include("utils/logging.jl")
97106
include("utils/viz.jl")
98107

108+
"""
109+
set_distributed_package!(value[="Distributed|DistributedNext"])
110+
111+
Set a [preference](https://github.com/JuliaPackaging/Preferences.jl) for using
112+
either the Distributed.jl stdlib or DistributedNext.jl. You will need to restart
113+
Julia after setting a new preference.
114+
"""
115+
function set_distributed_package!(value)
116+
MemPool.set_distributed_package!(value)
117+
TimespanLogging.set_distributed_package!(value)
118+
119+
@set_preferences!("distributed-package" => value)
120+
@info "Dagger.jl preference has been set, restart your Julia session for this change to take effect!"
121+
end
122+
99123
# Precompilation
100124
import PrecompileTools: @compile_workload
101125
include("precompile.jl")

Diff for: src/array/darray.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ end
434434

435435
function Distribute(data::AbstractArray{T,N}) where {T,N}
436436
nprocs = sum(w->length(Dagger.get_processors(OSProc(w))),
437-
Distributed.procs())
437+
procs())
438438
p = Blocks(ntuple(i->max(cld(size(data, i), nprocs), 1), N))
439439
return Distribute(partition(p, domain(data)), p, data)
440440
end

Diff for: src/array/sort.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ const use_shared_array = Ref(true)
144144
function _promote_array(x::AbstractArray{T}, y::AbstractArray{S}) where {T,S}
145145
Q = promote_type(T,S)
146146
ok = (isa(x, Array) || isa(x, SharedArray)) && (isa(y, Array) || isa(y, SharedArray))
147-
if ok && isbitstype(Q) && use_shared_array[] && Distributed.check_same_host([workers()..., 1])
148-
return SharedArray{Q}(length(x)+length(y), pids=Distributed.procs())
147+
if ok && isbitstype(Q) && use_shared_array[] && check_same_host([workers()..., 1])
148+
return SharedArray{Q}(length(x)+length(y), pids=procs())
149149
else
150150
return similar(x, Q, length(x)+length(y))
151151
end

Diff for: src/sch/Sch.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
module Sch
22

3-
import Distributed: Future, ProcessExitedException, RemoteChannel, RemoteException, myid, remote_do, remotecall_fetch, remotecall_wait, workers
3+
import Preferences: @load_preference
4+
if @load_preference("distributed-package") == "DistributedNext"
5+
import DistributedNext: Future, ProcessExitedException, RemoteChannel, RemoteException, myid, remote_do, remotecall_fetch, remotecall_wait, workers
6+
else
7+
import Distributed: Future, ProcessExitedException, RemoteChannel, RemoteException, myid, remote_do, remotecall_fetch, remotecall_wait, workers
8+
end
9+
410
import MemPool
511
import MemPool: DRef, StorageResource
612
import MemPool: poolset, storage_capacity, storage_utilized

Diff for: test/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ MemPool = "f9f48841-c794-520a-933b-121f7ba6ed94"
1313
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
1414
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1515
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
16+
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1617
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
1718
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1819
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

Diff for: test/preferences.jl

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Preferences: load_preference, set_preferences!
2+
3+
@testset "Preferences" begin
4+
cmd = `$(Base.julia_cmd()) --startup-file=no --project -E 'using Dagger; parentmodule(Dagger.myid)'`
5+
6+
try
7+
# Disabling the precompilation workload shaves off over half the time
8+
# this test takes.
9+
set_preferences!(Dagger, "precompile_workload" => false; force=true)
10+
11+
cd(dirname(Base.active_project())) do
12+
Dagger.set_distributed_package!("Distributed")
13+
@test readchomp(cmd) == "Distributed"
14+
15+
Dagger.set_distributed_package!("DistributedNext")
16+
@test readchomp(cmd) == "DistributedNext"
17+
end
18+
finally
19+
set_preferences!(Dagger, "precompile_workload" => true; force=true)
20+
end
21+
end

Diff for: test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ tests = [
2424
("Disk Caching", "diskcaching.jl"),
2525
("File IO", "file-io.jl"),
2626
("External Languages - Python", "extlang/python.jl"),
27+
("Preferences", "preferences.jl")
2728
#("Fault Tolerance", "fault-tolerance.jl"),
2829
]
2930
all_test_names = map(test -> replace(last(test), ".jl"=>""), tests)

0 commit comments

Comments
 (0)