aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/PerJobCounterSelectionCommandHandler.cpp
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-10-11 17:19:56 +0100
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>2019-10-14 16:06:26 +0100
commit994b5349180b41849ee616fa4f0d3b94a928f48f (patch)
tree9e204588e3d6e997b46bd83ec935a33e32941e9c /src/profiling/PerJobCounterSelectionCommandHandler.cpp
parent53e469915bc6552c0d79cb6461512c7c1168ee2d (diff)
downloadarmnn-994b5349180b41849ee616fa4f0d3b94a928f48f.tar.gz
IVGCVSW-3971 Implement the Per-Job Counter Selection command handler
* Added new PerJobCounterSelectionCommandHandler class * The new handler drops the incoming packet without altering the state of the profiling service * Added unit test Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I2b1bb803318a9e6c438391a0985893eb412e7787
Diffstat (limited to 'src/profiling/PerJobCounterSelectionCommandHandler.cpp')
-rw-r--r--src/profiling/PerJobCounterSelectionCommandHandler.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/profiling/PerJobCounterSelectionCommandHandler.cpp b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
new file mode 100644
index 0000000000..8892e1457d
--- /dev/null
+++ b/src/profiling/PerJobCounterSelectionCommandHandler.cpp
@@ -0,0 +1,48 @@
+//
+// Copyright © 2019 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "PerJobCounterSelectionCommandHandler.hpp"
+
+#include <boost/format.hpp>
+
+namespace armnn
+{
+
+namespace profiling
+{
+
+void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
+{
+ ProfilingState currentState = m_StateMachine.GetCurrentState();
+ switch (currentState)
+ {
+ case ProfilingState::Uninitialised:
+ case ProfilingState::NotConnected:
+ case ProfilingState::WaitingForAck:
+ throw RuntimeException(boost::str(boost::format("Per-Job Counter Selection Command Handler invoked while in "
+ "an wrong state: %1%")
+ % GetProfilingStateName(currentState)));
+ case ProfilingState::Active:
+ // Process the packet
+ if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u))
+ {
+ throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 5 but "
+ "received family = %1%, id = %2%")
+ % packet.GetPacketFamily()
+ % packet.GetPacketId()));
+ }
+
+ // Silently drop the packet
+
+ break;
+ default:
+ throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
+ % static_cast<int>(currentState)));
+ }
+}
+
+} // namespace profiling
+
+} // namespace armnn