I want to poll a global flag inside of a kernel in CUDA so as to shut down the kernel gracefully via the Host.
- How do I set up a Global flag in the host (I have tried abort=CuArray([false]) )
- Do I pass ‘abort’ as an arg to the kernel function? and can I check it’s value there?
- While the kernel is running (takes about 3 seconds) without sync: after 0.5 sec I set ‘abort’ to true in the host-side, but this has no affect - the kernel carries on running to the 3 second completion.
a = cu(; unified=true)
function kernel(b) b > 0 && (@cuprintln("ABORTED"); return nothing) for _ in 1:200000 a = sqrt(2) end return nothing end
println("START") fill!(a, 0) @cuda threads=16 blocks=1 kernel(a) fill!(a, 1) # has no effect on the kernel println("DONE")
I’m doing something basically wrong here. Will someone put me right please?