From 381134e4fdbdcb1099fc584291ee2805fafdb5f0 Mon Sep 17 00:00:00 2001 From: Roy Oursler Date: Mon, 13 Jan 2025 15:48:10 -0800 Subject: [PATCH] xe: ocl: log OpenCL C warnings when DNNL_VERBOSE=warn --- src/gpu/intel/ocl/ocl_gpu_engine.cpp | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/gpu/intel/ocl/ocl_gpu_engine.cpp b/src/gpu/intel/ocl/ocl_gpu_engine.cpp index d9fa95c6d6e..4af1542aaa8 100644 --- a/src/gpu/intel/ocl/ocl_gpu_engine.cpp +++ b/src/gpu/intel/ocl/ocl_gpu_engine.cpp @@ -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 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 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_; };