ArmNN  NotReleased
ProfilingService Class Reference

#include <ProfilingService.hpp>

Inheritance diagram for ProfilingService:
IReadWriteCounterValues IProfilingService IReadCounterValues IWriteCounterValues IProfilingGuidGenerator ProfilingServiceRuntimeHelper SwapProfilingConnectionFactoryHelper

Public Types

using ExternalProfilingOptions = IRuntime::CreationOptions::ExternalProfilingOptions
 
using IProfilingConnectionFactoryPtr = std::unique_ptr< IProfilingConnectionFactory >
 
using IProfilingConnectionPtr = std::unique_ptr< IProfilingConnection >
 
using CounterIndices = std::vector< std::atomic< uint32_t > * >
 
using CounterValues = std::list< std::atomic< uint32_t > >
 

Public Member Functions

void ResetExternalProfilingOptions (const ExternalProfilingOptions &options, bool resetProfilingService=false)
 
ProfilingState ConfigureProfilingService (const ExternalProfilingOptions &options, bool resetProfilingService=false)
 
void Update ()
 
void Disconnect ()
 
void AddBackendProfilingContext (const BackendId backendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext > profilingContext)
 
const ICounterDirectoryGetCounterDirectory () const
 
ICounterRegistryGetCounterRegistry ()
 
ProfilingState GetCurrentState () const
 
bool IsCounterRegistered (uint16_t counterUid) const override
 
uint32_t GetCounterValue (uint16_t counterUid) const override
 
uint16_t GetCounterCount () const override
 
const ICounterMappingsGetCounterMappings () const override
 
IRegisterCounterMappingGetCounterMappingRegistry ()
 
bool IsProfilingEnabled () const override
 
CaptureData GetCaptureData () override
 
void SetCaptureData (uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< BackendId > &activeBackends)
 
void SetCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t AddCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t SubtractCounterValue (uint16_t counterUid, uint32_t value) override
 
uint32_t IncrementCounterValue (uint16_t counterUid) override
 
ProfilingDynamicGuid NextGuid () override
 Return the next random Guid in the sequence. More...
 
ProfilingStaticGuid GenerateStaticId (const std::string &str) override
 Create a ProfilingStaticGuid based on a hash of the string. More...
 
std::unique_ptr< ISendTimelinePacketGetSendTimelinePacket () const override
 
ISendCounterPacketGetSendCounterPacket () override
 
bool IsEnabled ()
 Check if the profiling is enabled. More...
 
- Public Member Functions inherited from IReadWriteCounterValues
virtual ~IReadWriteCounterValues ()
 
- Public Member Functions inherited from IReadCounterValues
virtual ~IReadCounterValues ()
 
- Public Member Functions inherited from IWriteCounterValues
virtual ~IWriteCounterValues ()
 
- Public Member Functions inherited from IProfilingService
virtual ~IProfilingService ()
 
- Public Member Functions inherited from IProfilingGuidGenerator
virtual ~IProfilingGuidGenerator ()
 

Static Public Member Functions

static ProfilingServiceInstance ()
 

Protected Member Functions

 ProfilingService ()
 
 ~ProfilingService ()
 
void SwapProfilingConnectionFactory (ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)
 
IProfilingConnectionGetProfilingConnection (ProfilingService &instance)
 
void TransitionToState (ProfilingService &instance, ProfilingState newState)
 
bool WaitForPacketSent (ProfilingService &instance, uint32_t timeout=1000)
 
BufferManagerGetBufferManager (ProfilingService &instance)
 

Detailed Description

Definition at line 42 of file ProfilingService.hpp.

Member Typedef Documentation

◆ CounterIndices

using CounterIndices = std::vector<std::atomic<uint32_t>*>

Definition at line 48 of file ProfilingService.hpp.

◆ CounterValues

using CounterValues = std::list<std::atomic<uint32_t> >

Definition at line 49 of file ProfilingService.hpp.

◆ ExternalProfilingOptions

◆ IProfilingConnectionFactoryPtr

Definition at line 46 of file ProfilingService.hpp.

◆ IProfilingConnectionPtr

Definition at line 47 of file ProfilingService.hpp.

Constructor & Destructor Documentation

