aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/CounterDirectory.cpp
diff options
context:
space:
mode:
authorAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-08-22 18:10:52 +0100
committerAron Virginas-Tar <Aron.Virginas-Tar@arm.com>2019-08-23 15:19:33 +0100
commit4e5fc1fb6c74fa6e4dcb24639db8fafd69a0a065 (patch)
tree17c793909c046e769d46fe65ddcaf59a51174acc /src/profiling/CounterDirectory.cpp
parent00dda4a66c10a56b02bdd534ba3b5fdb27527ebc (diff)
downloadarmnn-4e5fc1fb6c74fa6e4dcb24639db8fafd69a0a065.tar.gz
IVGCVSW-3410 Create Counter Directory metadata classes
* Created classes Device, Counter, Category, CounterDirectory Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> Change-Id: Iaec4b0e154d962983c60460714bafcc1fb16f47e
Diffstat (limited to 'src/profiling/CounterDirectory.cpp')
-rw-r--r--src/profiling/CounterDirectory.cpp163
1 files changed, 163 insertions, 0 deletions
diff --git a/src/profiling/CounterDirectory.cpp b/src/profiling/CounterDirectory.cpp
new file mode 100644
index 0000000000..a84897995d
--- /dev/null
+++ b/src/profiling/CounterDirectory.cpp
@@ -0,0 +1,163 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "CounterDirectory.hpp"
+
+#include <armnn/Exceptions.hpp>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+CounterDirectory::CounterDirectory(uint16_t uid,
+ const std::string& name,
+ uint16_t deviceCount,
+ uint16_t counterCount,
+ uint16_t categoryCount)
+ : m_Uid(uid)
+ , m_Name(name)
+ , m_DeviceCount(deviceCount)
+ , m_CounterCount(counterCount)
+ , m_CategoryCount(categoryCount)
+ , m_DeviceIds(deviceCount)
+ , m_CounterIds(counterCount)
+ , m_CategoryIds(categoryCount)
+ , m_DeviceObjects(deviceCount)
+ , m_CounterObjects(counterCount)
+ , m_CategoryObjects(categoryCount)
+{}
+
+// Helper methods
+void CounterDirectory::CheckDeviceIndex(uint16_t index) const
+{
+ if (index >= m_DeviceCount)
+ {
+ throw InvalidArgumentException("Invalid device index");
+ }
+}
+
+void CounterDirectory::CheckCounterIndex(uint16_t index) const
+{
+ if (index >= m_CounterCount)
+ {
+ throw InvalidArgumentException("Invalid counter index");
+ }
+}
+
+void CounterDirectory::CheckCategoryIndex(uint16_t index) const
+{
+ if (index >= m_CategoryCount)
+ {
+ throw InvalidArgumentException("Invalid category index");
+ }
+}
+
+// Getters for basic attributes
+uint16_t CounterDirectory::GetUid() const
+{
+ return m_Uid;
+}
+
+const std::string& CounterDirectory::GetName() const
+{
+ return m_Name;
+}
+
+// Getters for counts
+uint16_t CounterDirectory::GetDeviceCount() const
+{
+ return m_DeviceCount;
+}
+
+uint16_t CounterDirectory::GetCounterCount() const
+{
+ return m_CounterCount;
+}
+
+uint16_t CounterDirectory::GetCategoryCount() const
+{
+ return m_CategoryCount;
+}
+
+// Getters and setters for devices
+void CounterDirectory::GetDeviceValue(uint16_t index, uint32_t& value) const
+{
+ CheckDeviceIndex(index);
+ value = m_DeviceIds[index].load();
+}
+
+void CounterDirectory::SetDeviceValue(uint16_t index, uint32_t value)
+{
+ CheckDeviceIndex(index);
+ m_DeviceIds[index].store(value);
+}
+
+void CounterDirectory::GetDeviceObject(uint16_t index, Device* device) const
+{
+ CheckDeviceIndex(index);
+ device = m_DeviceObjects[index].load();
+}
+
+void CounterDirectory::SetDeviceObject(uint16_t index, Device* device)
+{
+ CheckDeviceIndex(index);
+ m_DeviceObjects[index].store(device);
+}
+
+// Getters and setters for counters
+void CounterDirectory::GetCounterValue(uint16_t index, uint32_t& value) const
+{
+ CheckCounterIndex(index);
+ value = m_CounterIds[index].load();
+}
+
+void CounterDirectory::SetCounterValue(uint16_t index, uint32_t value)
+{
+ CheckCounterIndex(index);
+ m_CounterIds[index].store(value);
+}
+
+void CounterDirectory::GetCounterObject(uint16_t index, Counter* counter) const
+{
+ CheckCounterIndex(index);
+ counter = m_CounterObjects[index].load();
+}
+
+void CounterDirectory::SetCounterObject(uint16_t index, Counter* counter)
+{
+ CheckCounterIndex(index);
+ m_CounterObjects[index].store(counter);
+}
+
+// Getters and setters for categories
+void CounterDirectory::GetCategoryValue(uint16_t index, uint32_t& value) const
+{
+ CheckCategoryIndex(index);
+ value = m_CategoryIds[index].load();
+}
+
+void CounterDirectory::SetCategoryValue(uint16_t index, uint32_t value)
+{
+ CheckCategoryIndex(index);
+ m_CategoryIds[index].store(value);
+}
+
+void CounterDirectory::GetCategoryObject(uint16_t index, Category* category) const
+{
+ CheckCategoryIndex(index);
+ category = m_CategoryObjects[index].load();
+}
+
+void CounterDirectory::SetCategoryObject(uint16_t index, Category* category)
+{
+ CheckCategoryIndex(index);
+ m_CategoryObjects[index].store(category);
+}
+
+} // namespace profiling
+
+} // namespace armnn