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