◆ ProfilingService()

ProfilingService ( )
inlineprotected

Definition at line 160 of file ProfilingService.hpp.

References CommandHandlerRegistry::RegisterFunctor(), and ProfilingService::~ProfilingService().

Referenced by ProfilingService::IsEnabled().

161  : m_Options()
162  , m_CounterDirectory()
163  , m_ProfilingConnectionFactory(new ProfilingConnectionFactory())
164  , m_ProfilingConnection()
165  , m_StateMachine()
166  , m_CounterIndex()
167  , m_CounterValues()
168  , m_CommandHandlerRegistry()
169  , m_PacketVersionResolver()
170  , m_CommandHandler(1000,
171  false,
172  m_CommandHandlerRegistry,
173  m_PacketVersionResolver)
174  , m_BufferManager()
175  , m_SendCounterPacket(m_BufferManager)
176  , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket)
177  , m_SendTimelinePacket(m_BufferManager)
178  , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts)
179  , m_ConnectionAcknowledgedCommandHandler(0,
180  1,
181  m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
182  m_CounterDirectory,
183  m_SendCounterPacket,
184  m_SendTimelinePacket,
185  m_StateMachine)
186  , m_RequestCounterDirectoryCommandHandler(0,
187  3,
188  m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
189  m_CounterDirectory,
190  m_SendCounterPacket,
191  m_SendTimelinePacket,
192  m_StateMachine)
193  , m_PeriodicCounterSelectionCommandHandler(0,
194  4,
195  m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
196  m_BackendProfilingContexts,
197  m_CounterIdMap,
198  m_Holder,
199  MAX_ARMNN_COUNTER,
200  m_PeriodicCounterCapture,
201  *this,
202  m_SendCounterPacket,
203  m_StateMachine)
204  , m_PerJobCounterSelectionCommandHandler(0,
205  5,
206  m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(),
207  m_StateMachine)
208  , m_TimelinePacketWriterFactory(m_BufferManager)
209  , m_MaxGlobalCounterId(armnn::profiling::INFERENCES_RUN)
210  {
211  // Register the "Connection Acknowledged" command handler
212  m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler);
213 
214  // Register the "Request Counter Directory" command handler
215  m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler);
216 
217  // Register the "Periodic Counter Selection" command handler
218  m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler);
219 
220  // Register the "Per-Job Counter Selection" command handler
221  m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler);
222  }
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)

◆ ~ProfilingService()

~ProfilingService ( )
protected

Definition at line 448 of file ProfilingService.cpp.

Referenced by ProfilingService::ProfilingService().

449 {
450  Stop();
451 }

Member Function Documentation

◆ AddBackendProfilingContext()

void AddBackendProfilingContext ( const BackendId  backendId,
std::shared_ptr< armnn::profiling::IBackendProfilingContext profilingContext 
)

Definition at line 185 of file ProfilingService.cpp.

Referenced by ProfilingService::Instance(), and Runtime::Runtime().

187 {
188  BOOST_ASSERT(profilingContext != nullptr);
189  // Register the backend counters
190  m_MaxGlobalCounterId = profilingContext->RegisterCounters(m_MaxGlobalCounterId);
191  m_BackendProfilingContexts.emplace(backendId, std::move(profilingContext));
192 }

◆ AddCounterValue()

uint32_t AddCounterValue ( uint16_t  counterUid,
uint32_t  value 
)
overridevirtual

Implements IWriteCounterValues.

Definition at line 256 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

257 {
258  CheckCounterUid(counterUid);
259  std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid);
260  BOOST_ASSERT(counterValuePtr);
261  return counterValuePtr->fetch_add(value, std::memory_order::memory_order_relaxed);
262 }

◆ ConfigureProfilingService()

ProfilingState ConfigureProfilingService ( const ExternalProfilingOptions options,
bool  resetProfilingService = false 
)

Definition at line 38 of file ProfilingService.cpp.

References ProfilingStateMachine::GetCurrentState(), IRuntime::CreationOptions::ExternalProfilingOptions::m_EnableProfiling, armnn::profiling::NotConnected, ProfilingService::ResetExternalProfilingOptions(), armnn::profiling::Uninitialised, ProfilingService::Update(), and armnn::profiling::WaitingForAck.

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::Instance(), Runtime::Runtime(), and VerifyPostOptimisationStructureTestImpl().

