error code (-11):: what are all possible reasons of getting error “cl_build_program_failure” in OpenCL?

前端 未结 1 1768
情话喂你
情话喂你 2020-12-15 20:05

I am using ATI RV770 graphics card, OpenCl 1.0 and ati-stream-sdk-v2.3-lnx64 on linux.

While running my host code which includes following two sections to build kern

相关标签:
1条回答
  • 2020-12-15 20:50

    This error is typically caused by a syntax error in your kernel code. You can call the OpenCL function clGetProgramBuildInfo with the flag CL_PROGRAM_BUILD_LOG to access the log generated by the compiler. This log contains the output you are probably used to when compiling on the command-line (errors, warnings, etc.).

    For example, you could add something similar to the following after you call clBuildProgram:

    if (err == CL_BUILD_PROGRAM_FAILURE) {
        // Determine the size of the log
        size_t log_size;
        clGetProgramBuildInfo(program, devices_id[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
    
        // Allocate memory for the log
        char *log = (char *) malloc(log_size);
    
        // Get the log
        clGetProgramBuildInfo(program, devices_id[0], CL_PROGRAM_BUILD_LOG, log_size, log, NULL);
    
        // Print the log
        printf("%s\n", log);
    }
    

    You can also see the function buildOpenCLProgram() in SDKCommon.cpp in the AMD APP SDK for a real example.

    0 讨论(0)
提交回复
热议问题