Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 8 | #include "BufferManager.hpp" |
| 9 | #include "CommandHandler.hpp" |
| 10 | #include "ConnectionAcknowledgedCommandHandler.hpp" |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 11 | #include "CounterDirectory.hpp" |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 12 | #include "CounterIdMap.hpp" |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 13 | #include "ICounterRegistry.hpp" |
Matteo Martincigh | e0e6efc | 2019-10-04 17:17:42 +0100 | [diff] [blame] | 14 | #include "ICounterValues.hpp" |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 15 | #include "IProfilingService.hpp" |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 16 | #include "PeriodicCounterCapture.hpp" |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 17 | #include "PeriodicCounterSelectionCommandHandler.hpp" |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 18 | #include "PerJobCounterSelectionCommandHandler.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 19 | #include "ProfilingConnectionFactory.hpp" |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 20 | #include "ProfilingGuidGenerator.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 21 | #include "ProfilingStateMachine.hpp" |
| 22 | #include "RequestCounterDirectoryCommandHandler.hpp" |
| 23 | #include "SendCounterPacket.hpp" |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 24 | #include "SendThread.hpp" |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 25 | #include "SendTimelinePacket.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 26 | #include "TimelinePacketWriterFactory.hpp" |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 27 | #include <armnn/backends/profiling/IBackendProfilingContext.hpp> |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 28 | |
| 29 | namespace armnn |
| 30 | { |
| 31 | |
| 32 | namespace profiling |
| 33 | { |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 34 | // Static constants describing ArmNN's counter UID's |
| 35 | static const uint16_t NETWORK_LOADS = 0; |
| 36 | static const uint16_t NETWORK_UNLOADS = 1; |
| 37 | static const uint16_t REGISTERED_BACKENDS = 2; |
| 38 | static const uint16_t UNREGISTERED_BACKENDS = 3; |
| 39 | static const uint16_t INFERENCES_RUN = 4; |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 40 | static const uint16_t MAX_ARMNN_COUNTER = INFERENCES_RUN; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 41 | |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 42 | class ProfilingService : public IReadWriteCounterValues, public IProfilingService |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 43 | { |
| 44 | public: |
Narumol Prangnawarat | 85ad78c | 2019-11-18 15:34:23 +0000 | [diff] [blame] | 45 | using ExternalProfilingOptions = IRuntime::CreationOptions::ExternalProfilingOptions; |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 46 | using IProfilingConnectionFactoryPtr = std::unique_ptr<IProfilingConnectionFactory>; |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 47 | using IProfilingConnectionPtr = std::unique_ptr<IProfilingConnection>; |
| 48 | using CounterIndices = std::vector<std::atomic<uint32_t>*>; |
| 49 | using CounterValues = std::list<std::atomic<uint32_t>>; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 50 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 51 | // Getter for the singleton instance |
| 52 | static ProfilingService& Instance() |
| 53 | { |
| 54 | static ProfilingService instance; |
| 55 | return instance; |
| 56 | } |
| 57 | |
| 58 | // Resets the profiling options, optionally clears the profiling service entirely |
| 59 | void ResetExternalProfilingOptions(const ExternalProfilingOptions& options, bool resetProfilingService = false); |
Jim Flynn | 672d06e | 2019-10-15 10:18:11 +0100 | [diff] [blame] | 60 | ProfilingState ConfigureProfilingService(const ExternalProfilingOptions& options, |
| 61 | bool resetProfilingService = false); |
| 62 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 63 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 64 | // Updates the profiling service, making it transition to a new state if necessary |
| 65 | void Update(); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 66 | |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 67 | // Disconnects the profiling service from the external server |
| 68 | void Disconnect(); |
| 69 | |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 70 | // Store a profiling context returned from a backend that support profiling. |
| 71 | void AddBackendProfilingContext(const BackendId backendId, |
David Monahan | c1536d6 | 2020-02-12 15:52:35 +0000 | [diff] [blame] | 72 | std::shared_ptr<armnn::profiling::IBackendProfilingContext> profilingContext); |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 73 | |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 74 | const ICounterDirectory& GetCounterDirectory() const; |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 75 | ICounterRegistry& GetCounterRegistry(); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 76 | ProfilingState GetCurrentState() const; |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 77 | bool IsCounterRegistered(uint16_t counterUid) const override; |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 78 | uint32_t GetCounterValue(uint16_t counterUid) const override; |
Keith Davis | e394bd9 | 2019-12-02 15:12:19 +0000 | [diff] [blame] | 79 | uint16_t GetCounterCount() const override; |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 80 | // counter global/backend mapping functions |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 81 | const ICounterMappings& GetCounterMappings() const override; |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 82 | IRegisterCounterMapping& GetCounterMappingRegistry(); |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 83 | |
| 84 | // Getters for the profiling service state |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 85 | bool IsProfilingEnabled() const override; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 86 | |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 87 | CaptureData GetCaptureData() override; |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 88 | void SetCaptureData(uint32_t capturePeriod, |
| 89 | const std::vector<uint16_t>& counterIds, |
| 90 | const std::set<BackendId>& activeBackends); |
James Conroy | 2dcd3fe | 2020-02-06 18:34:52 +0000 | [diff] [blame] | 91 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 92 | // Setters for the profiling service state |
| 93 | void SetCounterValue(uint16_t counterUid, uint32_t value) override; |
| 94 | uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override; |
| 95 | uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override; |
| 96 | uint32_t IncrementCounterValue(uint16_t counterUid) override; |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 97 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 98 | // IProfilingGuidGenerator functions |
| 99 | /// Return the next random Guid in the sequence |
| 100 | ProfilingDynamicGuid NextGuid() override; |
| 101 | /// Create a ProfilingStaticGuid based on a hash of the string |
| 102 | ProfilingStaticGuid GenerateStaticId(const std::string& str) override; |
| 103 | |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame^] | 104 | std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const override; |
| 105 | |
| 106 | ISendCounterPacket& GetSendCounterPacket() override |
| 107 | { |
| 108 | return m_SendCounterPacket; |
| 109 | } |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 110 | |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 111 | /// Check if the profiling is enabled |
| 112 | bool IsEnabled() { return m_Options.m_EnableProfiling; } |
| 113 | |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 114 | private: |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 115 | // Copy/move constructors/destructors and copy/move assignment operators are deleted |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 116 | ProfilingService(const ProfilingService&) = delete; |
| 117 | ProfilingService(ProfilingService&&) = delete; |
| 118 | ProfilingService& operator=(const ProfilingService&) = delete; |
| 119 | ProfilingService& operator=(ProfilingService&&) = delete; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 120 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 121 | // Initialization/reset functions |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 122 | void Initialize(); |
| 123 | void InitializeCounterValue(uint16_t counterUid); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 124 | void Reset(); |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 125 | void Stop(); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 126 | |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 127 | // Helper function |
| 128 | void CheckCounterUid(uint16_t counterUid) const; |
| 129 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 130 | // Profiling service components |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 131 | ExternalProfilingOptions m_Options; |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 132 | CounterDirectory m_CounterDirectory; |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 133 | CounterIdMap m_CounterIdMap; |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 134 | IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory; |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 135 | IProfilingConnectionPtr m_ProfilingConnection; |
| 136 | ProfilingStateMachine m_StateMachine; |
| 137 | CounterIndices m_CounterIndex; |
| 138 | CounterValues m_CounterValues; |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 139 | CommandHandlerRegistry m_CommandHandlerRegistry; |
| 140 | PacketVersionResolver m_PacketVersionResolver; |
| 141 | CommandHandler m_CommandHandler; |
| 142 | BufferManager m_BufferManager; |
| 143 | SendCounterPacket m_SendCounterPacket; |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 144 | SendThread m_SendThread; |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 145 | SendTimelinePacket m_SendTimelinePacket; |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 146 | Holder m_Holder; |
| 147 | PeriodicCounterCapture m_PeriodicCounterCapture; |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 148 | ConnectionAcknowledgedCommandHandler m_ConnectionAcknowledgedCommandHandler; |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 149 | RequestCounterDirectoryCommandHandler m_RequestCounterDirectoryCommandHandler; |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 150 | PeriodicCounterSelectionCommandHandler m_PeriodicCounterSelectionCommandHandler; |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 151 | PerJobCounterSelectionCommandHandler m_PerJobCounterSelectionCommandHandler; |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame] | 152 | ProfilingGuidGenerator m_GuidGenerator; |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 153 | TimelinePacketWriterFactory m_TimelinePacketWriterFactory; |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 154 | std::unordered_map<BackendId, |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 155 | std::shared_ptr<armnn::profiling::IBackendProfilingContext>> m_BackendProfilingContexts; |
David Monahan | c1536d6 | 2020-02-12 15:52:35 +0000 | [diff] [blame] | 156 | uint16_t m_MaxGlobalCounterId; |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 157 | |
| 158 | protected: |
| 159 | // Default constructor/destructor kept protected for testing |
| 160 | ProfilingService() |
| 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() |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 175 | , m_SendCounterPacket(m_BufferManager) |
| 176 | , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket) |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 177 | , m_SendTimelinePacket(m_BufferManager) |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 178 | , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 179 | , m_ConnectionAcknowledgedCommandHandler(0, |
| 180 | 1, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 181 | m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(), |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 182 | m_CounterDirectory, |
| 183 | m_SendCounterPacket, |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 184 | m_SendTimelinePacket, |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 185 | m_StateMachine) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 186 | , m_RequestCounterDirectoryCommandHandler(0, |
| 187 | 3, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 188 | m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(), |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 189 | m_CounterDirectory, |
| 190 | m_SendCounterPacket, |
Matteo Martincigh | 9723d02 | 2019-11-13 10:56:41 +0000 | [diff] [blame] | 191 | m_SendTimelinePacket, |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 192 | m_StateMachine) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 193 | , m_PeriodicCounterSelectionCommandHandler(0, |
| 194 | 4, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 195 | m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 196 | m_BackendProfilingContexts, |
| 197 | m_CounterIdMap, |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 198 | m_Holder, |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 199 | MAX_ARMNN_COUNTER, |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 200 | m_PeriodicCounterCapture, |
| 201 | *this, |
| 202 | m_SendCounterPacket, |
| 203 | m_StateMachine) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 204 | , m_PerJobCounterSelectionCommandHandler(0, |
| 205 | 5, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 206 | m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(), |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 207 | m_StateMachine) |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 208 | , m_TimelinePacketWriterFactory(m_BufferManager) |
David Monahan | c1536d6 | 2020-02-12 15:52:35 +0000 | [diff] [blame] | 209 | , m_MaxGlobalCounterId(armnn::profiling::INFERENCES_RUN) |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 210 | { |
| 211 | // Register the "Connection Acknowledged" command handler |
| 212 | m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler); |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 213 | |
| 214 | // Register the "Request Counter Directory" command handler |
| 215 | m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler); |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 216 | |
| 217 | // Register the "Periodic Counter Selection" command handler |
| 218 | m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 219 | |
| 220 | // Register the "Per-Job Counter Selection" command handler |
| 221 | m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 222 | } |
janeil01 | 811ca55 | 2019-12-03 17:01:32 +0000 | [diff] [blame] | 223 | ~ProfilingService(); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 224 | |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 225 | // Protected methods for testing |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 226 | void SwapProfilingConnectionFactory(ProfilingService& instance, |
| 227 | IProfilingConnectionFactory* other, |
| 228 | IProfilingConnectionFactory*& backup) |
| 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 | } |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 236 | IProfilingConnection* GetProfilingConnection(ProfilingService& instance) |
| 237 | { |
| 238 | return instance.m_ProfilingConnection.get(); |
| 239 | } |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 240 | void TransitionToState(ProfilingService& instance, ProfilingState newState) |
| 241 | { |
| 242 | instance.m_StateMachine.TransitionToState(newState); |
| 243 | } |
Finn Williams | 09ad6f9 | 2019-12-19 17:05:18 +0000 | [diff] [blame] | 244 | bool WaitForPacketSent(ProfilingService& instance, uint32_t timeout = 1000) |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 245 | { |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 246 | return instance.m_SendThread.WaitForPacketSent(timeout); |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 247 | } |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 248 | |
| 249 | BufferManager& GetBufferManager(ProfilingService& instance) |
| 250 | { |
| 251 | return instance.m_BufferManager; |
| 252 | } |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | } // namespace profiling |
| 256 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 257 | } // namespace armnn |