41 {
42  ResetExternalProfilingOptions(options, resetProfilingService);
43  ProfilingState currentState = m_StateMachine.GetCurrentState();
44  if (options.m_EnableProfiling)
45  {
46  switch (currentState)
47  {
49  Update(); // should transition to NotConnected
50  Update(); // will either stay in NotConnected because there is no server
51  // or will enter WaitingForAck.
52  currentState = m_StateMachine.GetCurrentState();
53  if (currentState == ProfilingState::WaitingForAck)
54  {
55  Update(); // poke it again to send out the metadata packet
56  }
57  currentState = m_StateMachine.GetCurrentState();
58  return currentState;
60  Update(); // will either stay in NotConnected because there is no server
61  // or will enter WaitingForAck
62  currentState = m_StateMachine.GetCurrentState();
63  if (currentState == ProfilingState::WaitingForAck)
64  {
65  Update(); // poke it again to send out the metadata packet
66  }
67  currentState = m_StateMachine.GetCurrentState();
68  return currentState;
69  default:
70  return currentState;
71  }
72  }
73  else
74  {
75  // Make sure profiling is shutdown
76  switch (currentState)
77  {
80  return currentState;
81  default:
82  Stop();
83  return m_StateMachine.GetCurrentState();
84  }
85  }
86 }
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ Disconnect()

void Disconnect ( )

Definition at line 164 of file ProfilingService.cpp.

References armnn::profiling::Active, ProfilingStateMachine::GetCurrentState(), armnn::profiling::NotConnected, armnn::profiling::Uninitialised, and armnn::profiling::WaitingForAck.

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

165 {
166  ProfilingState currentState = m_StateMachine.GetCurrentState();
167  switch (currentState)
168  {
172  return; // NOP
174  // Stop the command thread (if running)
175  Stop();
176 
177  break;
178  default:
179  throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1")
180  % static_cast<int>(currentState)));
181  }
182 }

◆ GenerateStaticId()

ProfilingStaticGuid GenerateStaticId ( const std::string &  str)
overridevirtual

Create a ProfilingStaticGuid based on a hash of the string.

Implements IProfilingGuidGenerator.

Definition at line 285 of file ProfilingService.cpp.

References ProfilingGuidGenerator::GenerateStaticId().

Referenced by BOOST_AUTO_TEST_CASE(), TimelineUtilityMethods::DeclareLabel(), and ProfilingService::Instance().

286 {
287  return m_GuidGenerator.GenerateStaticId(str);
288 }
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.

◆ GetBufferManager()

BufferManager& GetBufferManager ( ProfilingService instance)
inlineprotected

Definition at line 249 of file ProfilingService.hpp.

250  {
251  return instance.m_BufferManager;
252  }

◆ GetCaptureData()

CaptureData GetCaptureData ( )
overridevirtual

Implements IProfilingService.

Definition at line 236 of file ProfilingService.cpp.

References Holder::GetCaptureData().

Referenced by ProfilingService::Instance().

237 {
238  return m_Holder.GetCaptureData();
239 }
CaptureData GetCaptureData() const
Definition: Holder.cpp:54

◆ GetCounterCount()

uint16_t GetCounterCount ( ) const
overridevirtual

Implements IReadCounterValues.

Definition at line 208 of file ProfilingService.cpp.

References CounterDirectory::GetCounterCount().

Referenced by ProfilingService::Instance().

209 {
210  return m_CounterDirectory.GetCounterCount();
211 }
uint16_t GetCounterCount() const override

◆ GetCounterDirectory()

const ICounterDirectory & GetCounterDirectory ( ) const

Definition at line 193 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

194 {
195  return m_CounterDirectory;
196 }

◆ GetCounterMappingRegistry()

IRegisterCounterMapping & GetCounterMappingRegistry ( )

Definition at line 231 of file ProfilingService.cpp.

Referenced by ProfilingService::Instance(), and RegisterBackendCounters::RegisterCounter().

232 {
233  return m_CounterIdMap;
234 }

