From 8882fc850fd65d48602669a9a82a6693cc960c76 Mon Sep 17 00:00:00 2001 From: "Durandin, Pavel" Date: Mon, 6 Jan 2025 18:52:39 +0400 Subject: [PATCH] [GPU] Draft, clean oneDNN cache in plugin --- src/plugins/intel_gpu/src/plugin/plugin.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp index 5650f5a66a2ae6..603bf988cf5414 100644 --- a/src/plugins/intel_gpu/src/plugin/plugin.cpp +++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp @@ -852,8 +852,30 @@ uint32_t Plugin::get_optimal_batch_size(const ov::AnyMap& options) const { return batch; } +class PluginSentry { +public: + PluginSentry() { +#ifdef ENABLE_ONEDNN_FOR_GPU + // touch oneDNN mutex for correct static objects destruction + auto capacity = dnnl::get_primitive_cache_capacity(); + dnnl::set_primitive_cache_capacity(0); + dnnl::set_primitive_cache_capacity(capacity); +#endif + } + + ~PluginSentry() { +#ifdef ENABLE_ONEDNN_FOR_GPU + // reset the capacity when plugin deleted + auto capacity = dnnl::get_primitive_cache_capacity(); + dnnl::set_primitive_cache_capacity(0); + dnnl::set_primitive_cache_capacity(capacity); +#endif + } +}; + } // namespace intel_gpu } // namespace ov static const ov::Version version = { CI_BUILD_NUMBER, "Intel GPU plugin" }; +static ov::intel_gpu::PluginSentry sentry; OV_DEFINE_PLUGIN_CREATE_FUNCTION(ov::intel_gpu::Plugin, version)