Array.get(async_=True) hangs when waiting on events
The following code hangs at the call to get
:
import pyopencl as cl
import pyopencl.array as cla
ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)
a_dev = cla.zeros(queue, (10,), 'float64')
a_host = a_dev.get()
start_event = cl.UserEvent(ctx)
a_dev.add_event(start_event)
print('about to get')
a_dev.get(ary=a_host, async_=True)
print('finished get')
(I can only interrupt the execution by killing the notebook kernel or shell session.)
If I catch the output of enqueue_copy
called in get
(_ = cl.enqueue_copy(...)
), the call to enqueue_copy
indeed does not block (i.e., a print statement just below it is reached), but the call to get
still hangs. Only by actually returning cl.enqueue_copy(...)
does the call release immediately.
set
doesn't seem to have any such issue. It adds the event returned by enqueue_copy
to the Array's events list. Doing the same in get
appears to resolve the issue, but I'm unsure one would want subsequent operations using the device-side array to necessarily wait for that copy to finish.
I can't say I understand what is going on here, but if this is indeed a bug I'd be happy to take a stab at a patch.