◆ GetCounterMappings()

const ICounterMappings & GetCounterMappings ( ) const
overridevirtual

Implements IProfilingService.

Definition at line 226 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BackendProfiling::GetActiveCounters(), and ProfilingService::Instance().

227 {
228  return m_CounterIdMap;
229 }

◆ GetCounterRegistry()

ICounterRegistry & GetCounterRegistry ( )

Definition at line 198 of file ProfilingService.cpp.

Referenced by ProfilingService::Instance().

199 {
200  return m_CounterDirectory;
201 }

◆ GetCounterValue()

uint32_t GetCounterValue ( uint16_t  counterUid) const
overridevirtual

Implements IReadCounterValues.

Definition at line 218 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::Instance(), and while().

219 {
220  CheckCounterUid(counterUid);
221  std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid);
222  BOOST_ASSERT(counterValuePtr);
223  return counterValuePtr->load(std::memory_order::memory_order_relaxed);
224 }

◆ GetCurrentState()

ProfilingState GetCurrentState ( ) const

Definition at line 203 of file ProfilingService.cpp.

References ProfilingStateMachine::GetCurrentState().

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::Instance(), and while().

204 {
205  return m_StateMachine.GetCurrentState();
206 }

◆ GetProfilingConnection()

IProfilingConnection* GetProfilingConnection ( ProfilingService instance)
inlineprotected

Definition at line 236 of file ProfilingService.hpp.

237  {
238  return instance.m_ProfilingConnection.get();
239  }

◆ GetSendCounterPacket()

ISendCounterPacket& GetSendCounterPacket ( )
inlineoverridevirtual

Implements IProfilingService.

Definition at line 106 of file ProfilingService.hpp.

107  {
108  return m_SendCounterPacket;
109  }

◆ GetSendTimelinePacket()

◆ IncrementCounterValue()

uint32_t IncrementCounterValue ( uint16_t  counterUid)
overridevirtual

Implements IWriteCounterValues.

Definition at line 272 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BackendRegistry::Deregister(), LoadedNetwork::EnqueueWorkload(), ProfilingService::Instance(), Runtime::LoadNetwork(), BackendRegistry::Register(), Runtime::UnloadNetwork(), and while().

273 {
274  CheckCounterUid(counterUid);
275  std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid);
276  BOOST_ASSERT(counterValuePtr);
277  return counterValuePtr->operator++(std::memory_order::memory_order_relaxed);
278 }

◆ Instance()

static ProfilingService& Instance ( )
inlinestatic

Definition at line 52 of file ProfilingService.hpp.

References ProfilingService::AddBackendProfilingContext(), ProfilingService::AddCounterValue(), ProfilingService::ConfigureProfilingService(), ProfilingService::Disconnect(), ProfilingService::GenerateStaticId(), ProfilingService::GetCaptureData(), ProfilingService::GetCounterCount(), ProfilingService::GetCounterDirectory(), ProfilingService::GetCounterMappingRegistry(), ProfilingService::GetCounterMappings(), ProfilingService::GetCounterRegistry(), ProfilingService::GetCounterValue(), ProfilingService::GetCurrentState(), ProfilingService::GetSendTimelinePacket(), ProfilingService::IncrementCounterValue(), ProfilingService::IsCounterRegistered(), ProfilingService::IsProfilingEnabled(), ProfilingService::NextGuid(), options, ProfilingService::ResetExternalProfilingOptions(), ProfilingService::SetCaptureData(), ProfilingService::SetCounterValue(), ProfilingService::SubtractCounterValue(), and ProfilingService::Update().

