-
Notifications
You must be signed in to change notification settings - Fork 246
Description
I'm having trouble porting my array-based code to an interop-based renderer.
I'm instantating the array like this:
using an allocator:
def gl_buffer_allocator(size):
ubo = glGenBuffers(1)
glBindBuffer(GL_UNIFORM_BUFFER, ubo)
glBufferStorage(GL_UNIFORM_BUFFER, size, None, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)
glBindBuffer(GL_UNIFORM_BUFFER, 0)
return GLBuffer(ctx, mem_flags.READ_WRITE, int(ubo))to_device cannot work because it doesn't acquire the GLBuffer, and I cannot do that beforehand since the buffer isn't allocated yet.
It works like this:
self.grid = Array(queue, self.grid_array.shape, self.grid_array.dtype, allocator=allocator)
self.grid.queue = None # didn't want to associate a queue yet
self.grid.allocator = None # make sure `.get()` doesn't allocate GLBuffersfor some reason passing a Context instead of a CommandQueue makes this lock up here. Freeing the context seems like the wrong thing to do...?
#0 0x00007fffeb5749aa in ?? () from /usr/lib/libnvidia-glcore.so.396.24
#1 0x00007fffeb1b2190 in ?? () from /usr/lib/libnvidia-glcore.so.396.24
#2 0x00007fffeb4c9f32 in ?? () from /usr/lib/libnvidia-glcore.so.396.24
#3 0x00007fffec70b6a3 in glcuR0d4nX () from /usr/lib/libGLX_nvidia.so.0
#4 0x00007fffe8853544 in ?? () from /usr/lib/libnvidia-opencl.so.1
#5 0x00007fffe8752881 in ?? () from /usr/lib/libnvidia-opencl.so.1
#6 0x00007fffe8751595 in ?? () from /usr/lib/libnvidia-opencl.so.1
#7 0x00007ffff032eb94 in clReleaseContext () from /usr/lib/libOpenCL.so.1
#8 0x00007ffff0572d95 in context::~context() () from /usr/lib/python3.6/site-packages/pyopencl/_cffi.abi3.so
#9 0x00007ffff057303a in context::~context() () from /usr/lib/python3.6/site-packages/pyopencl/_cffi.abi3.so
#10 0x00007ffff055f9fd in ?? () from /usr/lib/python3.6/site-packages/pyopencl/_cffi.abi3.so
The same deadlock is preventing me from using grid.with_queue(), grid.setitem() etc.
I realized later that I can trigger it just by accessing the context attribute of a CommandQueue:
def step(self):
with CommandQueue(self.ctx) as queue:
cl.enqueue_acquire_gl_objects(queue, [self.grid.base_data])
# uncomment to lock
# queue.context
self.grid.set(self.grid_array, queue=queue)
cl.enqueue_acquire_gl_objects(queue, [self.grid.base_data])
print('got here')interestingly it runs until 'got here' but I never see the result of the set call. The step() method also never returns for me.
If I debug the script in pudb, the interface closes as I step out of the method.
I'll see if i can create a small reproducable example now.