From: FinnWilliamsArm Date: Wed, 18 Sep 2019 09:28:16 +0000 (+0100) Subject: IVGCVSW-3413 Add the Counters Metadata X-Git-Tag: submit/tizen/20200316.035456~231 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ce2d9d13fbc0c8efd83dfb411c045553f87331f9;p=platform%2Fupstream%2Farmnn.git IVGCVSW-3413 Add the Counters Metadata Signed-off-by: FinnWilliamsArm Change-Id: I1313320a28b2d17d1adbc80248882ef458c34a14 --- diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index eaaded5..4e61383 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -21,8 +21,27 @@ void ProfilingService::Initialise() { if (m_Options.m_EnableProfiling == true) { - // Setup Counter Directory - this should only be created if profiling is enabled - // Setup Counter meta + // Setup provisional Counter Directory example - this should only be created if profiling is enabled + // Setup provisional Counter meta example + const std::string categoryName = "Category"; + + m_CounterDirectory.RegisterCategory(categoryName); + m_CounterDirectory.RegisterDevice("device name", 0, categoryName); + m_CounterDirectory.RegisterCounterSet("counterSet_name", 2, categoryName); + + m_CounterDirectory.RegisterCounter(categoryName, + 0, + 1, + 123.45f, + "counter name 1", + "counter description"); + + m_CounterDirectory.RegisterCounter(categoryName, + 0, + 1, + 123.45f, + "counter name 2", + "counter description"); // For now until CounterDirectory setup is implemented, change m_State once everything initialised m_State.TransitionToState(ProfilingState::NotConnected); @@ -46,10 +65,26 @@ void ProfilingService::Run() } } +const ICounterDirectory& ProfilingService::GetCounterDirectory() const +{ + return m_CounterDirectory; +} + ProfilingState ProfilingService::GetCurrentState() const { return m_State.GetCurrentState(); } + +void ProfilingService::ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options) +{ + if(!m_Options.m_EnableProfiling) + { + m_Options = options; + Initialise(); + return; + } + m_Options = options; +} } // namespace profiling } // namespace armnn \ No newline at end of file diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index 33f1135..eb29c33 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -7,6 +7,7 @@ #include "ProfilingStateMachine.hpp" #include "ProfilingConnectionFactory.hpp" +#include "CounterDirectory.hpp" namespace armnn { @@ -22,16 +23,17 @@ public: void Run(); + const ICounterDirectory& GetCounterDirectory() const; ProfilingState GetCurrentState() const; - - // Options are public to allow profiling to be turned on at runtime - Runtime::CreationOptions::ExternalProfilingOptions m_Options; + void ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options); private: void Initialise(); - ProfilingStateMachine m_State; + CounterDirectory m_CounterDirectory; ProfilingConnectionFactory m_Factory; + Runtime::CreationOptions::ExternalProfilingOptions m_Options; + ProfilingStateMachine m_State; }; } // namespace profiling diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index a5d60a5..2a20aac 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -535,13 +535,28 @@ BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime) BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised); service.Run(); BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised); - service.m_Options.m_EnableProfiling = true; - service.Run(); + options.m_EnableProfiling = true; + service.ResetExternalProfilingOptions(options); BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected); service.Run(); BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck); } +BOOST_AUTO_TEST_CASE(CheckProfilingServiceCounterDirectory) +{ + armnn::Runtime::CreationOptions::ExternalProfilingOptions options; + ProfilingService service(options); + + const ICounterDirectory& counterDirectory0 = service.GetCounterDirectory(); + BOOST_CHECK(counterDirectory0.GetCounterCount() == 0); + + options.m_EnableProfiling = true; + service.ResetExternalProfilingOptions(options); + + const ICounterDirectory& counterDirectory1 = service.GetCounterDirectory(); + BOOST_CHECK(counterDirectory1.GetCounterCount() != 0); +} + BOOST_AUTO_TEST_CASE(CheckProfilingObjectUids) { uint16_t uid = 0;