PDA

View Full Version : Buffer size for clCreateImage3D with CL_INTENSITY



dmulvang
06-14-2011, 02:49 AM
Hi.

When creating a 3D image with the following image format:

cl_image_format imgFormat;
imgFormat.image_channel_data_type = CL_UNORM_INT8;
imgFormat.image_channel_order = CL_INTENSITY;

and using CL_MEM_COPY_HOST_PTR or CL_MEM_USE_HOST_PTR, what should be the size of the buffer pointed to by host_ptr (m_inputData in example below)?
GRIDSIZE^3 or 4*GRIDSIZE^3?

example:

#define GRIDSIZE 256

m_cl_memin = clCreateImage3D (
m_clGPUContext,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
&imgFormat,
GRIDSIZE,
GRIDSIZE,
GRIDSIZE,
0,
0,
m_inputdata,
&ciErrNum);

Best regards
Dag Magne

david.garcia
06-14-2011, 04:37 AM
It should be sizeof(cl_uint)*image_slice_pitch*image_depth, where image_slice_pitch and image_depth are the arguments that you pass to clCreateImage3D().

dmulvang
06-16-2011, 02:43 AM
Why should it not be sizeof(cl_uchar)*image_slice_pitch*image_depth?

While struggeling with this, I dropped the CL_MEM_COPY_HOST_PTR or CL_MEM_USE_HOST_PTR flags, and initialised the image using:

clEnqueueWriteImage, pointing to a buffer of size sizeof(cl_uchar)*image_slice_pitch*image_depth,

and this works ok. (At the same time i switched to using image_channel_order=CL_A)

Dag Magne

david.garcia
06-16-2011, 03:44 AM
Why should it not be sizeof(cl_uchar)*image_slice_pitch*image_depth?

Sorry, that was my mistake. sizeof(cl_uchar) is correct.


At the same time i switched to using image_channel_order=CL_A

Did you check first which image formats are supported in your device? Maybe CL_INTENSITY is not supported. clGetSupportedImageFormats() gives that information.