Reputation: 167
I am trying to use vectors in my OpenCL code. Prior to this, I was mapping the memory to and fro as
cmDevSrc= clCreateBuffer(cxGPUContext,CL_MEM_READ_WRITE,sizeof(cl_char) * (row_info->width) * bpp,NULL,&ciErr);
cmDevDest=clCreateBuffer(cxGPUContext,CL_MEM_READ_WRITE,sizeof(cl_char) * (row_info->width) * bpp,NULL,&ciErr);
I am using cmDevSrc
as my source array of unsigned chars
and cmdDevDest
as for destination.
When I am trying to implement the same using vectors, I am passing the kernel argument as
clSetKernelArg(ckKernel,1,sizeof(cl_uchar4 )*row_info->rowbytes*bpp,&cmDevDest);
with cmDevDest
being cl_uchar4 cmDevDest
.
But now, I cannot read back my data using mapping , with the following error,
incompatible type for argument 2 of ‘clEnqueueMapBuffer’
/usr/include/CL/cl.h:1066: note: expected ‘cl_mem’ but argument is of type ‘cl_uchar4’
I don't know any other method for this compile time error at this time and I am searching net but any help will very helpful.
Thanks Piyush
Upvotes: 1
Views: 352
Reputation: 9925
The clCreateBuffer
function returns a cl_mem
object, not a cl_uchar4
(or anything else), so cmDevSrc
and cmDevDest
should be declared as cl_mem
variables. This is also what is causing the compiler error for your call to clEnqueueMapBuffer
.
Additionally, the arg_size
argument of clSetKernelArg
should be sizeof(cl_mem)
when you are passing memory object arguments, not the size of the buffer:
clSetKernelArg(ckKernel, 1, sizeof(cl_mem), &cmDevDest);
Upvotes: 3