Referenced by BOOST_AUTO_TEST_CASE(), TimelineUtilityMethods::CreateConnectionRelationship(), TimelineUtilityMethods::CreateNamedTypedChildEntity(), TimelineUtilityMethods::CreateNamedTypedEntity(), TimelineUtilityMethods::CreateRelationship(), TimelineUtilityMethods::DeclareLabel(), BackendRegistry::Deregister(), LoadedNetwork::EnqueueWorkload(), SwapProfilingConnectionFactoryHelper::ForceTransitionToState(), BackendProfiling::GetActiveCounters(), SwapProfilingConnectionFactoryHelper::GetMockProfilingConnection(), ProfilingServiceRuntimeHelper::GetProfilingBufferManager(), TimelineUtilityMethods::GetTimelineUtils(), Runtime::LoadNetwork(), TimelineUtilityMethods::MarkEntityWithLabel(), TimelineUtilityMethods::MarkEntityWithType(), TimelineUtilityMethods::RecordEvent(), TimelineUtilityMethods::RecordWorkloadInferenceAndStartOfLifeEvent(), BackendRegistry::Register(), RegisterBackendCounters::RegisterCounter(), Runtime::Runtime(), SwapProfilingConnectionFactoryHelper::SwapProfilingConnectionFactoryHelper(), Runtime::UnloadNetwork(), VerifyPostOptimisationStructureTestImpl(), SwapProfilingConnectionFactoryHelper::WaitForPacketsSent(), and SwapProfilingConnectionFactoryHelper::~SwapProfilingConnectionFactoryHelper().

53  {
54  static ProfilingService instance;
55  return instance;
56  }

◆ IsCounterRegistered()

bool IsCounterRegistered ( uint16_t  counterUid) const
overridevirtual

Implements IReadCounterValues.

Definition at line 213 of file ProfilingService.cpp.

Referenced by ProfilingService::GetSendTimelinePacket(), ProfilingService::Instance(), and while().

214 {
215  return counterUid < m_CounterIndex.size();
216 }

◆ IsEnabled()

bool IsEnabled ( )
inline

◆ IsProfilingEnabled()

bool IsProfilingEnabled ( ) const
overridevirtual

◆ NextGuid()

◆ ResetExternalProfilingOptions()

void ResetExternalProfilingOptions ( const ExternalProfilingOptions options,
bool  resetProfilingService = false 
)

Definition at line 19 of file ProfilingService.cpp.

References options.

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::ConfigureProfilingService(), ProfilingService::Instance(), and while().

21 {
22  // Update the profiling options
23  m_Options = options;
24 
25  // Check if the profiling service needs to be reset
26  if (resetProfilingService)
27  {
28  // Reset the profiling service
29  Reset();
30  }
31 }
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ SetCaptureData()

void SetCaptureData ( uint32_t  capturePeriod,
const std::vector< uint16_t > &  counterIds,
const std::set< BackendId > &  activeBackends 
)

Definition at line 241 of file ProfilingService.cpp.

References Holder::SetCaptureData().

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

244 {
245  m_Holder.SetCaptureData(capturePeriod, counterIds, activeBackends);
246 }
void SetCaptureData(uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< armnn::BackendId > &activeBackends)
Definition: Holder.cpp:74

◆ SetCounterValue()

void SetCounterValue ( uint16_t  counterUid,
uint32_t  value 
)
overridevirtual

Implements IWriteCounterValues.

Definition at line 248 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

249 {
250  CheckCounterUid(counterUid);
251  std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid);
252  BOOST_ASSERT(counterValuePtr);
253  counterValuePtr->store(value, std::memory_order::memory_order_relaxed);
254 }

◆ SubtractCounterValue()

uint32_t SubtractCounterValue ( uint16_t  counterUid,
uint32_t  value 
)
overridevirtual

Implements IWriteCounterValues.

Definition at line 264 of file ProfilingService.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ProfilingService::Instance().

265 {
266  CheckCounterUid(counterUid);
267  std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid);
268  BOOST_ASSERT(counterValuePtr);
269  return counterValuePtr->fetch_sub(value, std::memory_order::memory_order_relaxed);
270 }

◆ SwapProfilingConnectionFactory()

void SwapProfilingConnectionFactory ( ProfilingService instance,
IProfilingConnectionFactory other,
IProfilingConnectionFactory *&  backup 
)
inlineprotected

Definition at line 226 of file ProfilingService.hpp.

229  {
230  BOOST_ASSERT(instance.m_ProfilingConnectionFactory);
231  BOOST_ASSERT(other);
232 
233  backup = instance.m_ProfilingConnectionFactory.release();
234  instance.m_ProfilingConnectionFactory.reset(other);
235  }

◆ TransitionToState()

