clBuildProgram failed with error code -11 and without build log

前端 未结 4 2019
忘了有多久
忘了有多久 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 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);
    }
    

提交回复
热议问题