From 9efb57d62197aeb7d868c289bb34166c132f0287 Mon Sep 17 00:00:00 2001 From: David Beck Date: Mon, 5 Nov 2018 13:40:33 +0000 Subject: Revert "IVGCVSW-2056 + IVGCVSW-2064 : move ClContextControl to the ClBackend" This reverts commit d4dfa684941a21314b70593d01b0fc2167eebad4. Change-Id: Id61ce69215505c3cf5d30ec2a7ec9127fb2554fc --- src/backends/cl/ClBackendContext.cpp | 111 ----------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 src/backends/cl/ClBackendContext.cpp (limited to 'src/backends/cl/ClBackendContext.cpp') diff --git a/src/backends/cl/ClBackendContext.cpp b/src/backends/cl/ClBackendContext.cpp deleted file mode 100644 index 7789415f89..0000000000 --- a/src/backends/cl/ClBackendContext.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "ClBackendContext.hpp" -#include "ClBackendId.hpp" -#include "ClContextControl.hpp" - -#include -#include - -#include - -#ifdef ARMCOMPUTECL_ENABLED -// Needed for the CL scheduler calls -#include -#include -#include -#endif - -namespace armnn -{ - -namespace -{ - -static StaticRegistryInitializer g_RegisterHelper -{ - BackendContextRegistryInstance(), - ClBackendId(), - [](const IRuntime::CreationOptions& options) - { - return IBackendContextUniquePtr(new ClBackendContext{options}); - } -}; - -static std::mutex g_ContextControlMutex; - -std::shared_ptr -GetContextControlWrapper(const IRuntime::CreationOptions& options) -{ - static std::weak_ptr contextControlWrapper; - - std::lock_guard lockGuard(g_ContextControlMutex); - std::shared_ptr result; - - if (contextControlWrapper.expired()) - { - result = std::make_shared(options); - contextControlWrapper = result; - } - else - { - result = contextControlWrapper.lock(); - } - - return result; -} - -} // anonymous namespace - - -#ifdef ARMCOMPUTECL_ENABLED -struct ClBackendContext::ContextControlWrapper -{ - ContextControlWrapper(const IRuntime::CreationOptions& options) - : m_ClContextControl{options.m_GpuAccTunedParameters.get(), - options.m_EnableGpuProfiling} - { - } - - ~ContextControlWrapper() - { - if (arm_compute::CLScheduler::get().context()() != NULL) - { - // Waits for all queued CL requests to finish before unloading the network they may be using. - try - { - // Coverity fix: arm_compute::CLScheduler::sync() may throw an exception of type cl::Error. - arm_compute::CLScheduler::get().sync(); - m_ClContextControl.ClearClCache(); - } - catch (const cl::Error&) - { - BOOST_LOG_TRIVIAL(warning) << "WARNING: Runtime::UnloadNetwork(): an error occurred while waiting for " - "the queued CL requests to finish"; - } - } - } - - ClContextControl m_ClContextControl; -}; -#else //ARMCOMPUTECL_ENABLED -struct ClBackendContext::ContextControlWrapper -{ - ContextControlWrapper(const IRuntime::CreationOptions&){} -}; -#endif //ARMCOMPUTECL_ENABLED - -ClBackendContext::ClBackendContext(const IRuntime::CreationOptions& options) -: IBackendContext{options} -, m_ContextControl{GetContextControlWrapper(options)} -{ -} - -ClBackendContext::~ClBackendContext() -{ -} - -} // namespace armnn \ No newline at end of file -- cgit v1.2.1