I am new to OpenCL. I have worked with OpenCL kernel with 1-D data. But when I tried to pass a 3-D pointer, it fails to build the kernel. To be specific I'm getting CL_BUILD_PROGRAM_FAILURE. Here's the pseudo code for the kernel I'm trying to build -
__kernel void 3D_Test(__global float ***array)
{
x = get_global_id(0);
y = get_global_id(1);
z = get_global_id(2);
array[x][y][z] = 10.0;
}
Could anyone give me an idea on what's wrong with the code? Thanks in advance!
That's not valid OpenCL C (that's why it doesn't compile), for a 3D array, you will have to use a linearlized version of that array, just create a normal array of appropiate size (sizeX * sizeY * sizeZ) and index it this way:
int index = x + y * sizeX + z * sizeX * sizeY;
Other option is to use a 3D image with clCreateImage3D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With