aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeresaARM <teresa.charlinreyes@arm.com>2022-12-20 16:28:22 +0000
committerTeresaARM <teresa.charlinreyes@arm.com>2023-01-04 14:58:11 +0000
commit8b4a483e0e2fee508c23be2248ba0409789f1a74 (patch)
treeddb5c8f54149944fe566ff374c996ec13c226063
parent9d1786ee149821ec39fc0db0eba015f1c090f0ce (diff)
downloadarmnn-8b4a483e0e2fee508c23be2248ba0409789f1a74.tar.gz
Revert "IVGCVSW-7297 When creating multiple Executors only the last"
This reverts commit 21cf67af47a9cebbc10a98184c204fffa3722abd. Reason for revert: IVGCVSW-7397 Segmentation fault/Bus error in Backends CI job nightly Change-Id: I563e79700a857f8cf0fce0923a7040aeda29629b
-rw-r--r--src/backends/cl/ClBackendContext.cpp47
-rw-r--r--src/backends/cl/ClBackendContext.hpp5
2 files changed, 11 insertions, 41 deletions
diff --git a/src/backends/cl/ClBackendContext.cpp b/src/backends/cl/ClBackendContext.cpp
index 62c6b038da..c63fb0c893 100644
--- a/src/backends/cl/ClBackendContext.cpp
+++ b/src/backends/cl/ClBackendContext.cpp
@@ -20,20 +20,11 @@ namespace armnn
struct ClBackendContext::ClContextControlWrapper
{
- ClContextControlWrapper() {}
-
- bool IsInitialised()
- {
- return m_Initialised;
- }
-
- void Init(arm_compute::CLTuner* tuner,
- arm_compute::CLGEMMHeuristicsHandle* heuristicsHandle,
- bool profilingEnabled)
- {
- m_ClContextControl = ClContextControl(tuner, heuristicsHandle, profilingEnabled);
- m_Initialised = true;
- }
+ ClContextControlWrapper(arm_compute::CLTuner* tuner,
+ arm_compute::CLGEMMHeuristicsHandle* heuristicsHandle,
+ bool profilingEnabled)
+ : m_ClContextControl(tuner, heuristicsHandle, profilingEnabled)
+ {}
bool Sync()
{
@@ -62,28 +53,12 @@ struct ClBackendContext::ClContextControlWrapper
{
// There are no loaded networks left, so clear the CL cache to free up memory
m_ClContextControl.ClearClCache();
- m_Initialised = false;
}
}
-private:
- bool m_Initialised;
ClContextControl m_ClContextControl;
-
};
-/**
- * Returns a shared_ptr to the CLContextControlWrapper. This wraps the CLContextControl and ensures that we only create
- * and use one at a time.
- */
-std::shared_ptr<ClBackendContext::ClContextControlWrapper> ClBackendContext::Get()
-{
- static std::shared_ptr<ClBackendContext::ClContextControlWrapper> instance
- = std::make_shared<ClBackendContext::ClContextControlWrapper>();
- // Instantiated on first use.
- return instance;
-}
-
std::string LowerString(std::string value)
{
std::transform(value.begin(), value.end(), value.begin(),
@@ -171,7 +146,6 @@ ClBackendContext::ClBackendContext(const IRuntime::CreationOptions& options)
arm_compute::CLTuner* tuner = nullptr;
arm_compute::CLGEMMHeuristicsHandle* mlgoTuner = nullptr;
bool useLegacyTunerAPI = options.m_GpuAccTunedParameters.get() != nullptr;
-
if (useLegacyTunerAPI)
{
auto clTunerParams = PolymorphicDowncast<ClTunedParameters*>(
@@ -272,12 +246,11 @@ ClBackendContext::ClBackendContext(const IRuntime::CreationOptions& options)
tuner = m_Tuner.get();
}
- m_ClContextControlWrapper = Get();
-
- if (!m_ClContextControlWrapper->IsInitialised())
- {
- m_ClContextControlWrapper->Init(tuner, mlgoTuner, kernelProfiling);
- }
+ m_ClContextControlWrapper = std::make_unique<ClContextControlWrapper>(
+ tuner,
+ mlgoTuner,
+ kernelProfiling
+ );
}
bool ClBackendContext::BeforeLoadNetwork(NetworkId)
diff --git a/src/backends/cl/ClBackendContext.hpp b/src/backends/cl/ClBackendContext.hpp
index 276067727b..659d47b7c2 100644
--- a/src/backends/cl/ClBackendContext.hpp
+++ b/src/backends/cl/ClBackendContext.hpp
@@ -31,11 +31,8 @@ public:
private:
std::mutex m_Mutex;
-
struct ClContextControlWrapper;
- static std::shared_ptr<ClBackendContext::ClContextControlWrapper> Get();
-
- std::shared_ptr<ClBackendContext::ClContextControlWrapper> m_ClContextControlWrapper;
+ std::unique_ptr<ClContextControlWrapper> m_ClContextControlWrapper;
std::unordered_set<NetworkId> m_NetworkIds;