void TransitionToState ( ProfilingService instance,
ProfilingState  newState 
)
inlineprotected

Definition at line 240 of file ProfilingService.hpp.

References ProfilingStateMachine::TransitionToState().

241  {
242  instance.m_StateMachine.TransitionToState(newState);
243  }

◆ Update()

void Update ( )

Definition at line 88 of file ProfilingService.cpp.

References armnn::profiling::Active, ARMNN_LOG, ProfilingStateMachine::GetCurrentState(), IRuntime::CreationOptions::ExternalProfilingOptions::m_EnableProfiling, armnn::profiling::NotConnected, SendThread::Start(), CommandHandler::Start(), SendThread::Stop(), CommandHandler::Stop(), PeriodicCounterCapture::Stop(), ProfilingStateMachine::TransitionToState(), armnn::profiling::Uninitialised, armnn::profiling::WaitingForAck, armnn::warning, and Exception::what().

Referenced by BOOST_AUTO_TEST_CASE(), ProfilingService::ConfigureProfilingService(), and ProfilingService::Instance().

89 {
90  if (!m_Options.m_EnableProfiling)
91  {
92  // Don't run if profiling is disabled
93  return;
94  }
95 
96  ProfilingState currentState = m_StateMachine.GetCurrentState();
97  switch (currentState)
98  {
100 
101  // Initialize the profiling service
102  Initialize();
103 
104  // Move to the next state
106  break;
108  // Stop the command thread (if running)
109  m_CommandHandler.Stop();
110 
111  // Stop the send thread (if running)
112  m_SendThread.Stop(false);
113 
114  // Stop the periodic counter capture thread (if running)
115  m_PeriodicCounterCapture.Stop();
116 
117  // Reset any existing profiling connection
118  m_ProfilingConnection.reset();
119 
120  try
121  {
122  // Setup the profiling connection
123  BOOST_ASSERT(m_ProfilingConnectionFactory);
124  m_ProfilingConnection = m_ProfilingConnectionFactory->GetProfilingConnection(m_Options);
125  }
126  catch (const Exception& e)
127  {
128  ARMNN_LOG(warning) << "An error has occurred when creating the profiling connection: "
129  << e.what();
130  }
131 
132  // Move to the next state
133  m_StateMachine.TransitionToState(m_ProfilingConnection
134  ? ProfilingState::WaitingForAck // Profiling connection obtained, wait for ack
135  : ProfilingState::NotConnected); // Profiling connection failed, stay in the
136  // "NotConnected" state
137  break;
139  BOOST_ASSERT(m_ProfilingConnection);
140 
141  // Start the command thread
142  m_CommandHandler.Start(*m_ProfilingConnection);
143 
144  // Start the send thread, while in "WaitingForAck" state it'll send out a "Stream MetaData" packet waiting for
145  // a valid "Connection Acknowledged" packet confirming the connection
146  m_SendThread.Start(*m_ProfilingConnection);
147 
148  // The connection acknowledged command handler will automatically transition the state to "Active" once a
149  // valid "Connection Acknowledged" packet has been received
150 
151  break;
153 
154  // The period counter capture thread is started by the Periodic Counter Selection command handler upon
155  // request by an external profiling service
156 
157  break;
158  default:
159  throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1")
160  % static_cast<int>(currentState)));
161  }
162 }
void Start(IProfilingConnection &profilingConnection) override
Start the thread.
Definition: SendThread.cpp:52
void TransitionToState(ProfilingState newState)
bool Initialize()
Performs any required one-time setup.
void Stop(bool rethrowSendThreadExceptions=true) override
Stop the thread.
Definition: SendThread.cpp:82
#define ARMNN_LOG(severity)
Definition: Logging.hpp:163
void Start(IProfilingConnection &profilingConnection)

◆ WaitForPacketSent()

bool WaitForPacketSent ( ProfilingService instance,
uint32_t  timeout = 1000 
)
inlineprotected

Definition at line 244 of file ProfilingService.hpp.

References SendThread::WaitForPacketSent().

Referenced by SwapProfilingConnectionFactoryHelper::WaitForPacketsSent().

245  {
246  return instance.m_SendThread.WaitForPacketSent(timeout);
247  }

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