ClBuildProgram error with error code -11 and without build log

I did a bit of work in OpenCL, but recently, "clBuildProgram" failed to execute in one of my programs. The following is a snippet of code:

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

Usually, I used to get syntax or other errors inside the kernel file here using the function "clGetProgramBuildInfo ()" whenever "clBuildProgram" worked, but when this program starts, it only prints to the console:

Error building program --- Build a log ---

And when I tried to print the error code returned by the "clBuildProgram" command; it's "-11" ...... What could be the problem with my kernel file that I am not getting information about a build failure?

+7
source share
3 answers

You can find out the meaning of OpenCL error codes by doing a search in cl.h. In this case, -11 is what you expect, CL_BUILD_PROGRAM_FAILURE. Of course, it is curious that the build log is empty. Two questions:

1.) What is the return value from clGetProgramBuildInfo?

2.) What platform do you work on? If you are using the Apple OpenCL implementation, you can try setting CL_LOG_ERRORS = stdout in your environment. For example, from the terminal:

$ CL_LOG_ERRORS = stdout./myprog

It's also pretty easy to set this in Xcode (Edit Scheme -> Arguments -> Environment Variables).

+9
source

If you use C instead of C ++:

 err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL); ////////////////Add the following lines to see the log file/////////// if (err != CL_SUCCESS) { char *buff_erro; cl_int errcode; size_t build_log_len; errcode = clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_len); if (errcode) { printf("clGetProgramBuildInfo failed at line %d\n", __LINE__); exit(-1); } buff_erro = malloc(build_log_len); if (!buff_erro) { printf("malloc failed at line %d\n", __LINE__); exit(-2); } errcode = clGetProgramBuildInfo(program, devices[0], CL_PROGRAM_BUILD_LOG, build_log_len, buff_erro, NULL); if (errcode) { printf("clGetProgramBuildInfo failed at line %d\n", __LINE__); exit(-3); } fprintf(stderr,"Build log: \n%s\n", buff_erro); //Be careful with the fprint free(buff_erro); fprintf(stderr,"clBuildProgram failed\n"); exit(EXIT_FAILURE); } 
+3
source

I encountered the same problem with an empty log file. I tested my ocl core on another computer. He had 2 platforms instead of one. One Intel GPU and one AMD GPU. I just had the AMD OCL SDK installed. Problem installing Intel OCL SDK. Also fixed AMD platform selection instead of Intel GPU platform.

0
source

All Articles