Skip to content

Use hostcall for wait and stream GC #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/CUDAKernels/src/CUDAKernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ import Base: wait

wait(ev::CudaEvent, progress=yield) = wait(CPU(), ev, progress)

function wait(::CPU, ev::CudaEvent, progress=yield)
if progress === nothing
CUDA.synchronize(ev.event)
else
while !isdone(ev)
progress()
end
function wait(::CPU, ev::CudaEvent, progress=nothing)
isdone(ev) && return nothing

event = Base.Threads.Event()
stream = next_stream()
wait(CUDADevice(), ev, nothing, stream)
CUDA.launch(;stream) do
notify(event)
end
wait(event)
end

# Use this to synchronize between computation using the task local stream
Expand Down