IVGCVSW-4834 Add calls to increment REGISTERED_BACKENDS and UNREGISTERED_BACKENDS
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I3600dd15f97ccd4ab745deb87d06ba978e2a0b11
diff --git a/src/armnn/BackendRegistry.cpp b/src/armnn/BackendRegistry.cpp
index a79cdd0..ff63c82 100644
--- a/src/armnn/BackendRegistry.cpp
+++ b/src/armnn/BackendRegistry.cpp
@@ -5,6 +5,7 @@
#include <armnn/BackendRegistry.hpp>
#include <armnn/Exceptions.hpp>
+#include <ProfilingService.hpp>
namespace armnn
{
@@ -24,11 +25,25 @@
CHECK_LOCATION());
}
m_Factories[id] = factory;
+
+ if (m_ProfilingService.has_value())
+ {
+ if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
+ {
+ m_ProfilingService.value().IncrementCounterValue(armnn::profiling::REGISTERED_BACKENDS);
+ }
+ }
+
}
void BackendRegistry::Deregister(const BackendId& id)
{
m_Factories.erase(id);
+
+ if (m_ProfilingService.has_value() && m_ProfilingService.value().IsProfilingEnabled())
+ {
+ m_ProfilingService.value().IncrementCounterValue(armnn::profiling::UNREGISTERED_BACKENDS);
+ }
}
bool BackendRegistry::IsBackendRegistered(const BackendId& id) const
@@ -86,5 +101,10 @@
std::swap(instance.m_Factories, other);
}
+void BackendRegistry::SetProfilingService(armnn::Optional<profiling::ProfilingService&> profilingService)
+{
+ m_ProfilingService = profilingService;
+}
+
} // namespace armnn
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index 483eea7..dbdd409 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -220,6 +220,7 @@
}
}
+ BackendRegistryInstance().SetProfilingService(m_ProfilingService);
// pass configuration info to the profiling service
m_ProfilingService.ConfigureProfilingService(options.m_ProfilingOptions);
@@ -269,6 +270,8 @@
DynamicBackendUtils::DeregisterDynamicBackends(m_DeviceSpec.GetDynamicBackends());
m_DeviceSpec.ClearDynamicBackends();
m_BackendContexts.clear();
+
+ BackendRegistryInstance().SetProfilingService(armnn::EmptyOptional());
}
LoadedNetwork* Runtime::GetLoadedNetworkPtr(NetworkId networkId) const
diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp
index 52b6e23..66f99be 100644
--- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp
+++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp
@@ -118,7 +118,7 @@
{
// Reset the profiling service to the uninitialized state
armnn::IRuntime::CreationOptions options;
- options.m_ProfilingOptions.m_EnableProfiling = true;;
+ options.m_ProfilingOptions.m_EnableProfiling = true;
armnn::MockBackendInitialiser initialiser;
// Create a runtime
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index a26bba2..21972b4 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -377,6 +377,10 @@
std::string("backends"));
ARMNN_ASSERT(registeredBackendsCounter);
InitializeCounterValue(registeredBackendsCounter->m_Uid);
+
+ // Due to backends being registered before the profiling service becomes active,
+ // we need to set the counter to the correct value here
+ SetCounterValue(armnn::profiling::REGISTERED_BACKENDS, static_cast<uint32_t>(BackendRegistryInstance().Size()));
}
// Register a counter for the number of registered backends
if (!m_CounterDirectory.IsCounterRegistered("Backends unregistered"))