ArmNN
 20.05
ConnectionAcknowledgedCommandHandler Class Referencefinal

#include <ConnectionAcknowledgedCommandHandler.hpp>

Inheritance diagram for ConnectionAcknowledgedCommandHandler:
CommandHandlerFunctor

Public Member Functions

 ConnectionAcknowledgedCommandHandler (uint32_t familyId, uint32_t packetId, uint32_t version, ICounterDirectory &counterDirectory, ISendCounterPacket &sendCounterPacket, ISendTimelinePacket &sendTimelinePacket, ProfilingStateMachine &profilingStateMachine, Optional< BackendProfilingContexts > backendProfilingContexts=EmptyOptional())
 
void operator() (const Packet &packet) override
 
void setTimelineEnabled (bool timelineEnabled)
 
- Public Member Functions inherited from CommandHandlerFunctor
 CommandHandlerFunctor (uint32_t familyId, uint32_t packetId, uint32_t version)
 
uint32_t GetFamilyId () const
 
uint32_t GetPacketId () const
 
uint32_t GetVersion () const
 
virtual ~CommandHandlerFunctor ()
 

Detailed Description

Definition at line 21 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,
Optional< BackendProfilingContexts >  backendProfilingContexts = EmptyOptional() 
)
inline

Definition at line 28 of file ConnectionAcknowledgedCommandHandler.hpp.

References ConnectionAcknowledgedCommandHandler::operator()().

36  : CommandHandlerFunctor(familyId, packetId, version)
37  , m_CounterDirectory(counterDirectory)
38  , m_SendCounterPacket(sendCounterPacket)
39  , m_SendTimelinePacket(sendTimelinePacket)
40  , m_StateMachine(profilingStateMachine)
41  , m_BackendProfilingContext(backendProfilingContexts)
42  {}
CommandHandlerFunctor(uint32_t familyId, uint32_t packetId, uint32_t version)

Member Function Documentation

◆ operator()()

void operator() ( const Packet &  packet)
overridevirtual

Implements CommandHandlerFunctor.

Definition at line 19 of file ConnectionAcknowledgedCommandHandler.cpp.

References armnn::profiling::Active, ProfilingStateMachine::GetCurrentState(), armnn::profiling::GetProfilingStateName(), OptionalBase::has_value(), armnn::profiling::NotConnected, 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(boost::str(boost::format("Connection Acknowledged Command Handler invoked while in an "
27  "wrong state: %1%")
28  % GetProfilingStateName(currentState)));
30  // Process the packet
31  if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 1u))
32  {
33  throw armnn::InvalidArgumentException(boost::str(boost::format("Expected Packet family = 0, id = 1 but "
34  "received family = %1%, id = %2%")
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  break;
65  return; // NOP
66  default:
67  throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1%")
68  % static_cast<int>(currentState)));
69  }
70 }
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 46 of file ConnectionAcknowledgedCommandHandler.hpp.

Referenced by ProfilingService::ResetExternalProfilingOptions().

47  {
48  m_TimelineEnabled = timelineEnabled;
49  }

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