Skip to content

Commit 14dc2b5

Browse files
committed
Sch: Use at-invokelatest for move
1 parent 9dd7a89 commit 14dc2b5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/sch/Sch.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,8 @@ function do_task(to_proc, task_desc)
13941394
# TODO: Choose "closest" processor of same type first
13951395
some_proc = first(keys(CHUNK_CACHE[x]))
13961396
some_x = CHUNK_CACHE[x][some_proc]
1397-
move(some_proc, to_proc, some_x)
1397+
@dagdebug thunk_id :move "Cache hit for argument $id at $some_proc: $some_x"
1398+
@invokelatest move(some_proc, to_proc, some_x)
13981399
end)
13991400
else
14001401
nothing
@@ -1406,13 +1407,16 @@ function do_task(to_proc, task_desc)
14061407
else
14071408
# Fetch it
14081409
time_start = time_ns()
1409-
_x = move(to_proc, x)
1410+
from_proc = processor(x)
1411+
_x = @invokelatest move(from_proc, to_proc, x)
14101412
time_finish = time_ns()
14111413
if x.handle.size !== nothing
14121414
Threads.atomic_add!(transfer_time, time_finish - time_start)
14131415
Threads.atomic_add!(transfer_size, x.handle.size)
14141416
end
14151417

1418+
@dagdebug thunk_id :move "Cache miss for argument $id at $from_proc"
1419+
14161420
# Update cache
14171421
lock(TASK_SYNC) do
14181422
CHUNK_CACHE[x] = Dict{Processor,Any}()
@@ -1422,8 +1426,9 @@ function do_task(to_proc, task_desc)
14221426
_x
14231427
end
14241428
else
1425-
move(to_proc, x)
1429+
@invokelatest move(to_proc, x)
14261430
end
1431+
@dagdebug thunk_id :move "Moved argument $id to $to_proc: $x"
14271432
timespan_finish(ctx, :move, (;thunk_id, id), (;f, id, data=x); tasks=[Base.current_task()])
14281433
return x
14291434
end

test/options.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070
@test fetch(Dagger.@spawn sf(obj)) == 0
7171
@test fetch(Dagger.@spawn sf(obj)) == 0
7272
end
73-
Dagger.with_options(;scope=Dagger.ExactScope(Dagger.ThreadProc(1,1)), processor=Dagger.ThreadProc(1,1), meta=true) do
73+
Dagger.with_options(;scope=Dagger.ExactScope(Dagger.ThreadProc(1,1)), processor=OSProc(1), meta=true) do
7474
@test fetch(Dagger.@spawn sf(obj)) == 43
7575
@test fetch(Dagger.@spawn sf(obj)) == 43
7676
end

0 commit comments

Comments
 (0)