diff options
author | Jim Flynn <jim.flynn@arm.com> | 2020-01-30 14:10:55 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-02-02 19:32:41 +0000 |
commit | 8e0c7a66efc8d61787c43cdaeab3754e2905f623 (patch) | |
tree | 37f0de44d4e012f4c24a831add7d7b2817571ac1 /src/profiling | |
parent | 5e51cd803c7d926b2a9bd7c680c8d59fe100c2f2 (diff) | |
download | armnn-8e0c7a66efc8d61787c43cdaeab3754e2905f623.tar.gz |
IVGCVSW-4394 Add CounterIdMap to Profiling Service
Change-Id: I416397a7855fe45319b4801252e141b78f0325f0
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/profiling')
-rw-r--r-- | src/profiling/CounterIdMap.cpp | 8 | ||||
-rw-r--r-- | src/profiling/CounterIdMap.hpp | 31 | ||||
-rw-r--r-- | src/profiling/ProfilingService.cpp | 10 | ||||
-rw-r--r-- | src/profiling/ProfilingService.hpp | 8 |
4 files changed, 47 insertions, 10 deletions
diff --git a/src/profiling/CounterIdMap.cpp b/src/profiling/CounterIdMap.cpp index a925fb9cb4..8ee80f913c 100644 --- a/src/profiling/CounterIdMap.cpp +++ b/src/profiling/CounterIdMap.cpp @@ -4,8 +4,8 @@ // #include "CounterIdMap.hpp" #include "armnn/BackendId.hpp" -#include <map> #include <armnn/Exceptions.hpp> +#include <map> namespace armnn { @@ -21,7 +21,7 @@ void CounterIdMap::RegisterMapping(uint16_t globalCounterId, m_BackendCounterIdMap[backendIdPair] = globalCounterId; } -uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) +uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const { std::pair<uint16_t, armnn::BackendId> backendIdPair(backendCounterId, backendId); auto it = m_BackendCounterIdMap.find(backendIdPair); @@ -34,7 +34,7 @@ uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::Backe return it->second; } -const std::pair<uint16_t, armnn::BackendId>& CounterIdMap::GetBackendId(uint16_t globalCounterId) +const std::pair<uint16_t, armnn::BackendId>& CounterIdMap::GetBackendId(uint16_t globalCounterId) const { auto it = m_GlobalCounterIdMap.find(globalCounterId); if (it == m_GlobalCounterIdMap.end()) @@ -47,4 +47,4 @@ const std::pair<uint16_t, armnn::BackendId>& CounterIdMap::GetBackendId(uint16_t } } // namespace profiling -} // namespace armnn
\ No newline at end of file +} // namespace armnn diff --git a/src/profiling/CounterIdMap.hpp b/src/profiling/CounterIdMap.hpp index e401491c10..cb6b9c92e8 100644 --- a/src/profiling/CounterIdMap.hpp +++ b/src/profiling/CounterIdMap.hpp @@ -12,17 +12,38 @@ namespace armnn namespace profiling { -class CounterIdMap +class ICounterMappings +{ +public: + virtual uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const = 0; + virtual const std::pair<uint16_t, armnn::BackendId>& GetBackendId(uint16_t globalCounterId) const = 0; + virtual ~ICounterMappings() {} +}; + +class IRegisterCounterMapping +{ +public: + virtual void RegisterMapping(uint16_t globalCounterId, + uint16_t backendCounterId, + const armnn::BackendId& backendId) = 0; + virtual ~IRegisterCounterMapping() {} +}; + +class CounterIdMap : public ICounterMappings, public IRegisterCounterMapping { public: - void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId& backendId); - uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId); - const std::pair<uint16_t, armnn::BackendId>& GetBackendId(uint16_t globalCounterId); + CounterIdMap() = default; + virtual ~CounterIdMap() {} + void RegisterMapping(uint16_t globalCounterId, + uint16_t backendCounterId, + const armnn::BackendId& backendId) override; + uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const override; + const std::pair<uint16_t, armnn::BackendId>& GetBackendId(uint16_t globalCounterId) const override; private: std::map<uint16_t, std::pair<uint16_t, armnn::BackendId>> m_GlobalCounterIdMap; std::map<std::pair<uint16_t, armnn::BackendId>, uint16_t> m_BackendCounterIdMap; }; } // namespace profiling -} // namespace armnn
\ No newline at end of file +} // namespace armnn diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index cc41fb2d69..b06f149486 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -209,6 +209,16 @@ uint32_t ProfilingService::GetCounterValue(uint16_t counterUid) const return counterValuePtr->load(std::memory_order::memory_order_relaxed); } +const ICounterMappings& ProfilingService::GetCounterMappings() const +{ + return m_CounterIdMap; +} + +IRegisterCounterMapping& ProfilingService::GetCounterMappingRegistrar() +{ + return m_CounterIdMap; +} + void ProfilingService::SetCounterValue(uint16_t counterUid, uint32_t value) { CheckCounterUid(counterUid); diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index 24748bb69b..9cf7545205 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -9,6 +9,7 @@ #include "CommandHandler.hpp" #include "ConnectionAcknowledgedCommandHandler.hpp" #include "CounterDirectory.hpp" +#include "CounterIdMap.hpp" #include "ICounterValues.hpp" #include "PeriodicCounterCapture.hpp" #include "PeriodicCounterSelectionCommandHandler.hpp" @@ -61,12 +62,16 @@ public: // Disconnects the profiling service from the external server void Disconnect(); - // Getters for the profiling service state const ICounterDirectory& GetCounterDirectory() const; ProfilingState GetCurrentState() const; bool IsCounterRegistered(uint16_t counterUid) const override; uint32_t GetCounterValue(uint16_t counterUid) const override; uint16_t GetCounterCount() const override; + // counter global/backend mapping functions + const ICounterMappings& GetCounterMappings() const; + IRegisterCounterMapping& GetCounterMappingRegistrar(); + + // Getters for the profiling service state bool IsProfilingEnabled(); // Setters for the profiling service state @@ -105,6 +110,7 @@ private: // Profiling service components ExternalProfilingOptions m_Options; CounterDirectory m_CounterDirectory; + CounterIdMap m_CounterIdMap; IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory; IProfilingConnectionPtr m_ProfilingConnection; ProfilingStateMachine m_StateMachine; |