PDA

View Full Version : Error : CL_BUILD_PROGRAM_FAILURE, the source code seems ok



orobas
02-24-2011, 07:03 PM
Hello, First, I'm French, so sorry for my poor English.

So, I recently start with opencl and I have the following error while running : CL_BUILD_PROGRAM_FAILURE
It happens after calling the function : clBuildProgram
I read several topics but it cannot help me.
I call the "clGetProgramBuildInfo" function to find the problem but it returns an empty string.

I guessed the problem comes from my Kernel, so I just copy past the kernel from the topic http://www.khronos.org/message_boards/viewtopic.php?f=37&t=2495.

When I try to put a previous kernel I create, the compilation work fine, but with a kernel using __read/write_only image2d_t the compilation fail.

Here the source code of the kernel :



__kernel void gaussian(__read_only image2d_t origin,__write_only image2d_t dest, __global int* taille, __global int *filter){
int iGIDx = get_global_id(0);
int iGIDy = get_global_id(1);
const sampler_t sampler=CLK_NORMALIZED_COORDS_FALSE|CLK_ADDRESS_CL AMP|CLK_FI
uint4 pixel, temps;
pixel = read_imageui(origin,sampler,(int2)(iGIDX,iGIDY));
int k,l;
float R = 0,G = 0,B = 0;

for (k = 0; k < 5; k++)
for (l = 0; l < 5; l++){
temps = read_imageui(origin,sampler,(int2)(iGIDX+k-2,iGIDy+l-2));
R += filter[k*5+l]*temps.x;
G += filter[k*5+l]*temps.y;
B += filter[k*5+l]*temps.z;
}
R /=159; G/=159; B /=159;
temps.x = R; temps.y = G; temps.z = B;
write_imageui (dest,(int2)(iGIDX,iGIDY),temps);
}


If someone have any idea of the problem.
Thanks in advance.

david.garcia
02-24-2011, 07:51 PM
I call the "clGetProgramBuildInfo" function to find the problem but it returns an empty string.

Can you show us how you are making that call? It's very unusual to get an empty string.

Also, have you checked if your device supports images? You can call clGetDeviceInfo() and query CL_DEVICE_IMAGE_SUPPORT to find out.

Finally, what OpenCL implementation are you using? AMD? NVidia? Intel?

orobas
02-24-2011, 09:01 PM
First thanks for your quick reply.
So, I run clGetDeviceInfo() and it return 1;


cl_bool test;
ret = clGetDeviceInfo(device_id, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), (void *)&test, NULL);
printf("returned value %d\n",test);


Here is the way I call clGetProgramBuildInfo :


if (ret != CL_SUCCESS)
{
printf("\nFail to build the program\n");
size_t len;
char *buffer;
buffer = calloc(2048,sizeof(char));
clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_LOG, 2048*sizeof(char), buffer, &len);
printf("%s\n", buffer);
clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_STATUS, 2048*sizeof(char), buffer, &len);
printf("%s\n", buffer);
clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_OPTIONS, 2048*sizeof(char), buffer, &len);
printf("%s\n", buffer);
return EXIT_FAILURE;
}


I'm using the Nvidia opencl implementation, using win7/64 and my graphic card is a quadro nvs420.

david.garcia
02-25-2011, 07:03 AM
It's likely that the log is larger than 2KB and that's why it doesn't output anything.

Why don't you query the length first (using that last argument to clGetDeviceInfo()) and then allocate enough memory to contain the whole log?

Something like this (sorry I didn't try to compile this myself):



size_t len;
char *buffer;
clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &len);
buffer = calloc(len);
clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_LOG, len, buffer, NULL);
printf("%s\n", buffer);


Edit: my personal bet is a syntax error in the line that starts with "const sampler_t sampler" :)

orobas
02-25-2011, 05:28 PM
Thanks again,

I get my problem. I catch the return of clGetProgramBuildInfo and it tells me invalid device, I just had to remove the & value in front of it. Sometime I just don't think to easy solutions ...

Well, after the while reading the log I easily find the problem in the sampler CLK_FI was undeclared. I just copy it from another source code that seems to work, so I don't really get why.

Thanks also for the ";", but I corrected it quickly :)

david.garcia
02-25-2011, 06:10 PM
The reason "CLK_FI" is undeclared is because there's a missing piece from the code you copied. It should be "CLK_FILTER_NEAREST".

orobas
02-27-2011, 02:49 AM
I fixed all my trouble.
Thanks again for your help :)