Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 8 | #include "ActivateTimelineReportingCommandHandler.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 9 | #include "BufferManager.hpp" |
| 10 | #include "CommandHandler.hpp" |
| 11 | #include "ConnectionAcknowledgedCommandHandler.hpp" |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 12 | #include "CounterDirectory.hpp" |
Jim Flynn | 8e0c7a6 | 2020-01-30 14:10:55 +0000 | [diff] [blame] | 13 | #include "CounterIdMap.hpp" |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 14 | #include "DeactivateTimelineReportingCommandHandler.hpp" |
Jim Flynn | 9789702 | 2020-02-02 12:52:59 +0000 | [diff] [blame] | 15 | #include "ICounterRegistry.hpp" |
Matteo Martincigh | e0e6efc | 2019-10-04 17:17:42 +0100 | [diff] [blame] | 16 | #include "ICounterValues.hpp" |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 17 | #include <armnn/profiling/ILocalPacketHandler.hpp> |
Jim Flynn | 6406355 | 2020-02-14 10:18:08 +0000 | [diff] [blame] | 18 | #include "IProfilingService.hpp" |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 19 | #include "IReportStructure.hpp" |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 20 | #include "PeriodicCounterCapture.hpp" |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 21 | #include "PeriodicCounterSelectionCommandHandler.hpp" |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 22 | #include "PerJobCounterSelectionCommandHandler.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 23 | #include "ProfilingConnectionFactory.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 24 | #include "ProfilingStateMachine.hpp" |
| 25 | #include "RequestCounterDirectoryCommandHandler.hpp" |
| 26 | #include "SendCounterPacket.hpp" |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 27 | #include "SendThread.hpp" |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 28 | #include "SendTimelinePacket.hpp" |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 29 | #include "TimelinePacketWriterFactory.hpp" |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 30 | #include "INotifyBackends.hpp" |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 31 | #include <armnn/profiling/ArmNNProfiling.hpp> |
Colm Donelan | 1aff393 | 2020-02-05 17:48:59 +0000 | [diff] [blame] | 32 | #include <armnn/backends/profiling/IBackendProfilingContext.hpp> |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 33 | |
Nikhil Raj | 5b1bcc9 | 2021-06-08 12:31:50 +0100 | [diff] [blame] | 34 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 35 | #include <list> |
| 36 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 37 | namespace arm |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 38 | { |
| 39 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 40 | namespace pipe |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 41 | { |
| 42 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 43 | class ProfilingService : public IProfilingService, public INotifyBackends |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 44 | { |
| 45 | public: |
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>>; |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame] | 50 | using BackendProfilingContext = std::unordered_map<std::string, |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 51 | std::shared_ptr<IBackendProfilingContext>>; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 52 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 53 | ProfilingService(uint16_t maxGlobalCounterId, |
| 54 | IInitialiseProfilingService& initialiser, |
| 55 | armnn::Optional<IReportStructure&> reportStructure = armnn::EmptyOptional()) |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 56 | : m_Options() |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 57 | , m_TimelineReporting(false) |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 58 | , m_CounterDirectory() |
| 59 | , m_ProfilingConnectionFactory(new ProfilingConnectionFactory()) |
| 60 | , m_ProfilingConnection() |
| 61 | , m_StateMachine() |
| 62 | , m_CounterIndex() |
| 63 | , m_CounterValues() |
| 64 | , m_CommandHandlerRegistry() |
| 65 | , m_PacketVersionResolver() |
| 66 | , m_CommandHandler(1000, |
| 67 | false, |
| 68 | m_CommandHandlerRegistry, |
| 69 | m_PacketVersionResolver) |
| 70 | , m_BufferManager() |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 71 | , m_SendCounterPacket(m_BufferManager) |
| 72 | , m_SendThread(m_StateMachine, m_BufferManager, m_SendCounterPacket) |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 73 | , m_SendTimelinePacket(m_BufferManager) |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 74 | , m_PeriodicCounterCapture(m_Holder, m_SendCounterPacket, *this, m_CounterIdMap, m_BackendProfilingContexts) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 75 | , m_ConnectionAcknowledgedCommandHandler(0, |
| 76 | 1, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 77 | m_PacketVersionResolver.ResolvePacketVersion(0, 1).GetEncodedValue(), |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 78 | m_CounterDirectory, |
| 79 | m_SendCounterPacket, |
Matteo Martincigh | cdfb941 | 2019-11-08 11:23:06 +0000 | [diff] [blame] | 80 | m_SendTimelinePacket, |
Finn Williams | fe5a24b | 2020-04-09 16:05:28 +0100 | [diff] [blame] | 81 | m_StateMachine, |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 82 | *this, |
Finn Williams | fe5a24b | 2020-04-09 16:05:28 +0100 | [diff] [blame] | 83 | m_BackendProfilingContexts) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 84 | , m_RequestCounterDirectoryCommandHandler(0, |
| 85 | 3, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 86 | m_PacketVersionResolver.ResolvePacketVersion(0, 3).GetEncodedValue(), |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 87 | m_CounterDirectory, |
| 88 | m_SendCounterPacket, |
Matteo Martincigh | 9723d02 | 2019-11-13 10:56:41 +0000 | [diff] [blame] | 89 | m_SendTimelinePacket, |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 90 | m_StateMachine) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 91 | , m_PeriodicCounterSelectionCommandHandler(0, |
| 92 | 4, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 93 | m_PacketVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(), |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 94 | m_BackendProfilingContexts, |
| 95 | m_CounterIdMap, |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 96 | m_Holder, |
Finn Williams | 032bc74 | 2020-02-12 11:02:34 +0000 | [diff] [blame] | 97 | MAX_ARMNN_COUNTER, |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 98 | m_PeriodicCounterCapture, |
| 99 | *this, |
| 100 | m_SendCounterPacket, |
| 101 | m_StateMachine) |
Jim Flynn | 397043f | 2019-10-17 17:37:10 +0100 | [diff] [blame] | 102 | , m_PerJobCounterSelectionCommandHandler(0, |
| 103 | 5, |
Jim Flynn | ed25e0e | 2019-10-18 13:21:43 +0100 | [diff] [blame] | 104 | m_PacketVersionResolver.ResolvePacketVersion(0, 5).GetEncodedValue(), |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 105 | m_StateMachine) |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 106 | , m_ActivateTimelineReportingCommandHandler(0, |
| 107 | 6, |
| 108 | m_PacketVersionResolver.ResolvePacketVersion(0, 6) |
| 109 | .GetEncodedValue(), |
| 110 | m_SendTimelinePacket, |
| 111 | m_StateMachine, |
| 112 | reportStructure, |
| 113 | m_TimelineReporting, |
| 114 | *this) |
| 115 | , m_DeactivateTimelineReportingCommandHandler(0, |
| 116 | 7, |
| 117 | m_PacketVersionResolver.ResolvePacketVersion(0, 7) |
| 118 | .GetEncodedValue(), |
| 119 | m_TimelineReporting, |
| 120 | m_StateMachine, |
| 121 | *this) |
Jim Flynn | 8b20065 | 2019-10-24 18:07:44 +0100 | [diff] [blame] | 122 | , m_TimelinePacketWriterFactory(m_BufferManager) |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 123 | , m_MaxGlobalCounterId(maxGlobalCounterId) |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 124 | , m_ServiceActive(false) |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 125 | , m_Initialiser(initialiser) |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 126 | { |
| 127 | // Register the "Connection Acknowledged" command handler |
| 128 | m_CommandHandlerRegistry.RegisterFunctor(&m_ConnectionAcknowledgedCommandHandler); |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 129 | |
| 130 | // Register the "Request Counter Directory" command handler |
| 131 | m_CommandHandlerRegistry.RegisterFunctor(&m_RequestCounterDirectoryCommandHandler); |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 132 | |
| 133 | // Register the "Periodic Counter Selection" command handler |
| 134 | m_CommandHandlerRegistry.RegisterFunctor(&m_PeriodicCounterSelectionCommandHandler); |
Matteo Martincigh | 994b534 | 2019-10-11 17:19:56 +0100 | [diff] [blame] | 135 | |
| 136 | // Register the "Per-Job Counter Selection" command handler |
| 137 | m_CommandHandlerRegistry.RegisterFunctor(&m_PerJobCounterSelectionCommandHandler); |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 138 | |
| 139 | m_CommandHandlerRegistry.RegisterFunctor(&m_ActivateTimelineReportingCommandHandler); |
| 140 | |
| 141 | m_CommandHandlerRegistry.RegisterFunctor(&m_DeactivateTimelineReportingCommandHandler); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 142 | } |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 143 | |
janeil01 | 811ca55 | 2019-12-03 17:01:32 +0000 | [diff] [blame] | 144 | ~ProfilingService(); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 145 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 146 | // Resets the profiling options, optionally clears the profiling service entirely |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 147 | void ResetExternalProfilingOptions(const ProfilingOptions& options, |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 148 | bool resetProfilingService = false) override; |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 149 | ProfilingState ConfigureProfilingService(const ProfilingOptions& options, |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 150 | bool resetProfilingService = false) override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 151 | |
| 152 | |
| 153 | // Updates the profiling service, making it transition to a new state if necessary |
| 154 | void Update(); |
| 155 | |
| 156 | // Disconnects the profiling service from the external server |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 157 | void Disconnect() override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 158 | |
| 159 | // Store a profiling context returned from a backend that support profiling. |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame] | 160 | void AddBackendProfilingContext(const std::string& backendId, |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 161 | std::shared_ptr<IBackendProfilingContext> profilingContext) override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 162 | |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 163 | // Enable the recording of timeline events and entities |
| 164 | void NotifyBackendsForTimelineReporting() override; |
| 165 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 166 | const ICounterDirectory& GetCounterDirectory() const; |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 167 | ICounterRegistry& GetCounterRegistry() override; |
| 168 | ProfilingState GetCurrentState() const override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 169 | bool IsCounterRegistered(uint16_t counterUid) const override; |
Finn Williams | f3fcf32 | 2020-05-11 14:38:02 +0100 | [diff] [blame] | 170 | uint32_t GetAbsoluteCounterValue(uint16_t counterUid) const override; |
| 171 | uint32_t GetDeltaCounterValue(uint16_t counterUid) override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 172 | uint16_t GetCounterCount() const override; |
| 173 | // counter global/backend mapping functions |
| 174 | const ICounterMappings& GetCounterMappings() const override; |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 175 | IRegisterCounterMapping& GetCounterMappingRegistry() override; |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 176 | bool IsCategoryRegistered(const std::string& categoryName) const override; |
| 177 | bool IsCounterRegistered(const std::string& counterName) const override; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 178 | |
| 179 | // Getters for the profiling service state |
| 180 | bool IsProfilingEnabled() const override; |
| 181 | |
| 182 | CaptureData GetCaptureData() override; |
| 183 | void SetCaptureData(uint32_t capturePeriod, |
| 184 | const std::vector<uint16_t>& counterIds, |
Cathal Corbett | 6f07372 | 2022-03-04 12:11:09 +0000 | [diff] [blame] | 185 | const std::set<std::string>& activeBackends); |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 186 | |
| 187 | // Setters for the profiling service state |
| 188 | void SetCounterValue(uint16_t counterUid, uint32_t value) override; |
| 189 | uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override; |
| 190 | uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override; |
| 191 | uint32_t IncrementCounterValue(uint16_t counterUid) override; |
| 192 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 193 | void InitializeCounterValue(uint16_t counterUid) override; |
| 194 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 195 | std::unique_ptr<ISendTimelinePacket> GetSendTimelinePacket() const override; |
| 196 | |
| 197 | ISendCounterPacket& GetSendCounterPacket() override |
| 198 | { |
| 199 | return m_SendCounterPacket; |
| 200 | } |
| 201 | |
Jim Flynn | af94772 | 2022-03-02 11:04:47 +0000 | [diff] [blame] | 202 | bool IsTimelineReportingEnabled() const override |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 203 | { |
| 204 | return m_TimelineReporting; |
| 205 | } |
| 206 | |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 207 | void AddLocalPacketHandler(ILocalPacketHandlerSharedPtr localPacketHandler); |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 208 | |
| 209 | void NotifyProfilingServiceActive() override; // IProfilingServiceStatus |
| 210 | void WaitForProfilingServiceActivation(unsigned int timeout) override; // IProfilingServiceStatus |
| 211 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 212 | private: |
| 213 | //Copy/move constructors/destructors and copy/move assignment operators are deleted |
| 214 | ProfilingService(const ProfilingService&) = delete; |
| 215 | ProfilingService(ProfilingService&&) = delete; |
| 216 | ProfilingService& operator=(const ProfilingService&) = delete; |
| 217 | ProfilingService& operator=(ProfilingService&&) = delete; |
| 218 | |
| 219 | // Initialization/reset functions |
| 220 | void Initialize(); |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 221 | void Reset(); |
| 222 | void Stop(); |
| 223 | |
| 224 | // Helper function |
| 225 | void CheckCounterUid(uint16_t counterUid) const; |
| 226 | |
| 227 | // Profiling service components |
Jim Flynn | 4c9ed1d | 2022-01-23 23:57:20 +0000 | [diff] [blame] | 228 | ProfilingOptions m_Options; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 229 | std::atomic<bool> m_TimelineReporting; |
| 230 | CounterDirectory m_CounterDirectory; |
| 231 | CounterIdMap m_CounterIdMap; |
| 232 | IProfilingConnectionFactoryPtr m_ProfilingConnectionFactory; |
| 233 | IProfilingConnectionPtr m_ProfilingConnection; |
| 234 | ProfilingStateMachine m_StateMachine; |
| 235 | CounterIndices m_CounterIndex; |
| 236 | CounterValues m_CounterValues; |
| 237 | arm::pipe::CommandHandlerRegistry m_CommandHandlerRegistry; |
| 238 | arm::pipe::PacketVersionResolver m_PacketVersionResolver; |
| 239 | CommandHandler m_CommandHandler; |
| 240 | BufferManager m_BufferManager; |
| 241 | SendCounterPacket m_SendCounterPacket; |
| 242 | SendThread m_SendThread; |
| 243 | SendTimelinePacket m_SendTimelinePacket; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 244 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 245 | Holder m_Holder; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 246 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 247 | PeriodicCounterCapture m_PeriodicCounterCapture; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 248 | |
| 249 | ConnectionAcknowledgedCommandHandler m_ConnectionAcknowledgedCommandHandler; |
| 250 | RequestCounterDirectoryCommandHandler m_RequestCounterDirectoryCommandHandler; |
| 251 | PeriodicCounterSelectionCommandHandler m_PeriodicCounterSelectionCommandHandler; |
| 252 | PerJobCounterSelectionCommandHandler m_PerJobCounterSelectionCommandHandler; |
| 253 | ActivateTimelineReportingCommandHandler m_ActivateTimelineReportingCommandHandler; |
| 254 | DeactivateTimelineReportingCommandHandler m_DeactivateTimelineReportingCommandHandler; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 255 | |
| 256 | TimelinePacketWriterFactory m_TimelinePacketWriterFactory; |
Keith Davis | 33ed221 | 2020-03-30 10:43:41 +0100 | [diff] [blame] | 257 | BackendProfilingContext m_BackendProfilingContexts; |
| 258 | uint16_t m_MaxGlobalCounterId; |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 259 | |
Jim Flynn | 6398a98 | 2020-05-27 17:05:21 +0100 | [diff] [blame] | 260 | // Signalling to let external actors know when service is active or not |
| 261 | std::mutex m_ServiceActiveMutex; |
| 262 | std::condition_variable m_ServiceActiveConditionVariable; |
| 263 | bool m_ServiceActive; |
| 264 | |
Jim Flynn | 3443025 | 2022-03-04 15:03:58 +0000 | [diff] [blame] | 265 | IInitialiseProfilingService& m_Initialiser; |
| 266 | |
Sadik Armagan | 3184c90 | 2020-03-18 10:57:30 +0000 | [diff] [blame] | 267 | protected: |
| 268 | |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 269 | // Protected methods for testing |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 270 | void SwapProfilingConnectionFactory(ProfilingService& instance, |
| 271 | IProfilingConnectionFactory* other, |
| 272 | IProfilingConnectionFactory*& backup) |
| 273 | { |
Narumol Prangnawarat | ac2770a | 2020-04-01 16:51:23 +0100 | [diff] [blame] | 274 | ARMNN_ASSERT(instance.m_ProfilingConnectionFactory); |
| 275 | ARMNN_ASSERT(other); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 276 | |
| 277 | backup = instance.m_ProfilingConnectionFactory.release(); |
| 278 | instance.m_ProfilingConnectionFactory.reset(other); |
| 279 | } |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 280 | IProfilingConnection* GetProfilingConnection(ProfilingService& instance) |
| 281 | { |
| 282 | return instance.m_ProfilingConnection.get(); |
| 283 | } |
Matteo Martincigh | 8efc500 | 2019-10-10 14:30:29 +0100 | [diff] [blame] | 284 | void TransitionToState(ProfilingService& instance, ProfilingState newState) |
| 285 | { |
| 286 | instance.m_StateMachine.TransitionToState(newState); |
| 287 | } |
Finn Williams | 09ad6f9 | 2019-12-19 17:05:18 +0000 | [diff] [blame] | 288 | bool WaitForPacketSent(ProfilingService& instance, uint32_t timeout = 1000) |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 289 | { |
Sadik Armagan | 3896b47 | 2020-02-10 12:24:15 +0000 | [diff] [blame] | 290 | return instance.m_SendThread.WaitForPacketSent(timeout); |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 291 | } |
Narumol Prangnawarat | df31cfe | 2019-11-22 11:26:06 +0000 | [diff] [blame] | 292 | |
| 293 | BufferManager& GetBufferManager(ProfilingService& instance) |
| 294 | { |
| 295 | return instance.m_BufferManager; |
| 296 | } |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 297 | }; |
| 298 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 299 | } // namespace pipe |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 300 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 301 | } // namespace arm |