cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

akhal
Journeyman III

clBuildProgram failed without printing build log

I have worked little bit in OpenCL now but recently "clBuildProgram" failed in one of my program. My code excerpt is below:


    cl_program program;
    program = clCreateProgramWithSource(context, 1, (const char**) &kernel_string, NULL, &err);
    if(err != CL_SUCCESS)
    {
    cout<<"Unable to create Program Object. Error code = "<<err<<endl;
    exit(1);
    }
    if(clBuildProgram(program, 0, NULL, NULL, NULL, NULL) != CL_SUCCESS)
    {
    cout<<"Program Build failed\n";
    size_t length;
    char buffer[2048];
    clGetProgramBuildInfo(program, device_id[0], CL_PROGRAM_BUILD_LOG, sizeof(buffer), buffer, &length);
    cout<<"--- Build log ---\n "<<buffer<<endl;
    exit(1);
    }

Normally earlier I got syntax or other errors inside kernel file here with the help of "clGetProgramBuildInfo()" function whenever "clBuildProgram" Failed but when this program runs, on console it only prints:

Program Build failed
--- Build log ---
<Nothing here>

And when I tried to print the error code returned by "clBuildProgram"; it is "-11"......
What can be the problem with my kernel file that I dont get any build fail information ?

0 Likes
4 Replies
rick_weber
Adept II

I've seen this happen if your string buffer isn't large enough. Make it ridiculously big (like 32k).

0 Likes
rotor
Journeyman III

I met this problem several time before. in my case, the compiler cannot optimize the code for the targeted device and it return failed message with any specific error. And in this case, the compiling time is often very long since the compiler try to put effort on optimize the code for the device, I guess.

Roto

0 Likes
genaganna
Journeyman III

Originally posted by: akhal I have worked little bit in OpenCL now but recently "clBuildProgram" failed in one of my program. My code excerpt is below:     cl_program program;     program = clCreateProgramWithSource(context, 1, (const char**) &kernel_string, NULL, &err);     if(err != CL_SUCCESS)     {     cout<<"Unable to create Program Object. Error code = "< And when I tried to print the error code returned by "clBuildProgram"; it is "-11"...... What can be the problem with my kernel file that I dont get any build fail information ?

 



Akhal,

It looks like  sizeof(buffer) < length.  See what error you are getting from clGetProgramBuildInfo?

0 Likes

Thanks the problem disappeard with different algorithm so I dont know what was the reason, thanks for comments:)

0 Likes