blob: d9aa7fda45439f2e4317005d346cf1fa09ef2c94 [file] [log] [blame]
Keith Davis33ed2212020-03-30 10:43:41 +01001//
Jim Flynnbbfe6032020-07-20 16:57:44 +01002// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
Keith Davis33ed2212020-03-30 10:43:41 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "DeactivateTimelineReportingCommandHandler.hpp"
7
8#include <armnn/Exceptions.hpp>
Jan Eilers156113c2020-09-09 19:11:16 +01009#include <fmt/format.h>
Keith Davis33ed2212020-03-30 10:43:41 +010010
11
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000012namespace arm
Keith Davis33ed2212020-03-30 10:43:41 +010013{
14
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000015namespace pipe
Keith Davis33ed2212020-03-30 10:43:41 +010016{
17
Jim Flynnbbfe6032020-07-20 16:57:44 +010018void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet)
Keith Davis33ed2212020-03-30 10:43:41 +010019{
20 ProfilingState currentState = m_StateMachine.GetCurrentState();
21
22 switch ( currentState )
23 {
24 case ProfilingState::Uninitialised:
25 case ProfilingState::NotConnected:
26 case ProfilingState::WaitingForAck:
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000027 throw armnn::RuntimeException(fmt::format(
Jan Eilers156113c2020-09-09 19:11:16 +010028 "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}",
29 GetProfilingStateName(currentState)));
Keith Davis33ed2212020-03-30 10:43:41 +010030 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:
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000045 throw armnn::RuntimeException(fmt::format("Unknown profiling service state: {}",
Jan Eilers156113c2020-09-09 19:11:16 +010046 static_cast<int>(currentState)));
Keith Davis33ed2212020-03-30 10:43:41 +010047 }
48}
49
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000050} // namespace pipe
Keith Davis33ed2212020-03-30 10:43:41 +010051
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000052} // namespace arm
Keith Davis33ed2212020-03-30 10:43:41 +010053