aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
diff options
context:
space:
mode:
authorFerran Balaguer <ferran.balaguer@arm.com>2019-08-28 16:57:18 +0100
committerFerran Balaguer <ferran.balaguer@arm.com>2019-09-13 09:50:20 +0100
commit1b941728caa2cd7e2148d0872a6b7dda4947b641 (patch)
tree0820663b520604256554f55e4f4bf07ebc6a3fa3 /src/profiling/PeriodicCounterSelectionCommandHandler.cpp
parent9bff14458f9950a5d31b9523c62c0bbf79a65fcf (diff)
downloadarmnn-1b941728caa2cd7e2148d0872a6b7dda4947b641.tar.gz
IVGCVSW-3436 Create the Periodic Counter Selection Command Handler
Change-Id: Ia6fe19db5aebe82bb00dcbab17e16633befda0a5 Signed-off-by: Ferran Balaguer <ferran.balaguer@arm.com>
Diffstat (limited to 'src/profiling/PeriodicCounterSelectionCommandHandler.cpp')
-rw-r--r--src/profiling/PeriodicCounterSelectionCommandHandler.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/profiling/PeriodicCounterSelectionCommandHandler.cpp b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
new file mode 100644
index 0000000000..9be37fcfd2
--- /dev/null
+++ b/src/profiling/PeriodicCounterSelectionCommandHandler.cpp
@@ -0,0 +1,70 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "PeriodicCounterSelectionCommandHandler.hpp"
+#include "ProfilingUtils.hpp"
+
+#include <boost/numeric/conversion/cast.hpp>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+using namespace std;
+using boost::numeric_cast;
+
+void PeriodicCounterSelectionCommandHandler::ParseData(const Packet& packet, CaptureData& captureData)
+{
+ std::vector<uint16_t> counterIds;
+ uint32_t sizeOfUint32 = numeric_cast<uint32_t>(sizeof(uint32_t));
+ uint32_t sizeOfUint16 = numeric_cast<uint32_t>(sizeof(uint16_t));
+ uint32_t offset = 0;
+
+ if (packet.GetLength() > 0)
+ {
+ if (packet.GetLength() >= 4)
+ {
+ captureData.SetCapturePeriod(ReadUint32(reinterpret_cast<const unsigned char*>(packet.GetData()), offset));
+
+ unsigned int counters = (packet.GetLength() - 4) / 2;
+
+ if (counters > 0)
+ {
+ counterIds.reserve(counters);
+ offset += sizeOfUint32;
+ for(unsigned int pos = 0; pos < counters; ++pos)
+ {
+ counterIds.emplace_back(ReadUint16(reinterpret_cast<const unsigned char*>(packet.GetData()),
+ offset));
+ offset += sizeOfUint16;
+ }
+ }
+
+ captureData.SetCounterIds(counterIds);
+ }
+ }
+}
+
+void PeriodicCounterSelectionCommandHandler::operator()(const Packet& packet)
+{
+ CaptureData captureData;
+
+ ParseData(packet, captureData);
+
+ vector<uint16_t> counterIds = captureData.GetCounterIds();
+
+ m_CaptureDataHolder.SetCaptureData(captureData.GetCapturePeriod(), counterIds);
+
+ m_CaptureThread.Start();
+
+ // Write packet to Counter Stream Buffer
+ m_SendCounterPacket.SendPeriodicCounterSelectionPacket(captureData.GetCapturePeriod(), captureData.GetCounterIds());
+}
+
+} // namespace profiling
+
+} // namespace armnn \ No newline at end of file