Skip to content

Commit 1810d4c

Browse files
authored
Merge pull request #432 from JuliaParallel/jps/fix-init-eager
submission: Call init_eager on worker 1
2 parents ec7dba3 + 81155c9 commit 1810d4c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/sch/eager.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414

1515
function init_eager()
1616
if myid() != 1
17-
return
17+
throw(ConcurrencyViolationError("init_eager can only be called on worker 1"))
1818
end
1919
if Threads.atomic_xchg!(EAGER_INIT, true)
2020
wait(EAGER_READY)

src/submission.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Remote
22
function eager_submit_internal!(@nospecialize(payload))
3+
Sch.init_eager()
4+
35
ctx = Dagger.Sch.eager_context()
46
state = Dagger.Sch.EAGER_STATE[]
57
task = current_task()
@@ -10,6 +12,8 @@ function eager_submit_internal!(ctx, state, task, tid, payload; uid_to_tid=Dict{
1012
@nospecialize payload
1113
ntasks, uid, future, ref, f, args, options, reschedule = payload
1214

15+
Sch.init_eager()
16+
1317
if uid isa Vector
1418
thunk_ids = Sch.ThunkID[]
1519
for i in 1:ntasks
@@ -123,6 +127,7 @@ function eager_submit!(ntasks, uid, future, finalizer_ref, f, args, options)
123127
elseif myid() != 1
124128
return remotecall_fetch(eager_submit_internal!, 1, (ntasks, uid, future, finalizer_ref, f, args, options, true))
125129
else
130+
Sch.init_eager()
126131
state = Dagger.Sch.EAGER_STATE[]
127132
return lock(state.lock) do
128133
eager_submit_internal!((ntasks, uid, future, finalizer_ref,
@@ -170,8 +175,6 @@ function eager_process_options_submission_to_local(id_map, options::NamedTuple)
170175
end
171176
end
172177
function eager_spawn(spec::EagerTaskSpec)
173-
Dagger.Sch.init_eager()
174-
175178
# Generate new EagerThunk
176179
uid = eager_next_id()
177180
future = ThunkFuture()

test/thunk.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ end
4949
end
5050

5151
@testset "@spawn" begin
52+
@test_throws_unwrap ConcurrencyViolationError remotecall_fetch(last(workers())) do
53+
Dagger.Sch.init_eager()
54+
end
5255
@test Dagger.Sch.EAGER_CONTEXT[] === nothing
5356
@testset "per-call" begin
5457
x = 2

0 commit comments

Comments
 (0)