aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CounterIdMap.cpp
diff options
context:
space:
mode:
authorDavid Monahan <david.monahan@arm.com>2020-01-30 12:44:23 +0000
committerDavid Monahan <david.monahan@arm.com>2020-01-30 12:58:58 +0000
commitde80307c06986cc53cd1bd5a62fc08af1de7610f (patch)
tree21901cab5ff9dc83de680356f48e285cc3594cd3 /src/profiling/CounterIdMap.cpp
parent9308f6033547836007bd597fbe35b4c8d15105d7 (diff)
downloadarmnn-de80307c06986cc53cd1bd5a62fc08af1de7610f.tar.gz
IVGCVSW-4391 Add Global/Backend Counter ID map
Signed-off-by: David Monahan <david.monahan@arm.com> Change-Id: I943e02bc2026564e3a19d03e81ba75850d204497
Diffstat (limited to 'src/profiling/CounterIdMap.cpp')
-rw-r--r--src/profiling/CounterIdMap.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/profiling/CounterIdMap.cpp b/src/profiling/CounterIdMap.cpp
new file mode 100644
index 0000000000..a925fb9cb4
--- /dev/null
+++ b/src/profiling/CounterIdMap.cpp
@@ -0,0 +1,50 @@
+//
+// Copyright © 2020 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#include "CounterIdMap.hpp"
+#include "armnn/BackendId.hpp"
+#include <map>
+#include <armnn/Exceptions.hpp>
+
+namespace armnn
+{
+namespace profiling
+{
+
+void CounterIdMap::RegisterMapping(uint16_t globalCounterId,
+ uint16_t backendCounterId,
+ const armnn::BackendId& backendId)
+{
+ std::pair<uint16_t, armnn::BackendId> backendIdPair(backendCounterId, backendId);
+ m_GlobalCounterIdMap[globalCounterId] = backendIdPair;
+ m_BackendCounterIdMap[backendIdPair] = globalCounterId;
+}
+
+uint16_t CounterIdMap::GetGlobalId(uint16_t backendCounterId, const armnn::BackendId& backendId)
+{
+ std::pair<uint16_t, armnn::BackendId> backendIdPair(backendCounterId, backendId);
+ auto it = m_BackendCounterIdMap.find(backendIdPair);
+ if (it == m_BackendCounterIdMap.end())
+ {
+ std::stringstream ss;
+ ss << "No Backend Counter [" << backendIdPair.second << ":" << backendIdPair.first << "] registered";
+ throw armnn::Exception(ss.str());
+ }
+ return it->second;
+}
+
+const std::pair<uint16_t, armnn::BackendId>& CounterIdMap::GetBackendId(uint16_t globalCounterId)
+{
+ auto it = m_GlobalCounterIdMap.find(globalCounterId);
+ if (it == m_GlobalCounterIdMap.end())
+ {
+ std::stringstream ss;
+ ss << "No Global Counter ID [" << globalCounterId << "] registered";
+ throw armnn::Exception(ss.str());
+ }
+ return it->second;
+}
+
+} // namespace profiling
+} // namespace armnn \ No newline at end of file