blob: 8892e1457d491b558e6a0f72e25ebcc75205b955 [file] [log] [blame]
Matteo Martincigh994b5342019-10-11 17:19:56 +01001//
2// Copyright © 2019 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "PerJobCounterSelectionCommandHandler.hpp"
7
8#include <boost/format.hpp>
9
10namespace armnn
11{
12
13namespace profiling
14{
15
16void PerJobCounterSelectionCommandHandler::operator()(const Packet& packet)
17{
18 ProfilingState currentState = m_StateMachine.GetCurrentState();
19 switch (currentState)
20 {
21 case ProfilingState::Uninitialised:
22 case ProfilingState::NotConnected:
23 case ProfilingState::WaitingForAck:
24 throw RuntimeException(boost::str(boost::format("Per-Job Counter Selection Command Handler invoked while in "
25 "an wrong state: %1%")
26 % GetProfilingStateName(currentState)));
27 case ProfilingState::Active:
28 // Process the packet
29 if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u))
30 {
31 throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 5 but "
32 "received family = %1%, id = %2%")
33 % packet.GetPacketFamily()
34 % packet.GetPacketId()));
35 }
36
37 // Silently drop the packet
38
39 break;
40 default:
41 throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
42 % static_cast<int>(currentState)));
43 }
44}
45
46} // namespace profiling
47
48} // namespace armnn