Skip to content
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