Reading part of a 2D image

Hi again,

I have an 2D OpenCL image. Using a kernel, i modify the values of the first and second channels (x and y), the third and fourth channels are ignored.
Now, I have to transfer the data from the device to the host.
Two possibilities:

  • transfer the whole image in a cl_float4* (and consider only .x and .y values)
  • transfer a part of the image in a cl_float2*

My guess is that the first option should be faster (but I’m not sure) but we use then 2 times more memory on the host than we actually need.
Conversly, the second option should be longer but we use the exact amount of memory we need.

Any advice here?
Thank you,

Vincent

Why don’t you have your kernel write out an image directly instead of using pointers to float? You can create an image with only two channels (CL_RG) where each channel is a single-precision float (CL_FLOAT).

If you want to use pointers to float instead of images, a pointer to float2 is going to save you 50% of the bandwidth and storage, as you mention. What makes you think it would be slower?

I didn’ t know about CL_RG, that’s interesting :slight_smile:
My bad, I should have read the programming guide more carefully :wink:

Thanks