Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] enable_profiling when ONEDNN_VERBOSE is on (#38840)

Mingyu Kim5a6f1d683a19
diff --git a/src/plugins/intel_gpu/src/runtime/execution_config.cpp b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
index 44b4c06e982..e289d290e04 100644
--- a/src/plugins/intel_gpu/src/runtime/execution_config.cpp
+++ b/src/plugins/intel_gpu/src/runtime/execution_config.cpp
@@ -36,6 +36,10 @@
#include "openvino/op/gated_delta_net.hpp"
#include "transformations/utils/utils.hpp"
+#ifdef ENABLE_ONEDNN_FOR_GPU
+#include <oneapi/dnnl/dnnl.hpp>
+#endif
+
namespace ov::intel_gpu {
namespace {
@@ -348,12 +352,18 @@ void ExecutionConfig::finalize_impl(const IRemoteContext* context) {
if (!is_set_by_user(ov::internal::enable_lp_transformations)) {
m_enable_lp_transformations = info.supports_imad || info.supports_immad;
}
+#ifdef ENABLE_ONEDNN_FOR_GPU
if (!is_set_by_user(ov::intel_gpu::use_onednn) && info.supports_immad) {
m_use_onednn = true;
}
- if (get_use_onednn()) {
+ if (m_use_onednn) {
m_queue_type = QueueTypes::in_order;
}
+ if (m_use_onednn && dnnl::verbose_profiling_enabled()) {
+ // Auto-enable profiling when OneDNN verbose profiling is enabled.
+ m_enable_profiling = true;
+ }
+#endif
// Enable dynamic quantization by default for non-systolic platforms
if (!is_set_by_user(ov::hint::dynamic_quantization_group_size) && get_dynamic_quantization_group_size() == 0) {
diff --git a/src/plugins/intel_gpu/tests/unit/module_tests/execution_config_test.cpp b/src/plugins/intel_gpu/tests/unit/module_tests/execution_config_test.cpp
index c8526c7d1cc..8ec4fc42463 100644
--- a/src/plugins/intel_gpu/tests/unit/module_tests/execution_config_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/module_tests/execution_config_test.cpp
@@ -244,3 +244,44 @@ TEST(execution_config, kv_cache_4bit_by_token_throws) {
ASSERT_ANY_THROW(config.finalize(ctx.get(), model.get()));
}
+
+#ifdef ENABLE_ONEDNN_FOR_GPU
+#include <oneapi/dnnl/dnnl.hpp>
+
+// RAII wrapper to restore the OneDNN verbose level after each test.
+struct ScopedDnnlVerbose {
+ explicit ScopedDnnlVerbose(int level) { dnnl::set_verbose(level); }
+ ~ScopedDnnlVerbose() { dnnl::set_verbose(0); }
+};
+
+TEST(execution_config, profiling_auto_enabled_when_onednn_verbose_profiling_active) {
+ ScopedDnnlVerbose verbose_guard(1); // level1 includes exec_profile
+
+ auto& engine = get_test_engine();
+ if (!engine.get_device_info().supports_immad)
+ GTEST_SKIP() << "oneDNN not supported on this device; skipping test";
+
+ auto ctx = std::make_shared<RemoteContextImpl>("GPU", std::vector<cldnn::device::ptr>{engine.get_device()});
+
+ ExecutionConfig config;
+ config.finalize(ctx.get(), nullptr);
+
+ ASSERT_TRUE(config.get_enable_profiling());
+}
+
+TEST(execution_config, profiling_not_auto_enabled_without_onednn_verbose) {
+ // Explicitly disable verbose to avoid interference from environment variables.
+ ScopedDnnlVerbose verbose_guard(0);
+
+ auto& engine = get_test_engine();
+ if (!engine.get_device_info().supports_immad)
+ GTEST_SKIP() << "oneDNN not supported on this device; skipping test";
+
+ auto ctx = std::make_shared<RemoteContextImpl>("GPU", std::vector<cldnn::device::ptr>{engine.get_device()});
+
+ ExecutionConfig config;
+ config.finalize(ctx.get(), nullptr);
+
+ ASSERT_FALSE(config.get_enable_profiling());
+}
+#endif // ENABLE_ONEDNN_FOR_GPU