Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 1 | // |
| 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 | |
| 10 | namespace armnn |
| 11 | { |
| 12 | |
| 13 | namespace profiling |
| 14 | { |
| 15 | |
| 16 | void 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 |