Add cl_print_build_errors to handle OpenCL build errors

This function logs detailed build failure information, including the status and build log retrieved from OpenCL. It provides better debugging support for diagnosing issues with OpenCL program compilation.
This commit is contained in:
DevTekVE
2025-03-09 18:29:32 +01:00
parent 425f5ebb2e
commit ba3acbce0a
2 changed files with 12 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ common_src = [
]
thneed_src_common = [
"thneed/clutil_legacy.cc",
"thneed/thneed_common.cc",
"thneed/serialize.cc",
]

View File

@@ -8,6 +8,17 @@
#include "common/swaglog.h"
#include "sunnypilot/modeld/thneed/clutil_legacy.h"
void cl_print_build_errors(cl_program program, cl_device_id device) {
cl_build_status status;
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_STATUS, sizeof(status), &status, NULL);
size_t log_size;
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
std::string log(log_size, '\0');
clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG, log_size, &log[0], NULL);
LOGE("build failed; status=%d, log: %s", status, log.c_str());
}
cl_program cl_program_from_binary(cl_context ctx, cl_device_id device_id, const uint8_t* binary, size_t length, const char* args) {
cl_program prg = CL_CHECK_ERR(clCreateProgramWithBinary(ctx, 1, &device_id, &length, &binary, NULL, &err));
if (int err = clBuildProgram(prg, 1, &device_id, args, NULL, NULL); err != 0) {