I'm having trouble passing a vector type (uint8) parameter to an OpenCL kernel function from the host code in C.
In the host I've got the data in an array:
cl_uint dataArr[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
(My real data is more than just [1, 8]; this is just for ease of explanation.)
I then transfer the data over to a buffer to be passed to the kernel:
cl_mem kernelInputData = clCreateBuffer(context,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, sizeof(cl_uint)*8, dataArr, NULL);
Next, I pass this buffer into the kernel:
clSetKernelArg(kernel, 0, sizeof(cl_mem), &kernelInputData);
And the kernel function's signature looks something like this:
kernel void kernelFunction(constant uint8 *vectorPtr)
However, the kernel doesn't seem to be obtaining the correct input data from the pointer to kernelInputData. When I pass values back from within the kernel, I see that vectorPtr points to something with this structure: ( 1, 2, 3, 4, 5, ?, ?, ? ) where the question marks are usually 4293848814 but sometimes 0. Either way, not what they're supposed to be.
What am I doing wrong?
EDIT:
I've switched from using an array to cl_uint8 on the host side. I now have:
cl_uint8 dataVector = { 1, 2, 3, 4, 5, 6, 7, 8 };
And I pass this vector to the kernel like so:
clSetKernelArg(kernel, 0, sizeof(cl_uint8), &dataVector);
And the kernel function's signature looks something like this:
kernel void kernelFunction(constant uint8 *vectorPtr)
However, running this code gives me a CL_INVALID_ARG_SIZE error on clSetKernelArg(). This error goes away if I switch the ARG_SIZE paramater to sizeof(cl_uint8 *) but then I get an EXC_BAD_ACCESS error in __dynamic_cast within clSetKernelArg().
My device is:
Apple Macbook Pro (mid-2009)
OSX 10.8 Mountain Lion
NVIDIA GeForce 9400M
OpenCL 1.0
CLH 1.0
clSetKernelArg()is of typeconst void *. - JacobEvelyncl_uint8 dataVector = { 1, 2, 3, 4, 5, 6, 7, 8 };clSetKernelArg(kernel, 0, sizeof(cl_uint8), &dataVector);andkernel void kernelFunction(constant uint8 vectorPtr)- Alex Placet