OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] dump verbose log to file (#26244)
Mingyu Kim446d2e23bf7f
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hppindex 44414baf0da..fbc8ae84c36 100644--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/debug_configuration.hpp@@ -8,6 +8,7 @@#include <vector>#include <set>#include <string>+#include <iostream>namespace ov {namespace intel_gpu {@@ -62,8 +63,9 @@ enum class LogLevel : int8_t {#define GPU_DEBUG_LOG_RAW_INT(min_verbose_level) if (cldnn::debug_configuration::get_instance()->verbose >= min_verbose_level) \((cldnn::debug_configuration::get_instance()->verbose_color == 0) ? GPU_DEBUG_LOG_PREFIX : GPU_DEBUG_LOG_COLOR_PREFIX)#define GPU_DEBUG_LOG_RAW(min_verbose_level) GPU_DEBUG_LOG_RAW_INT(static_cast<std::underlying_type<ov::intel_gpu::LogLevel>::type>(min_verbose_level))-#define GPU_DEBUG_LOG_PREFIX std::cout << cldnn::debug_configuration::prefix << GPU_FILENAME << ":" <<__LINE__ << ":" << __func__ << ": "-#define GPU_DEBUG_LOG_COLOR_PREFIX std::cout << DARK_GRAY << cldnn::debug_configuration::prefix << \+#define GPU_DEBUG_LOG_PREFIX \+ *cldnn::debug_configuration::verbose_stream << cldnn::debug_configuration::prefix << GPU_FILENAME << ":" <<__LINE__ << ":" << __func__ << ": "+#define GPU_DEBUG_LOG_COLOR_PREFIX *cldnn::debug_configuration::verbose_stream << DARK_GRAY << cldnn::debug_configuration::prefix << \BLUE << GPU_FILENAME << ":" << PURPLE << __LINE__ << ":" << CYAN << __func__ << ": " << RESET#define DARK_GRAY "\033[1;30m"#define BLUE "\033[1;34m"@@ -77,7 +79,7 @@ enum class LogLevel : int8_t {#define GPU_DEBUG_PROFILED_STAGE(stage)#define GPU_DEBUG_PROFILED_STAGE_CACHE_HIT(val)#define GPU_DEBUG_PROFILED_STAGE_MEMALLOC_INFO(info)-#define GPU_DEBUG_LOG_RAW(min_verbose_level) if (0) std::cout << cldnn::debug_configuration::prefix+#define GPU_DEBUG_LOG_RAW(min_verbose_level) if (0) *cldnn::debug_configuration::verbose_stream << cldnn::debug_configuration::prefix#endif// Macro below is inserted to avoid unused variable warning when GPU_DEBUG_CONFIG is OFF@@ -100,6 +102,7 @@ public:int help; // Print help messagesint verbose; // Verbose executionint verbose_color; // Print verbose color+ std::string verbose_file; // Verbose log to fileint list_layers; // Print list layersint print_multi_kernel_perf; // Print execution time of each kernel in multi-kernel primitimiveint print_input_data_shapes; // Print the input data_shape for benchmark_app.@@ -170,6 +173,8 @@ public:int64_t start = 0;int64_t end = 0;} dump_prof_data_iter_params;++ static std::ostream* verbose_stream;};} // namespace cldnndiff --git a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp b/src/plugins/intel_gpu/src/runtime/debug_configuration.cppindex 1101fb3084d..dcbabff548c 100644--- a/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp+++ b/src/plugins/intel_gpu/src/runtime/debug_configuration.cpp@@ -10,9 +10,11 @@#include <regex>#include <sstream>#include <vector>+#include <fstream>namespace cldnn {const char *debug_configuration::prefix = "GPU_Debug: ";+std::ostream* debug_configuration::verbose_stream;// Default policy is that dump_configuration will override other configuration from IE.@@ -128,6 +130,7 @@ static void print_help_messages() {message_list.emplace_back("OV_GPU_Help", "Print help messages");message_list.emplace_back("OV_GPU_Verbose", "Verbose execution");message_list.emplace_back("OV_GPU_VerboseColor", "Print verbose color");+ message_list.emplace_back("OV_GPU_VerboseFile", "Filename to dump verbose log");message_list.emplace_back("OV_GPU_ListLayers", "Print layers names");message_list.emplace_back("OV_GPU_PrintMultiKernelPerf", "Print execution time of each kernel in multi-kernel primitimive");message_list.emplace_back("OV_GPU_PrintInputDataShapes", "Print data_shapes of input layers for benchmark_app.");@@ -214,6 +217,7 @@ debug_configuration::debug_configuration(): help(0), verbose(0), verbose_color(0)+ , verbose_file(), list_layers(0), print_multi_kernel_perf(0), print_input_data_shapes(0)@@ -255,6 +259,7 @@ debug_configuration::debug_configuration()get_gpu_debug_env_var("Help", help);get_common_debug_env_var("Verbose", verbose);get_gpu_debug_env_var("VerboseColor", verbose_color);+ get_gpu_debug_env_var("VerboseFile", verbose_file);get_gpu_debug_env_var("ListLayers", list_layers);get_gpu_debug_env_var("PrintMultiKernelPerf", print_multi_kernel_perf);get_gpu_debug_env_var("PrintInputDataShapes", print_input_data_shapes);@@ -316,6 +321,14 @@ debug_configuration::debug_configuration()exit(0);}+ if (verbose_file.length() > 0) {+ static std::ofstream fout;+ fout.open(verbose_file);+ verbose_stream = &fout;+ } else {+ verbose_stream = &std::cout;+ }+if (dump_prof_data_iter_str.length() > 0) {dump_prof_data_iter_str = " " + dump_prof_data_iter_str + " ";std::istringstream iss(dump_prof_data_iter_str);