Skip to content

Commit 774168c

Browse files
committed
Update generic move implementations
1 parent 5b847fa commit 774168c

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/DaggerGPU.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ using Dagger, MemPool, Requires, Adapt
44
using Distributed
55
using KernelAbstractions
66

7+
import Dagger: Chunk
8+
79
macro gpuproc(PROC, T)
810
quote
911
# Assume that we can run anything
@@ -14,8 +16,22 @@ macro gpuproc(PROC, T)
1416
Dagger.iscompatible_arg(proc::Dagger.ThreadProc, opts, x::$T) = false
1517

1618
# Adapt to/from the appropriate type
17-
Dagger.move(from_proc::OSProc, to_proc::$PROC, x) = adapt($T, x)
18-
Dagger.move(from_proc::$PROC, to_proc::OSProc, x) = adapt(Array, x)
19+
function Dagger.move(from_proc::OSProc, to_proc::$PROC, x::Chunk)
20+
from_pid = from_proc.pid
21+
to_pid = Dagger.get_parent(to_proc).pid
22+
@assert myid() == to_pid
23+
adapt($T, remotecall_fetch(from_pid, x) do x
24+
poolget(x.handle)
25+
end)
26+
end
27+
function Dagger.move(from_proc::$PROC, to_proc::OSProc, x::Chunk)
28+
from_pid = Dagger.get_parent(from_proc).pid
29+
to_pid = to_proc.pid
30+
@assert myid() == to_pid
31+
remotecall_fetch(from_pid, x) do x
32+
adapt(Array, poolget(x.handle))
33+
end
34+
end
1935
end
2036
end
2137

0 commit comments

Comments
 (0)