javaopencljocl

Pass int as kernel argument in JOCL


So I have a kernel that looks like to this:

__kernel void my_kernel( __global const uchar *array, const uint number, __global const uchar *result) {
...
}

I have figured out how to pass the arrays (byte arrays in Java) by creating a buffer:

cl_mem memObjects[] = new cl_mem[2];
memObjects[0] = clCreateBuffer(context, 
    CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
    Sizeof.cl_uchar * dataSize, 
    Pointer.to(data), null
);

and then setting it:

clSetKernelArg(my_kernel, 0, Sizeof.cl_mem, Pointer.to(memObjects[0]));

What I can't figure out is how to set the number parameter...which is a simple int in Java?


Solution

  • You could try :

    clSetKernelArg(my_kernel, 1, Sizeof.cl_uint, Pointer.to(new int[]{123}));