From a84edee4702c112a6e004b1987acc11144e2d6dd Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Wed, 2 Oct 2019 12:50:57 +0100 Subject: IVGCVSW-3937 Initial ServiceProfiling refactoring * Made the ServiceProfiling class a singleton * Registered basic category and counters * Code refactoring * Updated unit tests accordingly Signed-off-by: Matteo Martincigh Change-Id: I648a6202eead2a3016aac14d905511bd945a90cb --- src/profiling/ProfilingService.hpp | 63 ++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'src/profiling/ProfilingService.hpp') diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index 6d617978e5..36d95e0b5e 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -16,38 +16,63 @@ namespace armnn namespace profiling { -class ProfilingService : IWriteCounterValues +class ProfilingService final : public IReadWriteCounterValues { public: - ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options); - ~ProfilingService() = default; + using ExternalProfilingOptions = Runtime::CreationOptions::ExternalProfilingOptions; + using IProfilingConnectionPtr = std::unique_ptr; + using CounterIndices = std::vector*>; + using CounterValues = std::list>; + + // Getter for the singleton instance + static ProfilingService& Instance() + { + static ProfilingService instance; + return instance; + } + + // Resets the profiling options, optionally clears the profiling service entirely + void ResetExternalProfilingOptions(const ExternalProfilingOptions& options, bool resetProfilingService = false); + // Runs the profiling service void Run(); + // Getters for the profiling service state const ICounterDirectory& GetCounterDirectory() const; ProfilingState GetCurrentState() const; - void ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options); + uint16_t GetCounterCount() const override; + uint32_t GetCounterValue(uint16_t counterUid) const override; - uint16_t GetCounterCount() const; - void GetCounterValue(uint16_t index, uint32_t& value) const; - void SetCounterValue(uint16_t index, uint32_t value); - void AddCounterValue(uint16_t index, uint32_t value); - void SubtractCounterValue(uint16_t index, uint32_t value); - void IncrementCounterValue(uint16_t index); - void DecrementCounterValue(uint16_t index); + // Setters for the profiling service state + void SetCounterValue(uint16_t counterUid, uint32_t value) override; + uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override; + uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override; + uint32_t IncrementCounterValue(uint16_t counterUid) override; + uint32_t DecrementCounterValue(uint16_t counterUid) override; private: - void Initialise(); - void CheckIndexSize(uint16_t counterIndex) const; + // Default/copy/move constructors/destructors and copy/move assignment operators are kept private + ProfilingService() = default; + ProfilingService(const ProfilingService&) = delete; + ProfilingService(ProfilingService&&) = delete; + ProfilingService& operator=(const ProfilingService&) = delete; + ProfilingService& operator=(ProfilingService&&) = delete; + ~ProfilingService() = default; - CounterDirectory m_CounterDirectory; - ProfilingConnectionFactory m_Factory; - Runtime::CreationOptions::ExternalProfilingOptions m_Options; - ProfilingStateMachine m_State; + // Initialization functions + void Initialize(); + void InitializeCounterValue(uint16_t counterUid); - std::unordered_map> m_CounterIdToValue; + // Profiling service state variables + ExternalProfilingOptions m_Options; + CounterDirectory m_CounterDirectory; + ProfilingConnectionFactory m_ProfilingConnectionFactory; + IProfilingConnectionPtr m_ProfilingConnection; + ProfilingStateMachine m_StateMachine; + CounterIndices m_CounterIndex; + CounterValues m_CounterValues; }; } // namespace profiling -} // namespace armnn \ No newline at end of file +} // namespace armnn -- cgit v1.2.1