From 9789702c0b276ca9518e590f30465da7e76a940f Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Sun, 2 Feb 2020 12:52:59 +0000 Subject: IVGCVSW-4393 Register backend counters Signed-off-by: David Monahan Change-Id: I419ecc2fce4b7e0fcaeb6d1f9cb687c0b660125d Signed-off-by: Jim Flynn --- src/profiling/RegisterBackendCounters.cpp | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/profiling/RegisterBackendCounters.cpp (limited to 'src/profiling/RegisterBackendCounters.cpp') diff --git a/src/profiling/RegisterBackendCounters.cpp b/src/profiling/RegisterBackendCounters.cpp new file mode 100644 index 0000000000..0c68838cd6 --- /dev/null +++ b/src/profiling/RegisterBackendCounters.cpp @@ -0,0 +1,87 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "RegisterBackendCounters.hpp" + +namespace armnn +{ + +namespace profiling +{ + +void RegisterBackendCounters::RegisterCategory(const std::string& categoryName, + const Optional& deviceUid, + const Optional& counterSetUid) +{ + m_CounterDirectory.RegisterCategory(categoryName, deviceUid, counterSetUid); +} + +uint16_t RegisterBackendCounters::RegisterDevice(const std::string& deviceName, + uint16_t cores, + const Optional& parentCategoryName) +{ + const Device* devicePtr = m_CounterDirectory.RegisterDevice(deviceName, cores, parentCategoryName); + return devicePtr->m_Uid; +} + +uint16_t RegisterBackendCounters::RegisterCounterSet(const std::string& counterSetName, + uint16_t count, + const Optional& parentCategoryName) +{ + const CounterSet* counterSetPtr = m_CounterDirectory.RegisterCounterSet(counterSetName, count, parentCategoryName); + return counterSetPtr->m_Uid; +} + +uint16_t RegisterBackendCounters::RegisterCounter(const uint16_t uid, + const std::string& parentCategoryName, + uint16_t counterClass, + uint16_t interpolation, + double multiplier, + const std::string& name, + const std::string& description, + const Optional& units, + const Optional& numberOfCores, + const Optional& deviceUid, + const Optional& counterSetUid) +{ + ++m_CurrentMaxGlobalCounterID; + const Counter* counterPtr = m_CounterDirectory.RegisterCounter(m_BackendId, + m_CurrentMaxGlobalCounterID, + parentCategoryName, + counterClass, + interpolation, + multiplier, + name, + description, + units, + numberOfCores, + deviceUid, + counterSetUid); + m_CurrentMaxGlobalCounterID = counterPtr->m_MaxCounterUid; + // register mappings + IRegisterCounterMapping& counterIdMap = ProfilingService::Instance().GetCounterMappingRegistry(); + uint16_t globalCounterId = counterPtr->m_Uid; + if (globalCounterId == counterPtr->m_MaxCounterUid) + { + counterIdMap.RegisterMapping(globalCounterId, uid, m_BackendId); + } + else + { + uint16_t backendCounterId = uid; + while (globalCounterId <= counterPtr->m_MaxCounterUid) + { + // register mapping + // globalCounterId -> backendCounterId, m_BackendId + counterIdMap.RegisterMapping(globalCounterId, backendCounterId, m_BackendId); + ++globalCounterId; + ++backendCounterId; + } + } + return m_CurrentMaxGlobalCounterID; +} + +} // namespace profiling + +} // namespace armnn -- cgit v1.2.1