Hi
I’m having a weird error when trying to build a program.
When i run the following code it crashes with a CL_INVALID_VALUE on clBuildProgram…
However none of the error descriptions in the documentation have anything to do with what’s exactly happening in this code.
String kernelString = Activator.getInstance().loadKernel(kKERNEL_SOURCE_FILE);
fProgram = CL.clCreateProgramWithSource(fEnvironment.getContext(), 1, new String[] { kernelString }, null, null);
CL.clBuildProgram(fProgram, 0, null, null, null, null);
fKernel = CL.clCreateKernel(fProgram, kKERNEL_METHOD, null);```
This is the kernel source file that is passed as a string to clCreateProgramWithSource:
```const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_LINEAR;
__kernel void transform(
__read_only image2d_t target,
__read_only image2d_t floating,
__write_only image2d_t output,
const float m00,
const float m10,
const float m01,
const float m11,
const float m02,
const float m12
)
{
int gx = get_global_id(0);
int gy = get_global_id(1);
int2 coord = {gx,gy};
float xTrans = (m00 * gx) + (m01 * gy) + (m02 * 1);
float yTrans = (m10 * gx) + (m11 * gy) + (m12 * 1);
int xTransi = convert_int(xTrans);
int yTransi = convert_int(yTrans);
int2 coordTrans = {xTransi,yTransi};
int width = get_image_width(floating);
int height = get_image_height(floating);
uint4 pixel;
if(xTransi < 0 || yTransi < 0 || xTransi >= width || yTransi >= height){
pixel.x = 255;
pixel.y = 255;
pixel.z = 255;
}
else{
pixel = read_imageui(floating, sampler, coordTrans);
}
write_imageui(output, coord, pixel);
}```
I've been experimenting a little with the code in the kernel and i came across something strange..
When I comment the pieces of code that contain get_image_width, get_image_height and write_imageui the program does not crash when calling clBuildProgram. It's really strange because I have a whole bunch of kernels that I use before and after this one and they do build succesfully and even run succesfully.
So this is what i did to make this program build.
```int width = 0; //get_image_width(floating);
int height = 0; //get_image_height(floating);
uint4 pixel;
if(xTransi < 0 || yTransi < 0 || xTransi >= width || yTransi >= height){
pixel.x = 255;
pixel.y = 255;
pixel.z = 255;
}
else{
pixel = read_imageui(floating, sampler, coordTrans);
}
//write_imageui(output, coord, pixel);```
Ofcourse this will not make the kernel work as it should but it does compile nevertheless..
I've ran the same kernels on a laptop and there it works fine!
It sounds a lot like a driver bug but then the other kernels that use the same functions calls shouldn't be able to succesfully build either.
Anyway, i'm doing this on a GTX 660Ti with driver version 306.02, i also tried 305.68.
thanks in advance