Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "DeactivateTimelineReportingCommandHandler.hpp" |
| 7 | |
| 8 | #include <armnn/Exceptions.hpp> |
| 9 | #include <boost/format.hpp> |
| 10 | |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | |
| 15 | namespace profiling |
| 16 | { |
| 17 | |
| 18 | void DeactivateTimelineReportingCommandHandler::operator()(const Packet& packet) |
| 19 | { |
| 20 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 21 | |
| 22 | switch ( currentState ) |
| 23 | { |
| 24 | case ProfilingState::Uninitialised: |
| 25 | case ProfilingState::NotConnected: |
| 26 | case ProfilingState::WaitingForAck: |
| 27 | throw RuntimeException(boost::str( |
| 28 | boost::format("Deactivate Timeline Reporting Command Handler invoked while in a wrong state: %1%") |
| 29 | % GetProfilingStateName(currentState))); |
| 30 | case ProfilingState::Active: |
| 31 | if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 7u)) |
| 32 | { |
| 33 | throw armnn::Exception(std::string("Expected Packet family = 0, id = 7 but received family =") |
| 34 | + std::to_string(packet.GetPacketFamily()) |
| 35 | +" id = " + std::to_string(packet.GetPacketId())); |
| 36 | } |
| 37 | |
| 38 | m_TimelineReporting.store(false); |
| 39 | |
| 40 | // Notify Backends |
| 41 | m_BackendNotifier.NotifyBackendsForTimelineReporting(); |
| 42 | |
| 43 | break; |
| 44 | default: |
| 45 | throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%") |
| 46 | % static_cast<int>(currentState))); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | } // namespace profiling |
| 51 | |
| 52 | } // namespace armnn |
| 53 | |