42 static const uint16_t NETWORK_LOADS = 0;
43 static const uint16_t NETWORK_UNLOADS = 1;
44 static const uint16_t REGISTERED_BACKENDS = 2;
45 static const uint16_t UNREGISTERED_BACKENDS = 3;
46 static const uint16_t INFERENCES_RUN = 4;
47 static const uint16_t MAX_ARMNN_COUNTER = INFERENCES_RUN;
58 std::shared_ptr<armnn::profiling::IBackendProfilingContext>>;
62 , m_TimelineReporting(
false)
63 , m_CounterDirectory()
65 , m_ProfilingConnection()
69 , m_CommandHandlerRegistry()
70 , m_PacketVersionResolver()
71 , m_CommandHandler(1000,
73 m_CommandHandlerRegistry,
74 m_PacketVersionResolver)
76 , m_SendCounterPacket(m_BufferManager)
77 , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket)
78 , m_SendTimelinePacket(m_BufferManager)
79 , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts)
80 , m_ConnectionAcknowledgedCommandHandler(0,
82 m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
88 m_BackendProfilingContexts)
89 , m_RequestCounterDirectoryCommandHandler(0,
91 m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
96 , m_PeriodicCounterSelectionCommandHandler(0,
98 m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
99 m_BackendProfilingContexts,
103 m_PeriodicCounterCapture,
107 , m_PerJobCounterSelectionCommandHandler(0,
109 m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(),
111 , m_ActivateTimelineReportingCommandHandler(0,
113 m_PacketVersionResolver.ResolvePacketVersion(0, 6)
115 m_SendTimelinePacket,
120 , m_DeactivateTimelineReportingCommandHandler(0,
122 m_PacketVersionResolver.ResolvePacketVersion(0, 7)
127 , m_TimelinePacketWriterFactory(m_BufferManager)
128 , m_MaxGlobalCounterId(
armnn::profiling::INFERENCES_RUN)
129 , m_ServiceActive(
false)
132 m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler);
135 m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler);
138 m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler);
141 m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler);
143 m_CommandHandlerRegistry.RegisterFunctor(&m_ActivateTimelineReportingCommandHandler);
145 m_CommandHandlerRegistry.RegisterFunctor(&m_DeactivateTimelineReportingCommandHandler);
153 bool resetProfilingService =
false);
164 std::shared_ptr<armnn::profiling::IBackendProfilingContext> profilingContext);
185 const std::vector<uint16_t>& counterIds,
186 const std::set<BackendId>& activeBackends);
190 uint32_t
AddCounterValue(uint16_t counterUid, uint32_t value)
override;
205 return m_SendCounterPacket;
216 return m_TimelineReporting;
233 void InitializeCounterValue(uint16_t counterUid);
238 void CheckCounterUid(uint16_t counterUid)
const;
242 std::atomic<bool> m_TimelineReporting;
250 arm::pipe::CommandHandlerRegistry m_CommandHandlerRegistry;
251 arm::pipe::PacketVersionResolver m_PacketVersionResolver;
271 uint16_t m_MaxGlobalCounterId;
276 std::mutex m_ServiceActiveMutex;
277 std::condition_variable m_ServiceActiveConditionVariable;
278 bool m_ServiceActive;
290 backup = instance.m_ProfilingConnectionFactory.release();
291 instance.m_ProfilingConnectionFactory.reset(other);
295 return instance.m_ProfilingConnection.get();
308 return instance.m_BufferManager;
bool IsCounterRegistered(uint16_t counterUid) const override
void WaitForProfilingServiceActivation(unsigned int timeout) override
std::shared_ptr< ILocalPacketHandler > ILocalPacketHandlerSharedPtr
uint32_t GetAbsoluteCounterValue(uint16_t counterUid) const override
std::list< std::atomic< uint32_t > > CounterValues
std::unordered_map< BackendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext > > BackendProfilingContext
ProfilingState GetCurrentState() const
ICounterRegistry & GetCounterRegistry()
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
void NotifyBackendsForTimelineReporting() override
void NotifyProfilingServiceActive() override
Copyright (c) 2021 ARM Limited and Contributors.
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
uint32_t IncrementCounterValue(uint16_t counterUid) override
std::unique_ptr< IProfilingConnection > IProfilingConnectionPtr
void AddLocalPacketHandler(ILocalPacketHandlerSharedPtr localPacketHandler)
void ResetGuidGenerator()
bool WaitForPacketSent(ProfilingService &instance, uint32_t timeout=1000)
bool WaitForPacketSent(uint32_t timeout)
uint32_t GetDeltaCounterValue(uint16_t counterUid) override
uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override
std::vector< std::atomic< uint32_t > * > CounterIndices
void SwapProfilingConnectionFactory(ProfilingService &instance, IProfilingConnectionFactory *other, IProfilingConnectionFactory *&backup)
static ProfilingStaticGuid GetStaticId(const std::string &str)
void SetCaptureData(uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< BackendId > &activeBackends)
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override
const ICounterMappings & GetCounterMappings() const override
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
#define ARMNN_ASSERT(COND)
uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override
IRegisterCounterMapping & GetCounterMappingRegistry()
bool IsTimelineReportingEnabled()
BufferManager & GetBufferManager(ProfilingService &instance)
ProfilingService(Optional< IReportStructure &> reportStructure=EmptyOptional())
void SetCounterValue(uint16_t counterUid, uint32_t value) override
CaptureData GetCaptureData() override
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
bool IsProfilingEnabled() const override
IProfilingConnection * GetProfilingConnection(ProfilingService &instance)
static ProfilingDynamicGuid GetNextGuid()
void TransitionToState(ProfilingState newState)
std::unique_ptr< IProfilingConnectionFactory > IProfilingConnectionFactoryPtr
void TransitionToState(ProfilingService &instance, ProfilingState newState)
ISendCounterPacket & GetSendCounterPacket() override
void AddBackendProfilingContext(const BackendId backendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext > profilingContext)
const ICounterDirectory & GetCounterDirectory() const
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions &options, bool resetProfilingService=false)
uint16_t GetCounterCount() const override
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.