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