Skip to content

Commit

Permalink
xe: ocl: log OpenCL C warnings when DNNL_VERBOSE=warn
Browse files Browse the repository at this point in the history
  • Loading branch information
rjoursler committed Jan 15, 2025
1 parent 4052b9b commit 381134e
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/gpu/intel/ocl/ocl_gpu_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,31 @@ status_t create_ocl_kernel_from_cache_blob(const ocl_gpu_engine_t *ocl_engine,
cl_int maybe_print_debug_info(
cl_int err_, cl_program program, cl_device_id dev) {
// Return error code if verbose is not enabled.
if (err_ == CL_SUCCESS || !get_verbose(verbose_t::error)) return err_;
if (!get_verbose(verbose_t::error) && !get_verbose(verbose_t::warn))
return err_;

size_t log_length = 0;
auto err = clGetProgramBuildInfo(
program, dev, CL_PROGRAM_BUILD_LOG, 0, nullptr, &log_length);
assert(err == CL_SUCCESS);

std::vector<char> log_buf(log_length);
err = clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG, log_length,
log_buf.data(), nullptr);
assert(err == CL_SUCCESS);
VERROR(common, ocl,
"Error during the build of OpenCL program. Build log:\n%s",
log_buf.data());
gpu_assert(err == CL_SUCCESS);

bool is_err = get_verbose(verbose_t::error) && err_ != status::success;
bool is_warn = get_verbose(verbose_t::warn);
if (log_length > 1 && (is_err || is_warn)) {
std::vector<char> log_buf(log_length);
err = clGetProgramBuildInfo(program, dev, CL_PROGRAM_BUILD_LOG,
log_length, log_buf.data(), nullptr);
gpu_assert(err == CL_SUCCESS);
if (is_err)
VERROR(common, ocl,
"Error during the build of OpenCL program. Build log:\n%s",
log_buf.data());
else if (is_warn)
VWARN(common, ocl,
"Warning during the build of OpenCL program. Build "
"log:\n%s",
log_buf.data());
}
MAYBE_UNUSED(err);
return err_;
};
Expand Down

0 comments on commit 381134e

Please sign in to comment.