From 6f073727ad98d94f43a3938ddeac3f5a231ad959 Mon Sep 17 00:00:00 2001 From: Cathal Corbett Date: Fri, 4 Mar 2022 12:11:09 +0000 Subject: IVGCVSW-6814 Remove references to armnn:BackendId in the profiling code Signed-off-by: Cathal Corbett Change-Id: Ib399a5eee9e52882800ec3e02e4173424a7c19b1 --- .../backendsCommon/test/BackendProfilingTests.cpp | 14 +++++------ .../ConnectionAcknowledgedCommandHandler.cpp | 2 +- .../ConnectionAcknowledgedCommandHandler.hpp | 2 +- src/profiling/CounterDirectory.cpp | 7 ++---- src/profiling/CounterDirectory.hpp | 2 +- src/profiling/CounterIdMap.cpp | 11 ++++----- src/profiling/CounterIdMap.hpp | 17 +++++++------ src/profiling/Holder.cpp | 7 +++--- src/profiling/Holder.hpp | 10 ++++---- src/profiling/ICounterDirectory.hpp | 5 ++-- src/profiling/ICounterRegistry.hpp | 3 +-- src/profiling/IProfilingService.hpp | 2 +- src/profiling/PeriodicCounterCapture.cpp | 4 ++-- src/profiling/PeriodicCounterCapture.hpp | 8 +++---- .../PeriodicCounterSelectionCommandHandler.cpp | 14 +++++------ .../PeriodicCounterSelectionCommandHandler.hpp | 14 +++++------ src/profiling/ProfilingService.cpp | 5 ++-- src/profiling/ProfilingService.hpp | 6 ++--- src/profiling/RegisterBackendCounters.hpp | 4 ++-- src/profiling/backends/BackendProfiling.cpp | 2 +- src/profiling/backends/BackendProfiling.hpp | 4 ++-- src/profiling/test/ProfilingMocks.hpp | 4 ++-- src/profiling/test/ProfilingTestUtils.hpp | 1 - src/profiling/test/ProfilingTests.cpp | 28 +++++++++++----------- 24 files changed, 83 insertions(+), 93 deletions(-) diff --git a/src/backends/backendsCommon/test/BackendProfilingTests.cpp b/src/backends/backendsCommon/test/BackendProfilingTests.cpp index 3651696fd3..d262abca1b 100644 --- a/src/backends/backendsCommon/test/BackendProfilingTests.cpp +++ b/src/backends/backendsCommon/test/BackendProfilingTests.cpp @@ -155,8 +155,8 @@ TEST_CASE("TestBackendCounters") CounterIdMap counterIdMap; MockBackendSendCounterPacket sendCounterPacket; - const armnn::BackendId cpuAccId(armnn::Compute::CpuAcc); - const armnn::BackendId gpuAccId(armnn::Compute::GpuAcc); + const std::string cpuAccId(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)); + const std::string gpuAccId(GetComputeDeviceAsCString(armnn::Compute::GpuAcc)); ProfilingOptions options; options.m_EnableProfiling = true; @@ -173,7 +173,7 @@ TEST_CASE("TestBackendCounters") std::shared_ptr gpuProfilingContextPtr = std::make_shared(gpuBackendProfilingPtr); - std::unordered_map> backendProfilingContexts; backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr; @@ -222,7 +222,7 @@ TEST_CASE("TestBackendCounters") periodicCounterSelectionCommandHandler(PacketWriter(period, gpuCounters)); periodicCounterCapture.Stop(); - std::set activeIds = holder.GetCaptureData().GetActiveBackends(); + std::set activeIds = holder.GetCaptureData().GetActiveBackends(); CHECK(activeIds.size() == 1); CHECK((activeIds.find(gpuAccId) != activeIds.end())); @@ -403,8 +403,8 @@ TEST_CASE("TestBackendCounterLogging") CounterIdMap counterIdMap; MockBackendSendCounterPacket sendCounterPacket; - const armnn::BackendId cpuAccId(armnn::Compute::CpuAcc); - const armnn::BackendId gpuAccId(armnn::Compute::GpuAcc); + const std::string cpuAccId(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)); + const std::string gpuAccId(GetComputeDeviceAsCString(armnn::Compute::GpuAcc)); ProfilingOptions options; options.m_EnableProfiling = true; @@ -417,7 +417,7 @@ TEST_CASE("TestBackendCounterLogging") std::shared_ptr cpuProfilingContextPtr = std::make_shared(cpuBackendProfilingPtr); - std::unordered_map> backendProfilingContexts; uint16_t globalId = 5; diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp index 63ca741374..a3dabd53f5 100644 --- a/src/profiling/ConnectionAcknowledgedCommandHandler.cpp +++ b/src/profiling/ConnectionAcknowledgedCommandHandler.cpp @@ -55,7 +55,7 @@ void ConnectionAcknowledgedCommandHandler::operator()(const arm::pipe::Packet& p if(!backendContext.second->EnableProfiling(true)) { throw armnn::BackendProfilingException( - "Unable to enable profiling on Backend Id: " + backendContext.first.Get()); + "Unable to enable profiling on Backend Id: " + backendContext.first); } } } diff --git a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp index 5bb3c95cf5..9ea3bd4059 100644 --- a/src/profiling/ConnectionAcknowledgedCommandHandler.hpp +++ b/src/profiling/ConnectionAcknowledgedCommandHandler.hpp @@ -23,7 +23,7 @@ namespace pipe class ConnectionAcknowledgedCommandHandler final : public arm::pipe::CommandHandlerFunctor { -typedef const std::unordered_map>& +typedef const std::unordered_map>& BackendProfilingContexts; public: diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp index 5a7d8c6165..ba4ca1cc35 100644 --- a/src/profiling/CounterDirectory.cpp +++ b/src/profiling/CounterDirectory.cpp @@ -6,9 +6,8 @@ #include "CounterDirectory.hpp" #include "ProfilingUtils.hpp" -#include +#include #include -#include #include @@ -178,7 +177,7 @@ const CounterSet* CounterDirectory::RegisterCounterSet(const std::string& counte return counterSetPtr; } -const Counter* CounterDirectory::RegisterCounter(const armnn::BackendId& backendId, +const Counter* CounterDirectory::RegisterCounter(const std::string& /*backendId*/, const uint16_t uid, const std::string& parentCategoryName, uint16_t counterClass, @@ -191,8 +190,6 @@ const Counter* CounterDirectory::RegisterCounter(const armnn::BackendId& backend const armnn::Optional& deviceUid, const armnn::Optional& counterSetUid) { - IgnoreUnused(backendId); - // Check that the given parent category name is valid if (parentCategoryName.empty() || !arm::pipe::IsValidSwTraceString(parentCategoryName)) diff --git a/src/profiling/CounterDirectory.hpp b/src/profiling/CounterDirectory.hpp index ee9b52e8cd..4438042caf 100644 --- a/src/profiling/CounterDirectory.hpp +++ b/src/profiling/CounterDirectory.hpp @@ -36,7 +36,7 @@ public: uint16_t count = 0, const armnn::Optional& parentCategoryName = armnn::EmptyOptional()) override; - const Counter* RegisterCounter(const armnn::BackendId& backendId, + const Counter* RegisterCounter(const std::string& backendId, const uint16_t uid, const std::string& parentCategoryName, uint16_t counterClass, diff --git a/src/profiling/CounterIdMap.cpp b/src/profiling/CounterIdMap.cpp index bb575705ed..bff8e0660e 100644 --- a/src/profiling/CounterIdMap.cpp +++ b/src/profiling/CounterIdMap.cpp @@ -3,7 +3,6 @@ // SPDX-License-Identifier: MIT // #include "CounterIdMap.hpp" -#include "armnn/BackendId.hpp" #include #include @@ -14,9 +13,9 @@ namespace pipe void CounterIdMap::RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, - const armnn::BackendId& backendId) + const std::string& backendId) { - std::pair backendIdPair(backendCounterId, backendId); + std::pair backendIdPair(backendCounterId, backendId); m_GlobalCounterIdMap[globalCounterId] = backendIdPair; m_BackendCounterIdMap[backendIdPair] = globalCounterId; } @@ -27,9 +26,9 @@ void CounterIdMap::Reset() m_BackendCounterIdMap.clear(); } -uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const +uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const { - std::pair backendIdPair(backendCounterId, backendId); + std::pair backendIdPair(backendCounterId, backendId); auto it = m_BackendCounterIdMap.find(backendIdPair); if (it == m_BackendCounterIdMap.end()) { @@ -40,7 +39,7 @@ uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::Backe return it->second; } -const std::pair& CounterIdMap::GetBackendId(uint16_t globalCounterId) const +const std::pair& CounterIdMap::GetBackendId(uint16_t globalCounterId) const { auto it = m_GlobalCounterIdMap.find(globalCounterId); if (it == m_GlobalCounterIdMap.end()) diff --git a/src/profiling/CounterIdMap.hpp b/src/profiling/CounterIdMap.hpp index 7a3c3614ee..38955943aa 100644 --- a/src/profiling/CounterIdMap.hpp +++ b/src/profiling/CounterIdMap.hpp @@ -4,7 +4,6 @@ // #pragma once -#include "armnn/BackendId.hpp" #include namespace arm @@ -15,8 +14,8 @@ namespace pipe class ICounterMappings { public: - virtual uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const = 0; - virtual const std::pair& GetBackendId(uint16_t globalCounterId) const = 0; + virtual uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const = 0; + virtual const std::pair& GetBackendId(uint16_t globalCounterId) const = 0; virtual ~ICounterMappings() {} }; @@ -25,7 +24,7 @@ class IRegisterCounterMapping public: virtual void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, - const armnn::BackendId& backendId) = 0; + const std::string& backendId) = 0; virtual void Reset() = 0; virtual ~IRegisterCounterMapping() {} }; @@ -38,13 +37,13 @@ public: virtual ~CounterIdMap() {} void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, - const armnn::BackendId& backendId) override; + const std::string& backendId) override; void Reset() override; - uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId) const override; - const std::pair& GetBackendId(uint16_t globalCounterId) const override; + uint16_t GetGlobalId(uint16_t backendCounterId, const std::string& backendId) const override; + const std::pair& GetBackendId(uint16_t globalCounterId) const override; private: - std::map> m_GlobalCounterIdMap; - std::map, uint16_t> m_BackendCounterIdMap; + std::map> m_GlobalCounterIdMap; + std::map, uint16_t> m_BackendCounterIdMap; }; } // namespace pipe diff --git a/src/profiling/Holder.cpp b/src/profiling/Holder.cpp index 06600807f0..6517a24900 100644 --- a/src/profiling/Holder.cpp +++ b/src/profiling/Holder.cpp @@ -3,7 +3,6 @@ // SPDX-License-Identifier: MIT // -#include #include "Holder.hpp" namespace arm @@ -21,7 +20,7 @@ CaptureData& CaptureData::operator=(const CaptureData& other) return *this; } -void CaptureData::SetActiveBackends(const std::set& activeBackends) +void CaptureData::SetActiveBackends(const std::set& activeBackends) { m_ActiveBackends = activeBackends; } @@ -36,7 +35,7 @@ void CaptureData::SetCounterIds(const std::vector& counterIds) m_CounterIds = counterIds; } -const std::set& CaptureData::GetActiveBackends() const +const std::set& CaptureData::GetActiveBackends() const { return m_ActiveBackends; } @@ -73,7 +72,7 @@ bool CaptureData::IsCounterIdInCaptureData(uint16_t counterId) void Holder::SetCaptureData(uint32_t capturePeriod, const std::vector& counterIds, - const std::set& activeBackends) + const std::set& activeBackends) { std::lock_guard lockGuard(m_CaptureThreadMutex); diff --git a/src/profiling/Holder.hpp b/src/profiling/Holder.hpp index 612f8dc02e..10d393ff9b 100644 --- a/src/profiling/Holder.hpp +++ b/src/profiling/Holder.hpp @@ -23,7 +23,7 @@ public: : m_CapturePeriod(0) , m_CounterIds() , m_ActiveBackends(){} - CaptureData(uint32_t capturePeriod, std::vector& counterIds, std::set activeBackends) + CaptureData(uint32_t capturePeriod, std::vector& counterIds, std::set activeBackends) : m_CapturePeriod(capturePeriod) , m_CounterIds(counterIds) , m_ActiveBackends(activeBackends){} @@ -34,18 +34,18 @@ public: CaptureData& operator=(const CaptureData& other); - void SetActiveBackends(const std::set& activeBackends); + void SetActiveBackends(const std::set& activeBackends); void SetCapturePeriod(uint32_t capturePeriod); void SetCounterIds(const std::vector& counterIds); uint32_t GetCapturePeriod() const; const std::vector& GetCounterIds() const; - const std::set& GetActiveBackends() const; + const std::set& GetActiveBackends() const; bool IsCounterIdInCaptureData(uint16_t counterId); private: uint32_t m_CapturePeriod; std::vector m_CounterIds; - std::set m_ActiveBackends; + std::set m_ActiveBackends; }; class Holder @@ -56,7 +56,7 @@ public: CaptureData GetCaptureData() const; void SetCaptureData(uint32_t capturePeriod, const std::vector& counterIds, - const std::set& activeBackends); + const std::set& activeBackends); private: mutable std::mutex m_CaptureThreadMutex; diff --git a/src/profiling/ICounterDirectory.hpp b/src/profiling/ICounterDirectory.hpp index f902f9160b..b6b513a51f 100644 --- a/src/profiling/ICounterDirectory.hpp +++ b/src/profiling/ICounterDirectory.hpp @@ -5,7 +5,6 @@ #pragma once -#include #include #include @@ -94,7 +93,7 @@ class Counter final { public: // Constructors - Counter(armnn::BackendId backendId, + Counter(const std::string& backendId, uint16_t counterUid, uint16_t maxCounterUid, uint16_t counterClass, @@ -119,7 +118,7 @@ public: {} // Fields - armnn::BackendId m_BackendId; + std::string m_BackendId; uint16_t m_Uid; uint16_t m_MaxCounterUid; uint16_t m_Class; diff --git a/src/profiling/ICounterRegistry.hpp b/src/profiling/ICounterRegistry.hpp index 1d257b82db..9e04f605a1 100644 --- a/src/profiling/ICounterRegistry.hpp +++ b/src/profiling/ICounterRegistry.hpp @@ -6,7 +6,6 @@ #pragma once #include -#include namespace arm { @@ -30,7 +29,7 @@ public: uint16_t count, const armnn::Optional& parentCategoryName) = 0; - virtual const Counter* RegisterCounter(const armnn::BackendId& backendId, + virtual const Counter* RegisterCounter(const std::string& backendId, const uint16_t uid, const std::string& parentCategoryName, uint16_t counterClass, diff --git a/src/profiling/IProfilingService.hpp b/src/profiling/IProfilingService.hpp index 31d9b8d1e3..b91952249b 100644 --- a/src/profiling/IProfilingService.hpp +++ b/src/profiling/IProfilingService.hpp @@ -46,7 +46,7 @@ public: virtual ProfilingState ConfigureProfilingService(const ProfilingOptions& options, bool resetProfilingService = false) = 0; // Store a profiling context returned from a backend that support profiling. - virtual void AddBackendProfilingContext(const armnn::BackendId backendId, + virtual void AddBackendProfilingContext(const std::string& backendId, std::shared_ptr profilingContext) = 0; virtual ICounterRegistry& GetCounterRegistry() = 0; virtual IRegisterCounterMapping& GetCounterMappingRegistry() = 0; diff --git a/src/profiling/PeriodicCounterCapture.cpp b/src/profiling/PeriodicCounterCapture.cpp index 11ad6511fe..dd6d394d62 100644 --- a/src/profiling/PeriodicCounterCapture.cpp +++ b/src/profiling/PeriodicCounterCapture.cpp @@ -56,7 +56,7 @@ CaptureData PeriodicCounterCapture::ReadCaptureData() } void PeriodicCounterCapture::DispatchPeriodicCounterCapturePacket( - const armnn::BackendId& backendId, const std::vector& timestampValues) + const std::string& backendId, const std::vector& timestampValues) { // Report counter values for (const auto& timestampInfo : timestampValues) @@ -122,7 +122,7 @@ void PeriodicCounterCapture::Capture(IReadCounterValues& readCounterValues) // Report counter values for each active backend auto activeBackends = currentCaptureData.GetActiveBackends(); - for_each(activeBackends.begin(), activeBackends.end(), [&](const armnn::BackendId& backendId) + for_each(activeBackends.begin(), activeBackends.end(), [&](const std::string& backendId) { DispatchPeriodicCounterCapturePacket( backendId, m_BackendProfilingContexts.at(backendId)->ReportCounterValues()); diff --git a/src/profiling/PeriodicCounterCapture.hpp b/src/profiling/PeriodicCounterCapture.hpp index c442f425d4..9a678a85ab 100644 --- a/src/profiling/PeriodicCounterCapture.hpp +++ b/src/profiling/PeriodicCounterCapture.hpp @@ -32,8 +32,8 @@ public: ISendCounterPacket& packet, IReadCounterValues& readCounterValue, const ICounterMappings& counterIdMap, - const std::unordered_map>& backendProfilingContexts) + const std::unordered_map>& backendProfilingContexts) : m_CaptureDataHolder(data) , m_IsRunning(false) , m_KeepRunning(false) @@ -52,7 +52,7 @@ private: CaptureData ReadCaptureData(); void Capture(IReadCounterValues& readCounterValues); void DispatchPeriodicCounterCapturePacket( - const armnn::BackendId& backendId, const std::vector& timestampValues); + const std::string& backendId, const std::vector& timestampValues); const Holder& m_CaptureDataHolder; bool m_IsRunning; @@ -61,7 +61,7 @@ private: IReadCounterValues& m_ReadCounterValues; ISendCounterPacket& m_SendCounterPacket; const ICounterMappings& m_CounterIdMap; - const std::unordered_map>& m_BackendProfilingContexts; }; diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp index ae2aa0b94c..49928bf222 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp @@ -113,7 +113,7 @@ void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& return counterId > m_MaxArmCounterId; }); - std::set activeBackends; + std::set activeBackends; std::set backendCounterIds = std::set(backendIdStart, validCounterIds.end()); if (m_BackendCounterMap.size() != 0) @@ -166,13 +166,13 @@ void PeriodicCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& } } -std::set PeriodicCounterSelectionCommandHandler::ProcessBackendCounterIds( +std::set PeriodicCounterSelectionCommandHandler::ProcessBackendCounterIds( const uint32_t capturePeriod, const std::set newCounterIds, const std::set unusedCounterIds) { - std::set changedBackends; - std::set activeBackends = m_CaptureDataHolder.GetCaptureData().GetActiveBackends(); + std::set changedBackends; + std::set activeBackends = m_CaptureDataHolder.GetCaptureData().GetActiveBackends(); for (uint16_t counterId : newCounterIds) { @@ -195,7 +195,7 @@ std::set PeriodicCounterSelectionCommandHandler::ProcessBacken // If a backend has no counters associated with it we remove it from active backends and // send a capture period of zero with an empty vector, this will deactivate all the backends counters activeBackends.erase(backendId.second); - ActivateBackedCounters(backendId.second, 0, {}); + ActivateBackendCounters(backendId.second, 0, {}); } else { @@ -208,7 +208,7 @@ std::set PeriodicCounterSelectionCommandHandler::ProcessBacken { for (auto backend : changedBackends) { - ActivateBackedCounters(backend, capturePeriod, m_BackendCounterMap[backend]); + ActivateBackendCounters(backend, capturePeriod, m_BackendCounterMap[backend]); } } // Otherwise update all the backends with the new capture period and any new/unused counters @@ -216,7 +216,7 @@ std::set PeriodicCounterSelectionCommandHandler::ProcessBacken { for (auto backend : m_BackendCounterMap) { - ActivateBackedCounters(backend.first, capturePeriod, backend.second); + ActivateBackendCounters(backend.first, capturePeriod, backend.second); } if(capturePeriod == 0) { diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp index e8cdf0e5aa..4d94ba1010 100644 --- a/src/profiling/PeriodicCounterSelectionCommandHandler.hpp +++ b/src/profiling/PeriodicCounterSelectionCommandHandler.hpp @@ -35,7 +35,7 @@ public: PeriodicCounterSelectionCommandHandler(uint32_t familyId, uint32_t packetId, uint32_t version, - const std::unordered_map>& backendProfilingContexts, const ICounterMappings& counterIdMap, @@ -64,8 +64,8 @@ public: private: - std::unordered_map> m_BackendCounterMap; - const std::unordered_map> m_BackendCounterMap; + const std::unordered_map>& m_BackendProfilingContexts; const ICounterMappings& m_CounterIdMap; Holder& m_CaptureDataHolder; @@ -77,9 +77,9 @@ private: ISendCounterPacket& m_SendCounterPacket; const ProfilingStateMachine& m_StateMachine; - void ActivateBackedCounters(const armnn::BackendId backendId, - const uint32_t capturePeriod, - const std::vector counterIds) + void ActivateBackendCounters(const std::string backendId, + const uint32_t capturePeriod, + const std::vector counterIds) { armnn::Optional errorMsg = m_BackendProfilingContexts.at(backendId)->ActivateCounters(capturePeriod, counterIds); @@ -91,7 +91,7 @@ private: } } void ParseData(const arm::pipe::Packet& packet, CaptureData& captureData); - std::set ProcessBackendCounterIds(const uint32_t capturePeriod, + std::set ProcessBackendCounterIds(const uint32_t capturePeriod, const std::set newCounterIds, const std::set unusedCounterIds); diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp index 2e67dc870d..eba70e1c96 100644 --- a/src/profiling/ProfilingService.cpp +++ b/src/profiling/ProfilingService.cpp @@ -5,7 +5,6 @@ #include "ProfilingService.hpp" -#include #include #include @@ -194,7 +193,7 @@ void ProfilingService::Disconnect() } // Store a profiling context returned from a backend that support profiling, and register its counters -void ProfilingService::AddBackendProfilingContext(const armnn::BackendId backendId, +void ProfilingService::AddBackendProfilingContext(const std::string& backendId, std::shared_ptr profilingContext) { ARMNN_ASSERT(profilingContext != nullptr); @@ -262,7 +261,7 @@ CaptureData ProfilingService::GetCaptureData() void ProfilingService::SetCaptureData(uint32_t capturePeriod, const std::vector& counterIds, - const std::set& activeBackends) + const std::set& activeBackends) { m_Holder.SetCaptureData(capturePeriod, counterIds, activeBackends); } diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp index a4b02c10ad..7919c3019a 100644 --- a/src/profiling/ProfilingService.hpp +++ b/src/profiling/ProfilingService.hpp @@ -47,7 +47,7 @@ public: using IProfilingConnectionPtr = std::unique_ptr; using CounterIndices = std::vector*>; using CounterValues = std::list>; - using BackendProfilingContext = std::unordered_map>; ProfilingService(armnn::Optional reportStructure = armnn::EmptyOptional()) @@ -154,7 +154,7 @@ public: void Disconnect(); // Store a profiling context returned from a backend that support profiling. - void AddBackendProfilingContext(const armnn::BackendId backendId, + void AddBackendProfilingContext(const std::string& backendId, std::shared_ptr profilingContext) override; // Enable the recording of timeline events and entities @@ -177,7 +177,7 @@ public: CaptureData GetCaptureData() override; void SetCaptureData(uint32_t capturePeriod, const std::vector& counterIds, - const std::set& activeBackends); + const std::set& activeBackends); // Setters for the profiling service state void SetCounterValue(uint16_t counterUid, uint32_t value) override; diff --git a/src/profiling/RegisterBackendCounters.hpp b/src/profiling/RegisterBackendCounters.hpp index 34f9f3a3eb..88234df273 100644 --- a/src/profiling/RegisterBackendCounters.hpp +++ b/src/profiling/RegisterBackendCounters.hpp @@ -21,7 +21,7 @@ class RegisterBackendCounters : public IRegisterBackendCounters public: RegisterBackendCounters( - uint16_t currentMaxGlobalCounterID, const armnn::BackendId& backendId, IProfilingService& profilingService) + uint16_t currentMaxGlobalCounterID, const std::string& backendId, IProfilingService& profilingService) : m_CurrentMaxGlobalCounterID(currentMaxGlobalCounterID), m_BackendId(backendId), m_ProfilingService(profilingService), @@ -54,7 +54,7 @@ public: private: uint16_t m_CurrentMaxGlobalCounterID; - const armnn::BackendId& m_BackendId; + const std::string& m_BackendId; IProfilingService& m_ProfilingService; ICounterRegistry& m_CounterDirectory; }; diff --git a/src/profiling/backends/BackendProfiling.cpp b/src/profiling/backends/BackendProfiling.cpp index 6c0f9b1b5c..e29316ee3b 100644 --- a/src/profiling/backends/BackendProfiling.cpp +++ b/src/profiling/backends/BackendProfiling.cpp @@ -73,7 +73,7 @@ std::vector BackendProfiling::GetActiveCounters() for (auto globalCounterId : globalCounterIds) { // Get pair of local counterId and backendId using globalCounterId - const std::pair& backendCounterIdPair = + const std::pair& backendCounterIdPair = m_ProfilingService.GetCounterMappings().GetBackendId(globalCounterId); if (backendCounterIdPair.second == m_BackendId) { diff --git a/src/profiling/backends/BackendProfiling.hpp b/src/profiling/backends/BackendProfiling.hpp index 545234db56..bedda5d763 100644 --- a/src/profiling/backends/BackendProfiling.hpp +++ b/src/profiling/backends/BackendProfiling.hpp @@ -19,7 +19,7 @@ class BackendProfiling : public IBackendProfiling public: BackendProfiling(const ProfilingOptions& options, IProfilingService& profilingService, - const armnn::BackendId& backendId) + const std::string& backendId) : m_Options(options), m_ProfilingService(profilingService), m_BackendId(backendId) {} @@ -45,7 +45,7 @@ public: private: ProfilingOptions m_Options; IProfilingService& m_ProfilingService; - armnn::BackendId m_BackendId; + std::string m_BackendId; }; } // namespace pipe diff --git a/src/profiling/test/ProfilingMocks.hpp b/src/profiling/test/ProfilingMocks.hpp index 5e7d31a914..93145031ea 100644 --- a/src/profiling/test/ProfilingMocks.hpp +++ b/src/profiling/test/ProfilingMocks.hpp @@ -505,7 +505,7 @@ public: return counterSetPtr; } - const Counter* RegisterCounter(const armnn::BackendId& backendId, + const Counter* RegisterCounter(const std::string& backendId, const uint16_t uid, const std::string& parentCategoryName, uint16_t counterClass, @@ -676,7 +676,7 @@ public: void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, - const armnn::BackendId& backendId) + const std::string& backendId) { m_CounterMapping.RegisterMapping(globalCounterId, backendCounterId, backendId); } diff --git a/src/profiling/test/ProfilingTestUtils.hpp b/src/profiling/test/ProfilingTestUtils.hpp index 16c6dde4ea..32a156ee42 100644 --- a/src/profiling/test/ProfilingTestUtils.hpp +++ b/src/profiling/test/ProfilingTestUtils.hpp @@ -8,7 +8,6 @@ #include "ProfilingUtils.hpp" #include "Runtime.hpp" -#include #include #include #include diff --git a/src/profiling/test/ProfilingTests.cpp b/src/profiling/test/ProfilingTests.cpp index cba6ebd475..0a98af2817 100644 --- a/src/profiling/test/ProfilingTests.cpp +++ b/src/profiling/test/ProfilingTests.cpp @@ -1786,7 +1786,7 @@ TEST_CASE("CounterSelectionCommandHandlerParseData") const uint32_t packetId = 0x40000; uint32_t version = 1; - const std::unordered_map> backendProfilingContext; CounterIdMap counterIdMap; Holder holder; @@ -2342,7 +2342,7 @@ TEST_CASE("CheckPeriodicCounterCaptureThread") ProfilingStateMachine profilingStateMachine; - const std::unordered_map> backendProfilingContext; CounterIdMap counterIdMap; Holder data; @@ -3382,8 +3382,8 @@ TEST_CASE("CheckCounterIdMap") uint16_t globalCounterIds = 0; - armnn::BackendId cpuRefId(armnn::Compute::CpuRef); - armnn::BackendId cpuAccId(armnn::Compute::CpuAcc); + std::string cpuRefId(GetComputeDeviceAsCString(armnn::Compute::CpuRef)); + std::string cpuAccId(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)); std::vector cpuRefCounters = {0, 1, 2, 3}; std::vector cpuAccCounters = {0, 1}; @@ -3399,12 +3399,12 @@ TEST_CASE("CheckCounterIdMap") ++globalCounterIds; } - CHECK(counterIdMap.GetBackendId(0) == (std::pair(0, cpuRefId))); - CHECK(counterIdMap.GetBackendId(1) == (std::pair(1, cpuRefId))); - CHECK(counterIdMap.GetBackendId(2) == (std::pair(2, cpuRefId))); - CHECK(counterIdMap.GetBackendId(3) == (std::pair(3, cpuRefId))); - CHECK(counterIdMap.GetBackendId(4) == (std::pair(0, cpuAccId))); - CHECK(counterIdMap.GetBackendId(5) == (std::pair(1, cpuAccId))); + CHECK(counterIdMap.GetBackendId(0) == (std::pair(0, cpuRefId))); + CHECK(counterIdMap.GetBackendId(1) == (std::pair(1, cpuRefId))); + CHECK(counterIdMap.GetBackendId(2) == (std::pair(2, cpuRefId))); + CHECK(counterIdMap.GetBackendId(3) == (std::pair(3, cpuRefId))); + CHECK(counterIdMap.GetBackendId(4) == (std::pair(0, cpuAccId))); + CHECK(counterIdMap.GetBackendId(5) == (std::pair(1, cpuAccId))); CHECK(counterIdMap.GetGlobalId(0, cpuRefId) == 0); CHECK(counterIdMap.GetGlobalId(1, cpuRefId) == 1); @@ -3417,7 +3417,7 @@ TEST_CASE("CheckCounterIdMap") TEST_CASE("CheckRegisterBackendCounters") { uint16_t globalCounterIds = INFERENCES_RUN; - armnn::BackendId cpuRefId(armnn::Compute::CpuRef); + std::string cpuRefId(GetComputeDeviceAsCString(armnn::Compute::CpuRef)); // Reset the profiling service to the uninitialized state ProfilingOptions options; @@ -3474,8 +3474,8 @@ TEST_CASE("CheckCounterStatusQuery") ProfilingService profilingService; profilingService.ResetExternalProfilingOptions(options, true); - const armnn::BackendId cpuRefId(armnn::Compute::CpuRef); - const armnn::BackendId cpuAccId(armnn::Compute::CpuAcc); + const std::string cpuRefId(GetComputeDeviceAsCString(armnn::Compute::CpuRef)); + const std::string cpuAccId(GetComputeDeviceAsCString(armnn::Compute::CpuAcc)); // Create BackendProfiling for each backend BackendProfiling backendProfilingCpuRef(options, profilingService, cpuRefId); @@ -3610,7 +3610,7 @@ TEST_CASE("CheckRegisterCounters") CaptureData captureData; MockProfilingService mockProfilingService(mockBuffer, options.m_EnableProfiling, captureData); - armnn::BackendId cpuRefId(armnn::Compute::CpuRef); + std::string cpuRefId(GetComputeDeviceAsCString(armnn::Compute::CpuRef)); mockProfilingService.RegisterMapping(6, 0, cpuRefId); mockProfilingService.RegisterMapping(7, 1, cpuRefId); -- cgit v1.2.1