Hello,
I am a novice in OpenCl and I am facing problem with passing structure to a opencl kernel.
I have a structure :
struct c {
Bitboard a;
.
.
.
.
Bitboard m;
}
I need to pass a pointer to this structure to my opencl kernel. The first argument of opencl kernel is an array of interger.
I have created memory buffers for the two arguments :
// Create memory buffers on the device
cl_mem c_mem_obj = clCreateBuffer(context, CL_MEM_READ_WRITE, LIST_SIZE * sizeof(int), NULL, &ret);
cl_mem st_mem_obj = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(struct c), NULL, &ret);
Then : // Copy array C and struct to their respective memory buffers
ret = clEnqueueWriteBuffer(command_queue, c_mem_obj, CL_TRUE, 0, LIST_SIZE * sizeof(int), C, 0, NULL, NULL);
ret = clEnqueueWriteBuffer(command_queue, st_mem_obj, CL_TRUE, 0, sizeof(struct c), &c, 0, NULL, NULL);
For Setting the arguments of the kernel
ret = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&c_mem_obj);
if(ret != CL_SUCCESS) {
printf("Error: Setting kernel argument. (c_mem)
");
}
ret = clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&st_mem_obj);
if(ret != CL_SUCCESS) {
printf("Error: Setting kernel argument. (struct c)
");
}
and defined the kernel as :
__kernel void eval( __global int *a, __global struct chess* cc)
Can any body point out the mistake/mistakes from the procedure mentioned? The program works perfectly fine if I pass only the integer array to the kernel whereas on passing both it shows error with setting kernel parameters.