ArmNN
 22.02
ConnectionAcknowledgedCommandHandler Class Referencefinal

#include <ConnectionAcknowledgedCommandHandler.hpp>

Inheritance diagram for ConnectionAcknowledgedCommandHandler:

Public Member Functions

 ConnectionAcknowledgedCommandHandler (uint32_t familyId, uint32_t packetId, uint32_t version, ICounterDirectory &counterDirectory, ISendCounterPacket &sendCounterPacket, ISendTimelinePacket &sendTimelinePacket, ProfilingStateMachine &profilingStateMachine, IProfilingServiceStatus &profilingServiceStatus, Optional< BackendProfilingContexts > backendProfilingContexts=EmptyOptional())
 
void operator() (const arm::pipe::Packet &packet) override
 
void setTimelineEnabled (bool timelineEnabled)
 

Detailed Description

Definition at line 23 of file ConnectionAcknowledgedCommandHandler.hpp.

Constructor & Destructor Documentation

◆ ConnectionAcknowledgedCommandHandler()

ConnectionAcknowledgedCommandHandler ( uint32_t  familyId,
uint32_t  packetId,
uint32_t  version,
ICounterDirectory counterDirectory,
ISendCounterPacket sendCounterPacket,
ISendTimelinePacket sendTimelinePacket,
ProfilingStateMachine profilingStateMachine,
IProfilingServiceStatus profilingServiceStatus,
Optional< BackendProfilingContexts >  backendProfilingContexts = EmptyOptional() 
)
inline

Definition at line 30 of file ConnectionAcknowledgedCommandHandler.hpp.

References ConnectionAcknowledgedCommandHandler::operator()().

39  : CommandHandlerFunctor(familyId, packetId, version)
40  , m_CounterDirectory(counterDirectory)
41  , m_SendCounterPacket(sendCounterPacket)
42  , m_SendTimelinePacket(sendTimelinePacket)
43  , m_StateMachine(profilingStateMachine)
44  , m_ProfilingServiceStatus(profilingServiceStatus)
45  , m_BackendProfilingContext(backendProfilingContexts)
46  , m_TimelineEnabled(false)
47  {}

Member Function Documentation

◆ operator()()

void operator() ( const arm::pipe::Packet &  packet)
override

Definition at line 19 of file ConnectionAcknowledgedCommandHandler.cpp.

References armnn::profiling::Active, ProfilingStateMachine::GetCurrentState(), armnn::profiling::GetProfilingStateName(), OptionalBase::has_value(), armnn::profiling::NotConnected, IProfilingServiceStatus::NotifyProfilingServiceActive(), ISendCounterPacket::SendCounterDirectoryPacket(), ISendTimelinePacket::SendTimelineMessageDirectoryPackage(), TimelineUtilityMethods::SendWellKnownLabelsAndEventClasses(), ProfilingStateMachine::TransitionToState(), armnn::profiling::Uninitialised, OptionalReferenceSwitch< IsReference, T >::value(), and armnn::profiling::WaitingForAck.

Referenced by ConnectionAcknowledgedCommandHandler::ConnectionAcknowledgedCommandHandler().

20 {
21  ProfilingState currentState = m_StateMachine.GetCurrentState();
22  switch (currentState)
23  {
26  throw RuntimeException(fmt::format("Connection Acknowledged Command Handler invoked while in an "
27  "wrong state: {}",
28  GetProfilingStateName(currentState)));
30  // Process the packet
31  if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 1u))
32  {
33  throw armnn::InvalidArgumentException(fmt::format("Expected Packet family = 0, id = 1 but "
34  "received family = {}, id = {}",
35  packet.GetPacketFamily(),
36  packet.GetPacketId()));
37  }
38 
39  // Once a Connection Acknowledged packet has been received, move to the Active state immediately
41  // Send the counter directory packet.
42  m_SendCounterPacket.SendCounterDirectoryPacket(m_CounterDirectory);
43 
44  if (m_TimelineEnabled)
45  {
46  m_SendTimelinePacket.SendTimelineMessageDirectoryPackage();
48  }
49 
50  if (m_BackendProfilingContext.has_value())
51  {
52  for (auto backendContext : m_BackendProfilingContext.value())
53  {
54  // Enable profiling on the backend and assert that it returns true
55  if(!backendContext.second->EnableProfiling(true))
56  {
57  throw BackendProfilingException(
58  "Unable to enable profiling on Backend Id: " + backendContext.first.Get());
59  }
60  }
61  }
62 
63  // At this point signal any external processes waiting on the profiling system
64  // to come up that profiling is fully active
65  m_ProfilingServiceStatus.NotifyProfilingServiceActive();
66  break;
68  return; // NOP
69  default:
70  throw RuntimeException(fmt::format("Unknown profiling service state: {}",
71  static_cast<int>(currentState)));
72  }
73 }
bool has_value() const noexcept
Definition: Optional.hpp:53
void TransitionToState(ProfilingState newState)
static void SendWellKnownLabelsAndEventClasses(ISendTimelinePacket &timelinePacket)
virtual void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory)=0
Create and write a CounterDirectoryPacket from the parameters to the buffer.
virtual void SendTimelineMessageDirectoryPackage()=0
Create and write a TimelineMessageDirectoryPackage in the buffer.
constexpr char const * GetProfilingStateName(ProfilingState state)

◆ setTimelineEnabled()

void setTimelineEnabled ( bool  timelineEnabled)
inline

Definition at line 51 of file ConnectionAcknowledgedCommandHandler.hpp.

Referenced by ProfilingService::ResetExternalProfilingOptions().

52  {
53  m_TimelineEnabled = timelineEnabled;
54  }

The documentation for this class was generated from the following files: