From fdc125118e9b2357f2c707f06c4b744f8dd557c6 Mon Sep 17 00:00:00 2001 From: Maxim Shevtsov Date: Fri, 24 Sep 2021 12:20:57 +0300 Subject: [PATCH] Reverted to atomic flag on the load completion + GetGraph that will wait for graph to be loaded (as opposite to assuming it is loaded) (#7629) --- .../src/mkldnn_plugin/mkldnn_exec_network.cpp | 15 +-------------- .../src/mkldnn_plugin/mkldnn_exec_network.h | 3 +-- .../multi_device/multi_device_exec_network.hpp | 2 +- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp index 14fe27a187d..69a4bc1721a 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp @@ -133,7 +133,7 @@ MKLDNNExecNetwork::MKLDNNExecNetwork(const InferenceEngine::CNNNetwork &network, } } -MKLDNNExecNetwork::Graph::Lock MKLDNNExecNetwork::GetGraph() { +MKLDNNExecNetwork::Graph::Lock MKLDNNExecNetwork::GetGraph() const { int streamId = 0; int numaNodeId = 0; auto streamsExecutor = dynamic_cast(_taskExecutor.get()); @@ -167,19 +167,6 @@ MKLDNNExecNetwork::Graph::Lock MKLDNNExecNetwork::GetGraph() { return graphLock; } -MKLDNNExecNetwork::Graph::Lock MKLDNNExecNetwork::GetGraph() const { - int streamId = 0; - int numaNodeId = 0; - auto streamsExecutor = dynamic_cast(_taskExecutor.get()); - if (nullptr != streamsExecutor) { - streamId = streamsExecutor->GetStreamId(); - numaNodeId = streamsExecutor->GetNumaNodeId(); - } - auto graphLock = Graph::Lock(_graphs[streamId % _graphs.size()]); - IE_ASSERT(graphLock._graph.IsReady()); - return graphLock; -} - void MKLDNNExecNetwork::setProperty(const std::map &properties) { { std::lock_guard lock{_cfgMutex}; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h index 2ebd1007068..e9373efd4a5 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h @@ -50,7 +50,7 @@ protected: MKLDNNExtensionManager::Ptr extensionManager; std::vector memoryStates; const InferenceEngine::CNNNetwork _network; - std::mutex _cfgMutex; + mutable std::mutex _cfgMutex; Config _cfg; std::atomic_int _numRequests = {0}; std::string _name; @@ -70,7 +70,6 @@ protected: * NOTE: Main thread is interpreted as master thread of external stream so use this function to get access to graphs * even from main thread */ - Graph::Lock GetGraph(); Graph::Lock GetGraph() const; diff --git a/inference-engine/src/multi_device/multi_device_exec_network.hpp b/inference-engine/src/multi_device/multi_device_exec_network.hpp index 2fd86c63170..aafbdc4819c 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.hpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.hpp @@ -170,7 +170,7 @@ private: NetworkPromise _cpuPromise; mutable NetworkFuture _acceleratorFuture; mutable NetworkPromise _acceleratorPromise; - mutable bool _alreadyActualNetwork = {false}; + mutable std::atomic _alreadyActualNetwork = {false}; bool _workModeIsAUTO = {false}; DeviceInformation _cpuDevice; DeviceInformation _acceleratorDevice;