Results 1 to 7 of 7

Thread: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems ok

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    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 http://www.khronos.org/message_board...hp?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 :

    Code :
    __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_CLAMP|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.

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

    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?
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

    First thanks for your quick reply.
    So, I run clGetDeviceInfo() and it return 1;

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

    Code :
    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.

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

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

    Code :
          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"
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

    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

  6. #6
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

    The reason "CLK_FI" is undeclared is because there's a missing piece from the code you copied. It should be "CLK_FILTER_NEAREST".
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  7. #7
    Junior Member
    Join Date
    Feb 2011
    Posts
    5

    Re: Error : CL_BUILD_PROGRAM_FAILURE, the source code seems

    I fixed all my trouble.
    Thanks again for your help

Similar Threads

  1. about the source code of the opengl es 1.1 version
    By robert in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 01-19-2013, 01:54 PM
  2. OpenVG source code
    By chandrasekhar in forum OpenVG and VGU
    Replies: 1
    Last Post: 10-24-2007, 11:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •