aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2019-10-15 10:18:11 +0100
committerJim Flynn Arm <jim.flynn@arm.com>2019-10-15 14:43:37 +0000
commit672d06eac5b0842c22f9f219e9b65efcd5883d33 (patch)
tree7961c81d0073d9e49491c26e67586cfa1a0aae6c
parent062e0e95a4332430efa7b0d5af3aab7a5b45a2dc (diff)
downloadarmnn-672d06eac5b0842c22f9f219e9b65efcd5883d33.tar.gz
IVGCVSW-3948 Add Startup method to Profiling
Change-Id: I591e84048775278bfc728e1b0c189ff4cf2d350b Signed-off-by: Jim Flynn <jim.flynn@arm.com>
-rw-r--r--src/armnn/Runtime.cpp2
-rw-r--r--src/profiling/ProfilingService.cpp50
-rw-r--r--src/profiling/ProfilingService.hpp3
-rw-r--r--src/profiling/test/ProfilingTests.cpp27
4 files changed, 81 insertions, 1 deletions
diff --git a/src/armnn/Runtime.cpp b/src/armnn/Runtime.cpp
index dd46708508..68975a2191 100644
--- a/src/armnn/Runtime.cpp
+++ b/src/armnn/Runtime.cpp
@@ -149,7 +149,7 @@ Runtime::Runtime(const CreationOptions& options)
BOOST_LOG_TRIVIAL(info) << "ArmNN v" << ARMNN_VERSION << "\n";
// pass configuration info to the profiling service
- armnn::profiling::ProfilingService::Instance().ResetExternalProfilingOptions(options.m_ProfilingOptions);
+ armnn::profiling::ProfilingService::Instance().ConfigureProfilingService(options.m_ProfilingOptions);
// Load any available/compatible dynamic backend before the runtime
// goes through the backend registry
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index b481695d49..b87773fc86 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -28,6 +28,56 @@ void ProfilingService::ResetExternalProfilingOptions(const ExternalProfilingOpti
}
}
+ProfilingState ProfilingService::ConfigureProfilingService(
+ const ExternalProfilingOptions& options,
+ bool resetProfilingService)
+{
+ ResetExternalProfilingOptions(options, resetProfilingService);
+ ProfilingState currentState = m_StateMachine.GetCurrentState();
+ if (options.m_EnableProfiling)
+ {
+ switch (currentState)
+ {
+ case ProfilingState::Uninitialised:
+ Update(); // should transition to NotConnected
+ Update(); // will either stay in NotConnected because there is no server
+ // or will enter WaitingForAck.
+ currentState = m_StateMachine.GetCurrentState();
+ if (currentState == ProfilingState::WaitingForAck)
+ {
+ Update(); // poke it again to send out the metadata packet
+ }
+ currentState = m_StateMachine.GetCurrentState();
+ return currentState;
+ case ProfilingState::NotConnected:
+ Update(); // will either stay in NotConnected because there is no server
+ // or will enter WaitingForAck
+ currentState = m_StateMachine.GetCurrentState();
+ if (currentState == ProfilingState::WaitingForAck)
+ {
+ Update(); // poke it again to send out the metadata packet
+ }
+ currentState = m_StateMachine.GetCurrentState();
+ return currentState;
+ default:
+ return currentState;
+ }
+ }
+ else
+ {
+ // Make sure profiling is shutdown
+ switch (currentState)
+ {
+ case ProfilingState::Uninitialised:
+ case ProfilingState::NotConnected:
+ return currentState;
+ default:
+ Stop();
+ return m_StateMachine.GetCurrentState();
+ }
+ }
+}
+
void ProfilingService::Update()
{
if (!m_Options.m_EnableProfiling)
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 1afcb1ca97..dda37dddf2 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -42,6 +42,9 @@ public:
// Resets the profiling options, optionally clears the profiling service entirely
void ResetExternalProfilingOptions(const ExternalProfilingOptions& options, bool resetProfilingService = false);
+ ProfilingState ConfigureProfilingService(const ExternalProfilingOptions& options,
+ bool resetProfilingService = false);
+
// Updates the profiling service, making it transition to a new state if necessary
void Update();
diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp
index 033f64ae24..b32a55cc6d 100644
--- a/src/profiling/test/ProfilingTests.cpp
+++ b/src/profiling/test/ProfilingTests.cpp
@@ -3137,4 +3137,31 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceGoodPerJobCounterSelectionPacket)
profilingService.ResetExternalProfilingOptions(options, true);
}
+BOOST_AUTO_TEST_CASE(CheckConfigureProfilingServiceOn)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ options.m_EnableProfiling = true;
+ ProfilingService& profilingService = ProfilingService::Instance();
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
+ profilingService.ConfigureProfilingService(options);
+ // should get as far as NOT_CONNECTED
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::NotConnected);
+ // Reset the profiling service to stop any running thread
+ options.m_EnableProfiling = false;
+ profilingService.ResetExternalProfilingOptions(options, true);
+}
+
+BOOST_AUTO_TEST_CASE(CheckConfigureProfilingServiceOff)
+{
+ armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
+ ProfilingService& profilingService = ProfilingService::Instance();
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
+ profilingService.ConfigureProfilingService(options);
+ // should not move from Uninitialised
+ BOOST_CHECK(profilingService.GetCurrentState() == ProfilingState::Uninitialised);
+ // Reset the profiling service to stop any running thread
+ options.m_EnableProfiling = false;
+ profilingService.ResetExternalProfilingOptions(options, true);
+}
+
BOOST_AUTO_TEST_SUITE_END()