diff options
author | David Beck <david.beck@arm.com> | 2018-11-05 13:40:33 +0000 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-11-05 17:26:57 +0000 |
commit | 9efb57d62197aeb7d868c289bb34166c132f0287 (patch) | |
tree | 047fe9ac08ad90145d4e2d5bf1c6acc24eaad16c /src/backends/cl | |
parent | 9c6f3afdf7686d9804fd5bc04ea68fca4c49a0a8 (diff) | |
download | armnn-9efb57d62197aeb7d868c289bb34166c132f0287.tar.gz |
Revert "IVGCVSW-2056 + IVGCVSW-2064 : move ClContextControl to the ClBackend"
This reverts commit d4dfa684941a21314b70593d01b0fc2167eebad4.
Change-Id: Id61ce69215505c3cf5d30ec2a7ec9127fb2554fc
Diffstat (limited to 'src/backends/cl')
-rw-r--r-- | src/backends/cl/CMakeLists.txt | 27 | ||||
-rw-r--r-- | src/backends/cl/ClBackend.cpp | 7 | ||||
-rw-r--r-- | src/backends/cl/ClBackend.hpp | 4 | ||||
-rw-r--r-- | src/backends/cl/ClBackendContext.cpp | 111 | ||||
-rw-r--r-- | src/backends/cl/ClBackendContext.hpp | 23 | ||||
-rw-r--r-- | src/backends/cl/ClLayerSupport.cpp | 2 | ||||
-rw-r--r-- | src/backends/cl/backend.mk | 2 |
7 files changed, 22 insertions, 154 deletions
diff --git a/src/backends/cl/CMakeLists.txt b/src/backends/cl/CMakeLists.txt index 30254582b2..d751854c92 100644 --- a/src/backends/cl/CMakeLists.txt +++ b/src/backends/cl/CMakeLists.txt @@ -3,23 +3,18 @@ # SPDX-License-Identifier: MIT # -list(APPEND armnnClBackend_sources - ClBackendId.hpp - ClLayerSupport.cpp - ClLayerSupport.hpp - ClWorkloadFactory.cpp - ClWorkloadFactory.hpp -) - if(ARMCOMPUTECL) list(APPEND armnnClBackend_sources - ClBackendContext.cpp - ClBackendContext.hpp ClBackend.cpp ClBackend.hpp + ClBackendId.hpp ClContextControl.cpp ClContextControl.hpp + ClLayerSupport.cpp + ClLayerSupport.hpp ClTensorHandle.hpp + ClWorkloadFactory.cpp + ClWorkloadFactory.hpp OpenClTimer.cpp OpenClTimer.hpp ) @@ -29,10 +24,20 @@ if(ARMCOMPUTECL) if(BUILD_UNIT_TESTS) add_subdirectory(test) endif() + +else() + list(APPEND armnnClBackend_sources + ClBackendId.hpp + ClContextControl.cpp + ClContextControl.hpp + ClLayerSupport.cpp + ClLayerSupport.hpp + ClWorkloadFactory.cpp + ClWorkloadFactory.hpp + ) endif() add_library(armnnClBackend OBJECT ${armnnClBackend_sources}) target_include_directories(armnnClBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnn) target_include_directories(armnnClBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/armnnUtils) target_include_directories(armnnClBackend PRIVATE ${PROJECT_SOURCE_DIR}/src/backends) - diff --git a/src/backends/cl/ClBackend.cpp b/src/backends/cl/ClBackend.cpp index 5d5cad572c..b1857a3678 100644 --- a/src/backends/cl/ClBackend.cpp +++ b/src/backends/cl/ClBackend.cpp @@ -8,7 +8,6 @@ #include "ClWorkloadFactory.hpp" #include <backendsCommon/BackendRegistry.hpp> -#include <boost/log/trivial.hpp> namespace armnn { @@ -20,13 +19,13 @@ static StaticRegistryInitializer<BackendRegistry> g_RegisterHelper { BackendRegistryInstance(), ClBackend::GetIdStatic(), - [](const EmptyInitializer&) + []() { return IBackendInternalUniquePtr(new ClBackend); } }; -} // anonymous namespace +} const BackendId& ClBackend::GetIdStatic() { @@ -39,4 +38,4 @@ IBackendInternal::IWorkloadFactoryPtr ClBackend::CreateWorkloadFactory() const return std::make_unique<ClWorkloadFactory>(); } -} // namespace armnn
\ No newline at end of file +} // namespace armnn diff --git a/src/backends/cl/ClBackend.hpp b/src/backends/cl/ClBackend.hpp index 381d808036..223aeb3095 100644 --- a/src/backends/cl/ClBackend.hpp +++ b/src/backends/cl/ClBackend.hpp @@ -12,8 +12,8 @@ namespace armnn class ClBackend : public IBackendInternal { public: - ClBackend() = default; - ~ClBackend() override = default; + ClBackend() = default; + ~ClBackend() = default; static const BackendId& GetIdStatic(); const BackendId& GetId() const override { return GetIdStatic(); } 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 <backendsCommon/BackendContextRegistry.hpp> -#include <boost/log/trivial.hpp> - -#include <mutex> - -#ifdef ARMCOMPUTECL_ENABLED -// Needed for the CL scheduler calls -#include <arm_compute/core/CL/OpenCL.h> -#include <arm_compute/core/CL/CLKernelLibrary.h> -#include <arm_compute/runtime/CL/CLScheduler.h> -#endif - -namespace armnn -{ - -namespace -{ - -static StaticRegistryInitializer<BackendContextRegistry> g_RegisterHelper -{ - BackendContextRegistryInstance(), - ClBackendId(), - [](const IRuntime::CreationOptions& options) - { - return IBackendContextUniquePtr(new ClBackendContext{options}); - } -}; - -static std::mutex g_ContextControlMutex; - -std::shared_ptr<ClBackendContext::ContextControlWrapper> -GetContextControlWrapper(const IRuntime::CreationOptions& options) -{ - static std::weak_ptr<ClBackendContext::ContextControlWrapper> contextControlWrapper; - - std::lock_guard<std::mutex> lockGuard(g_ContextControlMutex); - std::shared_ptr<ClBackendContext::ContextControlWrapper> result; - - if (contextControlWrapper.expired()) - { - result = std::make_shared<ClBackendContext::ContextControlWrapper>(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 diff --git a/src/backends/cl/ClBackendContext.hpp b/src/backends/cl/ClBackendContext.hpp deleted file mode 100644 index 4aaa8a9afe..0000000000 --- a/src/backends/cl/ClBackendContext.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - -#include <backendsCommon/IBackendContext.hpp> - -namespace armnn -{ - -class ClBackendContext : public IBackendContext -{ -public: - ClBackendContext(const IRuntime::CreationOptions& options); - ~ClBackendContext() override; - - struct ContextControlWrapper; -private: - std::shared_ptr<ContextControlWrapper> m_ContextControl; -}; - -} // namespace armnn
\ No newline at end of file diff --git a/src/backends/cl/ClLayerSupport.cpp b/src/backends/cl/ClLayerSupport.cpp index ab62eee41e..f4e14c24d0 100644 --- a/src/backends/cl/ClLayerSupport.cpp +++ b/src/backends/cl/ClLayerSupport.cpp @@ -53,7 +53,7 @@ ILayerSupportSharedPtr GetLayerSupportPointer() static StaticRegistryInitializer<LayerSupportRegistry> g_RegisterHelper{ LayerSupportRegistryInstance(), ClBackendId(), - [](const EmptyInitializer&) + []() { return GetLayerSupportPointer(); } diff --git a/src/backends/cl/backend.mk b/src/backends/cl/backend.mk index 8433240ae9..97df8e4903 100644 --- a/src/backends/cl/backend.mk +++ b/src/backends/cl/backend.mk @@ -8,7 +8,6 @@ # file in the root of ArmNN BACKEND_SOURCES := \ - ClBackendContext.cpp \ ClBackend.cpp \ ClContextControl.cpp \ ClLayerSupport.cpp \ @@ -55,4 +54,3 @@ BACKEND_TEST_SOURCES := \ test/ClRuntimeTests.cpp \ test/Fp16SupportTest.cpp \ test/OpenClTimerTest.cpp - |