Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "PerJobCounterSelectionCommandHandler.hpp" |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 7 | #include <armnn/Exceptions.hpp> |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 8 | |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 9 | #include <fmt/format.h> |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
| 14 | namespace profiling |
| 15 | { |
| 16 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 17 | void PerJobCounterSelectionCommandHandler::operator()(const arm::pipe::Packet& packet) |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 18 | { |
| 19 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 20 | switch (currentState) |
| 21 | { |
| 22 | case ProfilingState::Uninitialised: |
| 23 | case ProfilingState::NotConnected: |
| 24 | case ProfilingState::WaitingForAck: |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 25 | throw armnn::RuntimeException(fmt::format( |
| 26 | "Per-Job Counter Selection Command Handler invoked while in an incorrect state: {}", |
| 27 | GetProfilingStateName(currentState))); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 28 | case ProfilingState::Active: |
| 29 | // Process the packet |
| 30 | if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 5u)) |
| 31 | { |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 32 | throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 5 but " |
| 33 | "received family = {}, id = {}", |
| 34 | packet.GetPacketFamily(), |
| 35 | packet.GetPacketId())); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | // Silently drop the packet |
| 39 | |
| 40 | break; |
| 41 | default: |
Jan Eilers | 156113c | 2020-09-09 19:11:16 +0100 | [diff] [blame] | 42 | throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}", |
| 43 | static_cast<int>(currentState))); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
| 47 | } // namespace profiling |
| 48 | |
| 49 | } // namespace armnn |