Skip to content

Commit

Permalink
[IE CLDNN] New debug_config: ShowOclBuildError (openvinotoolkit#6495)
Browse files Browse the repository at this point in the history
  • Loading branch information
isanghao authored Jul 6, 2021
1 parent ff2d661 commit d209373
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
28 changes: 17 additions & 11 deletions inference-engine/thirdparty/clDNN/runtime/debug_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@ const char *debug_configuration::prefix = "GPU_Debug: ";
static void print_option(std::string option_name, std::string option_value) {
GPU_DEBUG_COUT << "Config " << option_name << " = " << option_value << std::endl;
}

static void get_int_env(const std::string &var, int &val) {
if (const auto env_var = std::getenv(var.c_str())) {
val = std::stoi(env_var);
print_option(var, std::to_string(val));
}
}

static void get_str_env(const std::string &var, std::string &val) {
if (const auto env_var = std::getenv(var.c_str())) {
val = env_var;
print_option(var, val);
}
}

#endif

debug_configuration::debug_configuration()
: verbose(0)
, dump_graphs(std::string()) {
#ifdef GPU_DEBUG_CONFIG
const std::string OV_GPU_VERBOSE("OV_GPU_Verbose");
const std::string OV_GPU_DUMP_GRAPHS("OV_GPU_DumpGraphs");
if (const auto env_var = std::getenv(OV_GPU_VERBOSE.c_str())) {
verbose = std::stoi(env_var);
print_option(OV_GPU_VERBOSE, std::to_string(verbose));
}

if (const auto env_var = std::getenv(OV_GPU_DUMP_GRAPHS.c_str())) {
dump_graphs = env_var;
print_option(OV_GPU_DUMP_GRAPHS, dump_graphs);
}
get_int_env("OV_GPU_Verbose", verbose);
get_str_env("OV_GPU_DumpGraphs", dump_graphs);
#endif
}

Expand Down
5 changes: 5 additions & 0 deletions inference-engine/thirdparty/clDNN/runtime/kernels_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "kernels_factory.hpp"
#include "kernels_cache.hpp"
#include "ocl/ocl_engine.hpp"
#include "cldnn/runtime/debug_configuration.hpp"

#include <algorithm>
#include <cassert>
Expand Down Expand Up @@ -372,6 +373,10 @@ void kernels_cache::build_batch(const engine& build_engine, const batch_program&
dump_file << "*/\n";
}
if (!err_log.empty()) {
GPU_DEBUG_GET_INSTANCE(debug_config);
GPU_DEBUG_IF(debug_config->verbose) {
std::cout << err_log << std::endl;
}
throw std::runtime_error("Program build failed. You may enable OCL source dump to see the error log.\n");
}
}
Expand Down

0 comments on commit d209373

Please sign in to comment.