clBuildProgram failed with error code -11 and without build log

前端 未结 4 2004
忘了有多久
忘了有多久 2021-01-12 08:31

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 = c         


        
相关标签:
4条回答
  • 2021-01-12 08:47

    I've seen this happen on OSX 10.14.6 when the OpenCL kernel source is missing the _kernel attribute tag. If both the _kernel tag and return type are missing it seems to crash the system OpenCL compiler daemon, which then takes a few seconds to restart before new kernels will compile again.

    0 讨论(0)
  • 2021-01-12 08:59

    You can learn the meaning of OpenCL error codes by searching in cl.h. In this case, -11 is just what you'd expect, CL_BUILD_PROGRAM_FAILURE. It's certainly curious that the build log is empty. Two questions:

    1.) What is the return value from clGetProgramBuildInfo?

    2.) What platform are you on? If you are using Apple's OpenCL implementation, you could try setting CL_LOG_ERRORS=stdout in your environment. For example, from Terminal:

    $ CL_LOG_ERRORS=stdout ./myprog

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

    0 讨论(0)
  • 2021-01-12 09:00

    I encountered the same problem with an empty log file. I was testing my ocl kernel on a different computer. It had 2 platforms instead of one. One Intel GPU and one AMD GPU. I only had AMD OCL SDK installed. Installing the Intel OCL SDK fixed the problem. Also selecting the AMD platform instead of the Intel GPU platform fixed it.

    0 讨论(0)
  • 2021-01-12 09:02

    If you are using the 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);
    }
    
    0 讨论(0)
提交回复
热议问题