aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/ProfilingService.hpp
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2020-03-18 10:57:30 +0000
committerSadik Armagan <sadik.armagan@arm.com>2020-03-18 15:48:21 +0000
commit3184c907b2420e6c66485529f336251b2b62aecf (patch)
treeb79190007f80da9bb9d827efb714ce13a0ffb2bb /src/profiling/ProfilingService.hpp
parente6a2ccd09060ba93203ddc5a7f79260cedf2c147 (diff)
downloadarmnn-3184c907b2420e6c66485529f336251b2b62aecf.tar.gz
IVGCVSW-4463 Change ProfilingService to a member of runtime from a singleton
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I345c39a10a4693a500aa1687d9a5cee76da791c3
Diffstat (limited to 'src/profiling/ProfilingService.hpp')
-rw-r--r--src/profiling/ProfilingService.hpp143
1 files changed, 72 insertions, 71 deletions
diff --git a/src/profiling/ProfilingService.hpp b/src/profiling/ProfilingService.hpp
index 4629c126bf..f6e409daeb 100644
--- a/src/profiling/ProfilingService.hpp
+++ b/src/profiling/ProfilingService.hpp
@@ -48,13 +48,73 @@ public:
using CounterIndices = std::vector<std::atomic<uint32_t>*>;
using CounterValues = std::list<std::atomic<uint32_t>>;
- // Getter for the singleton instance
- static ProfilingService& Instance()
+ // Default constructor/destructor kept protected for testing
+ ProfilingService()
+ : m_Options()
+ , m_CounterDirectory()
+ , m_ProfilingConnectionFactory(new ProfilingConnectionFactory())
+ , m_ProfilingConnection()
+ , m_StateMachine()
+ , m_CounterIndex()
+ , m_CounterValues()
+ , m_CommandHandlerRegistry()
+ , m_PacketVersionResolver()
+ , m_CommandHandler(1000,
+ false,
+ m_CommandHandlerRegistry,
+ m_PacketVersionResolver)
+ , m_BufferManager()
+ , m_SendCounterPacket(m_BufferManager)
+ , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket)
+ , m_SendTimelinePacket(m_BufferManager)
+ , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts)
+ , m_ConnectionAcknowledgedCommandHandler(0,
+ 1,
+ m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
+ m_CounterDirectory,
+ m_SendCounterPacket,
+ m_SendTimelinePacket,
+ m_StateMachine)
+ , m_RequestCounterDirectoryCommandHandler(0,
+ 3,
+ m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
+ m_CounterDirectory,
+ m_SendCounterPacket,
+ m_SendTimelinePacket,
+ m_StateMachine)
+ , m_PeriodicCounterSelectionCommandHandler(0,
+ 4,
+ m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
+ m_BackendProfilingContexts,
+ m_CounterIdMap,
+ m_Holder,
+ MAX_ARMNN_COUNTER,
+ m_PeriodicCounterCapture,
+ *this,
+ m_SendCounterPacket,
+ m_StateMachine)
+ , m_PerJobCounterSelectionCommandHandler(0,
+ 5,
+ m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(),
+ m_StateMachine)
+ , m_TimelinePacketWriterFactory(m_BufferManager)
+ , m_MaxGlobalCounterId(armnn::profiling::INFERENCES_RUN)
{
- static ProfilingService instance;
- return instance;
+ // Register the "Connection Acknowledged" command handler
+ m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler);
+
+ // Register the "Request Counter Directory" command handler
+ m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler);
+
+ // Register the "Periodic Counter Selection" command handler
+ m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler);
+
+ // Register the "Per-Job Counter Selection" command handler
+ m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler);
}
+ ~ProfilingService();
+
// Resets the profiling options, optionally clears the profiling service entirely
void ResetExternalProfilingOptions(const ExternalProfilingOptions& options, bool resetProfilingService = false);
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions& options,
@@ -111,8 +171,12 @@ public:
/// Check if the profiling is enabled
bool IsEnabled() { return m_Options.m_EnableProfiling; }
+ static ProfilingDynamicGuid GetNextGuid();
+
+ static ProfilingStaticGuid GetStaticId(const std::string& str);
+
private:
- // Copy/move constructors/destructors and copy/move assignment operators are deleted
+ //Copy/move constructors/destructors and copy/move assignment operators are deleted
ProfilingService(const ProfilingService&) = delete;
ProfilingService(ProfilingService&&) = delete;
ProfilingService& operator=(const ProfilingService&) = delete;
@@ -149,78 +213,15 @@ private:
RequestCounterDirectoryCommandHandler m_RequestCounterDirectoryCommandHandler;
PeriodicCounterSelectionCommandHandler m_PeriodicCounterSelectionCommandHandler;
PerJobCounterSelectionCommandHandler m_PerJobCounterSelectionCommandHandler;
- ProfilingGuidGenerator m_GuidGenerator;
+
TimelinePacketWriterFactory m_TimelinePacketWriterFactory;
std::unordered_map<BackendId,
std::shared_ptr<armnn::profiling::IBackendProfilingContext>> m_BackendProfilingContexts;
uint16_t m_MaxGlobalCounterId;
-protected:
- // Default constructor/destructor kept protected for testing
- ProfilingService()
- : m_Options()
- , m_CounterDirectory()
- , m_ProfilingConnectionFactory(new ProfilingConnectionFactory())
- , m_ProfilingConnection()
- , m_StateMachine()
- , m_CounterIndex()
- , m_CounterValues()
- , m_CommandHandlerRegistry()
- , m_PacketVersionResolver()
- , m_CommandHandler(1000,
- false,
- m_CommandHandlerRegistry,
- m_PacketVersionResolver)
- , m_BufferManager()
- , m_SendCounterPacket(m_BufferManager)
- , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket)
- , m_SendTimelinePacket(m_BufferManager)
- , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts)
- , m_ConnectionAcknowledgedCommandHandler(0,
- 1,
- m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(),
- m_CounterDirectory,
- m_SendCounterPacket,
- m_SendTimelinePacket,
- m_StateMachine)
- , m_RequestCounterDirectoryCommandHandler(0,
- 3,
- m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(),
- m_CounterDirectory,
- m_SendCounterPacket,
- m_SendTimelinePacket,
- m_StateMachine)
- , m_PeriodicCounterSelectionCommandHandler(0,
- 4,
- m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
- m_BackendProfilingContexts,
- m_CounterIdMap,
- m_Holder,
- MAX_ARMNN_COUNTER,
- m_PeriodicCounterCapture,
- *this,
- m_SendCounterPacket,
- m_StateMachine)
- , m_PerJobCounterSelectionCommandHandler(0,
- 5,
- m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(),
- m_StateMachine)
- , m_TimelinePacketWriterFactory(m_BufferManager)
- , m_MaxGlobalCounterId(armnn::profiling::INFERENCES_RUN)
- {
- // Register the "Connection Acknowledged" command handler
- m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler);
-
- // Register the "Request Counter Directory" command handler
- m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler);
+ static ProfilingGuidGenerator m_GuidGenerator;
- // Register the "Periodic Counter Selection" command handler
- m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler);
-
- // Register the "Per-Job Counter Selection" command handler
- m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler);
- }
- ~ProfilingService();
+protected:
// Protected methods for testing
void SwapProfilingConnectionFactory(ProfilingService& instance,