aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingService.cpp
diff options
context:
space:
mode:
authorFinnWilliamsArm <Finn.Williams@arm.com>2019-09-16 15:45:42 +0100
committerJim Flynn Arm <jim.flynn@arm.com>2019-09-25 05:28:48 +0000
commitf6e534a82d167403c5980e3ea3b67135ff9be78b (patch)
tree1d355ea0c6e9d2c42836c0a378f4cc10978abf6c /src/profiling/ProfilingService.cpp
parent95e73d77b9a79f7d350a39d85f07d09cd58422cc (diff)
downloadarmnn-f6e534a82d167403c5980e3ea3b67135ff9be78b.tar.gz
IVGCVSW-3411 Add the Counter Values array and accessor methods
Signed-off-by: FinnWilliamsArm <Finn.Williams@arm.com> Change-Id: I4fa2428a83b93cbe58b821344206e2f7ce9e37e7
Diffstat (limited to 'src/profiling/ProfilingService.cpp')
-rw-r--r--src/profiling/ProfilingService.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/profiling/ProfilingService.cpp b/src/profiling/ProfilingService.cpp
index 4e613838c2..9f5978888d 100644
--- a/src/profiling/ProfilingService.cpp
+++ b/src/profiling/ProfilingService.cpp
@@ -43,6 +43,11 @@ void ProfilingService::Initialise()
"counter name 2",
"counter description");
+ for (unsigned short i = 0; i < m_CounterDirectory.GetCounterCount(); ++i)
+ {
+ m_CounterIdToValue[i] = 0;
+ }
+
// For now until CounterDirectory setup is implemented, change m_State once everything initialised
m_State.TransitionToState(ProfilingState::NotConnected);
}
@@ -70,6 +75,47 @@ const ICounterDirectory& ProfilingService::GetCounterDirectory() const
return m_CounterDirectory;
}
+void ProfilingService::SetCounterValue(uint16_t counterIndex, uint32_t value)
+{
+ CheckIndexSize(counterIndex);
+ m_CounterIdToValue.at(counterIndex).store(value, std::memory_order::memory_order_relaxed);
+}
+
+void ProfilingService::GetCounterValue(uint16_t counterIndex, uint32_t& value) const
+{
+ CheckIndexSize(counterIndex);
+ value = m_CounterIdToValue.at(counterIndex).load(std::memory_order::memory_order_relaxed);
+}
+
+void ProfilingService::AddCounterValue(uint16_t counterIndex, uint32_t value)
+{
+ CheckIndexSize(counterIndex);
+ m_CounterIdToValue.at(counterIndex).fetch_add(value, std::memory_order::memory_order_relaxed);
+}
+
+void ProfilingService::SubtractCounterValue(uint16_t counterIndex, uint32_t value)
+{
+ CheckIndexSize(counterIndex);
+ m_CounterIdToValue.at(counterIndex).fetch_sub(value, std::memory_order::memory_order_relaxed);
+}
+
+void ProfilingService::IncrementCounterValue(uint16_t counterIndex)
+{
+ CheckIndexSize(counterIndex);
+ m_CounterIdToValue.at(counterIndex).operator++(std::memory_order::memory_order_relaxed);
+}
+
+void ProfilingService::DecrementCounterValue(uint16_t counterIndex)
+{
+ CheckIndexSize(counterIndex);
+ m_CounterIdToValue.at(counterIndex).operator--(std::memory_order::memory_order_relaxed);
+}
+
+uint16_t ProfilingService::GetCounterCount() const
+{
+ return m_CounterDirectory.GetCounterCount();
+}
+
ProfilingState ProfilingService::GetCurrentState() const
{
return m_State.GetCurrentState();
@@ -85,6 +131,15 @@ void ProfilingService::ResetExternalProfilingOptions(const Runtime::CreationOpti
}
m_Options = options;
}
+
+inline void ProfilingService::CheckIndexSize(uint16_t counterIndex) const
+{
+ if (counterIndex >= m_CounterDirectory.GetCounterCount())
+ {
+ throw InvalidArgumentException("Counter index is out of range");
+ }
+}
+
} // namespace profiling
} // namespace armnn \ No newline at end of file