yes, you can read out the debug messages with clGetProgramBuildInfo. Please read the opencl documentation section 5.4.5.
here’s a “little” hint:
inline void build(CDevice &device, const char* options = "")
{
// build
cl_int ret_val = clBuildProgram(program, 1, &device.device_id, options, NULL, NULL);
// avoid abortion due to CL_BILD_PROGRAM_FAILURE
if (ret_val != CL_SUCCESS && ret_val != CL_BUILD_PROGRAM_FAILURE)
CL_CHECK_ERROR(ret_val);
cl_build_status build_status;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL));
if (build_status == CL_SUCCESS)
return;
char *build_log;
size_t ret_val_size;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size));
build_log = new char[ret_val_size+1];
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL));
// to be carefully, terminate with
inline void build(CDevice &device, const char* options = “”)
{
// build
cl_int ret_val = clBuildProgram(program, 1, &device.device_id, options, NULL, NULL);
// avoid abortion due to CL_BILD_PROGRAM_FAILURE
if (ret_val != CL_SUCCESS && ret_val != CL_BUILD_PROGRAM_FAILURE)
CL_CHECK_ERROR(ret_val);
cl_build_status build_status;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL));
if (build_status == CL_SUCCESS)
return;
char *build_log;
size_t ret_val_size;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size));
build_log = new char[ret_val_size+1];
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL));
// to be carefully, terminate with \0
// there's no information in the reference whether the string is 0 terminated or not
build_log[ret_val_size] = '\0';
std::cout << "BUILD LOG: '" << filepath << "'" << std::endl;
std::cout << build_log << std::endl;
delete[] build_log;
}
// there's no information in the reference whether the string is 0 terminated or not
build_log[ret_val_size] = '
inline void build(CDevice &device, const char* options = “”)
{
// build
cl_int ret_val = clBuildProgram(program, 1, &device.device_id, options, NULL, NULL);
// avoid abortion due to CL_BILD_PROGRAM_FAILURE
if (ret_val != CL_SUCCESS && ret_val != CL_BUILD_PROGRAM_FAILURE)
CL_CHECK_ERROR(ret_val);
cl_build_status build_status;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_STATUS, sizeof(cl_build_status), &build_status, NULL));
if (build_status == CL_SUCCESS)
return;
char *build_log;
size_t ret_val_size;
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size));
build_log = new char[ret_val_size+1];
CL_CHECK_ERROR(clGetProgramBuildInfo(program, device.device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL));
// to be carefully, terminate with \0
// there's no information in the reference whether the string is 0 terminated or not
build_log[ret_val_size] = '\0';
std::cout << "BUILD LOG: '" << filepath << "'" << std::endl;
std::cout << build_log << std::endl;
delete[] build_log;
}
';
std::cout << "BUILD LOG: '" << filepath << "'" << std::endl;
std::cout << build_log << std::endl;
delete[] build_log;
}