Closed beatreichenbach closed 1 year ago
Thanks for the report. How does https://gitlab.tiker.net/inducer/pyopencl/-/merge_requests/138 look?
Thank you for such a quick reply!
Just by looking at the code it seems like that makes sense as that's my understanding from reading the OpenCL docs.
I haven't tested those use cases but should image2d_array -> Buffer and more importantly image2d_array -> image2d_array also be supported?
Good catch. See updated https://gitlab.tiker.net/inducer/pyopencl/-/merge_requests/138.
Yep, I just did a super quick test to see if image->buffer and image->image actually works and seemed to be okay. Thanks for the quick fix :)
import pyopencl as cl
import pyopencl._cl as _cl
import numpy as np
context = cl.create_some_context(interactive=False)
queue = cl.CommandQueue(context)
image_format = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT)
image = np.ascontiguousarray(np.zeros((128, 128, 4), np.float32))
image_shape = (image.shape[1], image.shape[0])
array_shape = (*image_shape, 1)
image_cl = cl.Image(context, cl.mem_flags.READ_ONLY, image_format, shape=image_shape)
image_array_cl = cl.Image(context, cl.mem_flags.READ_ONLY, image_format, shape=array_shape, is_array=True)
image2_array_cl = cl.Image(context, cl.mem_flags.WRITE_ONLY, image_format, shape=array_shape, is_array=True)
buffer_cl = cl.Buffer(context, cl.mem_flags.WRITE_ONLY, size=image.nbytes)
_cl._enqueue_copy_image(queue, src=image_array_cl, dest=image2_array_cl, src_origin=(0, 0, 0), dest_origin=(0, 0, 0), region=array_shape)
_cl._enqueue_copy_image_to_buffer(queue, src=image_array_cl, dest=buffer_cl, offset=0, origin=(0, 0, 0), region=array_shape)
Describe the bug When creating image arrays with the argument
is_array=True
enqueue_copy doesn't allow that memory object to be used for src or dest. For example: https://github.com/inducer/pyopencl/blob/d2ade3f041a24604c697935b8d92405f11960d59/pyopencl/__init__.py#L2005 has support for 2d and 3d images, but not for cl.mem_object_type.IMAGE2D_ARRAYTo Reproduce
Expected behavior I would expect the code above to copy the contents of image_cl to image.
Calling the underlying
_cl._enqueue_write_image
function with the same arguments seems to work as expected.Environment (please complete the following information):