Image object memory consumption


I am new to OpenCL (have a bit more experience with CUDA) and have a question about image memory objects.

Do I understand correctly, that there is no way to have an image with only one channel? Consider I have a 3D black-and-white image of large size (e.g. 512^3) with float precision. If I store this as “Image3D” object, does this mean the memory consumption on the graphics hardware is then 4x512^3 floats (2GB), although I would actually only need one channel? This would mean that 3/4 of the consumption would be completely wasted, and the code would not run on a lot of cards, while it actually could, given a reasonable memory layout (512MB).

In total these image objects seem less flexible to me compared to what i can do with the “texture memory” in CUDA. Maybe I am mistaken (?).

Thanks for your answers,

No, that’s not correct. Simply look at the documentation for cl_image_format. You’d want to use CL_INTENSITY.

In what respect do you think them be less flexible?

Many thanks for your quick reply!

I saw this, but as the return value of “ReadImage” is always a float4 or int4 I was afraid that the memory is blown up.

Thanks for clarifying that it is not the case.

Maybe it’s “less flexible” is not the correct wording - I somehow find it more intuitive to have 1d (!), 2d, 3d memory of floats, float4s or whatever. Maybe I just have to get more used to OpenCL, some things are still a bit confusing.

Take a look at the table in the read_imagef documentation. It makes even more clear that the float4 returned for an intensity texture just puts the intensity “I” into each channel for convenience.

Yeah, it’s certainly easier for people who have worked with OpenGL before.