Al5678 February 2016

OpenCL 1.2 read/write image data

I'm creating an Image2d object on the host using the flag CL_MEM_READ_WRITE. This image is the output of one kernel and I want it to be used as an input to a different kernel. I'm also using cl_image_format = {CL_INTENSITY, CL_FLOAT};

Is this possible in OpenCL 1.2? I've read nowhere that says you can't do this, yet when I try my second kernel returns all zeros, but no error.

I've also tried using clEnqueueCopyImage to copy the output of the first kernel to a different Image2d (also created using CL_MEM_READ_WRITE) and using that as input to the second kernel, but that also does not work.

I've verified the output of my first kernel is correct.

Thanks for any insight.

Answers


Dithermaster February 2016

Yes, the output image from one kernel can be used as input to a subsequent kernel.

As long as the image is CL_MEM_READ_WRITE it can either read __read_only or __write_only in a kernel in OpenCL 1.x.

OpenCL 2.0 further allows images to be __read_write but special rules must be followed (such as barriers) to get correct results.

For more information on read/write image, please see https://software.intel.com/en-us/articles/using-opencl-20-read-write-images

Don't try to cheat (OpenCL - Pass image2d_t twice to get both read and write from kernel?)

Post Status

Asked in February 2016
Viewed 3,245 times
Voted 14
Answered 1 times

Search




Leave an answer