Error : CL_BUILD_PROGRAM_FAILURE, the source code seems ok

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

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);
    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.

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?

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

Here is the way I call clGetProgramBuildInfo :

if (ret != CL_SUCCESS)
Fail to build the program
      size_t len;
      char *buffer;
      buffer = calloc(2048,sizeof(char));
      clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_LOG, 2048*sizeof(char), buffer, &len);
", buffer);
      clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_STATUS, 2048*sizeof(char), buffer, &len);
", buffer);
      clGetProgramBuildInfo(program, &device_id, CL_PROGRAM_BUILD_OPTIONS, 2048*sizeof(char), buffer, &len);
", buffer);
      return EXIT_FAILURE;

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

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);
", buffer);

Edit: my personal bet is a syntax error in the line that starts with “const sampler_t sampler” :slight_smile:

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 :slight_smile:

The reason “CLK_FI” is undeclared is because there’s a missing piece from the code you copied. It should be “CLK_FILTER_NEAREST”.

I fixed all my trouble.
Thanks again for your help :slight_smile: