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 | #include "ProfilingService.hpp" |
| 7 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 8 | #include <boost/log/trivial.hpp> |
| 9 | #include <boost/format.hpp> |
| 10 | |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 11 | namespace armnn |
| 12 | { |
| 13 | |
| 14 | namespace profiling |
| 15 | { |
| 16 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 17 | void ProfilingService::ResetExternalProfilingOptions(const ExternalProfilingOptions& options, |
| 18 | bool resetProfilingService) |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 19 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 20 | // Update the profiling options |
| 21 | m_Options = options; |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 22 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 23 | // Check if the profiling service needs to be reset |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 24 | if (resetProfilingService) |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 25 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 26 | // Reset the profiling service |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 27 | Reset(); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 28 | } |
| 29 | } |
| 30 | |
Jim Flynn | 672d06e | 2019-10-15 10:18:11 +0100 | [diff] [blame] | 31 | ProfilingState ProfilingService::ConfigureProfilingService( |
| 32 | const ExternalProfilingOptions& options, |
| 33 | bool resetProfilingService) |
| 34 | { |
| 35 | ResetExternalProfilingOptions(options, resetProfilingService); |
| 36 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 37 | if (options.m_EnableProfiling) |
| 38 | { |
| 39 | switch (currentState) |
| 40 | { |
| 41 | case ProfilingState::Uninitialised: |
| 42 | Update(); // should transition to NotConnected |
| 43 | Update(); // will either stay in NotConnected because there is no server |
| 44 | // or will enter WaitingForAck. |
| 45 | currentState = m_StateMachine.GetCurrentState(); |
| 46 | if (currentState == ProfilingState::WaitingForAck) |
| 47 | { |
| 48 | Update(); // poke it again to send out the metadata packet |
| 49 | } |
| 50 | currentState = m_StateMachine.GetCurrentState(); |
| 51 | return currentState; |
| 52 | case ProfilingState::NotConnected: |
| 53 | Update(); // will either stay in NotConnected because there is no server |
| 54 | // or will enter WaitingForAck |
| 55 | currentState = m_StateMachine.GetCurrentState(); |
| 56 | if (currentState == ProfilingState::WaitingForAck) |
| 57 | { |
| 58 | Update(); // poke it again to send out the metadata packet |
| 59 | } |
| 60 | currentState = m_StateMachine.GetCurrentState(); |
| 61 | return currentState; |
| 62 | default: |
| 63 | return currentState; |
| 64 | } |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | // Make sure profiling is shutdown |
| 69 | switch (currentState) |
| 70 | { |
| 71 | case ProfilingState::Uninitialised: |
| 72 | case ProfilingState::NotConnected: |
| 73 | return currentState; |
| 74 | default: |
| 75 | Stop(); |
| 76 | return m_StateMachine.GetCurrentState(); |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 81 | void ProfilingService::Update() |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 82 | { |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 83 | if (!m_Options.m_EnableProfiling) |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 84 | { |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 85 | // Don't run if profiling is disabled |
| 86 | return; |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 87 | } |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 88 | |
| 89 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 90 | switch (currentState) |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 91 | { |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 92 | case ProfilingState::Uninitialised: |
| 93 | // Initialize the profiling service |
| 94 | Initialize(); |
| 95 | |
| 96 | // Move to the next state |
| 97 | m_StateMachine.TransitionToState(ProfilingState::NotConnected); |
| 98 | break; |
| 99 | case ProfilingState::NotConnected: |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 100 | // Stop the command thread (if running) |
| 101 | m_CommandHandler.Stop(); |
| 102 | |
| 103 | // Stop the send thread (if running) |
| 104 | m_SendCounterPacket.Stop(false); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 105 | |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 106 | // Stop the periodic counter capture thread (if running) |
| 107 | m_PeriodicCounterCapture.Stop(); |
| 108 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 109 | // Reset any existing profiling connection |
| 110 | m_ProfilingConnection.reset(); |
| 111 | |
Sadik Armagan | bd9e2c5 | 2019-09-26 23:13:31 +0100 | [diff] [blame] | 112 | try |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 113 | { |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 114 | // Setup the profiling connection |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 115 | BOOST_ASSERT(m_ProfilingConnectionFactory); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 116 | m_ProfilingConnection = m_ProfilingConnectionFactory->GetProfilingConnection(m_Options); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 117 | } |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 118 | catch (const Exception& e) |
Sadik Armagan | bd9e2c5 | 2019-09-26 23:13:31 +0100 | [diff] [blame] | 119 | { |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 120 | BOOST_LOG_TRIVIAL(warning) << "An error has occurred when creating the profiling connection: " |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 121 | << e.what() << std::endl; |
Sadik Armagan | bd9e2c5 | 2019-09-26 23:13:31 +0100 | [diff] [blame] | 122 | } |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 123 | |
| 124 | // Move to the next state |
| 125 | m_StateMachine.TransitionToState(m_ProfilingConnection |
| 126 | ? ProfilingState::WaitingForAck // Profiling connection obtained, wait for ack |
| 127 | : ProfilingState::NotConnected); // Profiling connection failed, stay in the |
| 128 | // "NotConnected" state |
| 129 | break; |
| 130 | case ProfilingState::WaitingForAck: |
| 131 | BOOST_ASSERT(m_ProfilingConnection); |
| 132 | |
| 133 | // Start the command thread |
| 134 | m_CommandHandler.Start(*m_ProfilingConnection); |
| 135 | |
| 136 | // Start the send thread, while in "WaitingForAck" state it'll send out a "Stream MetaData" packet waiting for |
| 137 | // a valid "Connection Acknowledged" packet confirming the connection |
| 138 | m_SendCounterPacket.Start(*m_ProfilingConnection); |
| 139 | |
| 140 | // The connection acknowledged command handler will automatically transition the state to "Active" once a |
| 141 | // valid "Connection Acknowledged" packet has been received |
| 142 | |
| 143 | break; |
| 144 | case ProfilingState::Active: |
| 145 | |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 146 | // The period counter capture thread is started by the Periodic Counter Selection command handler upon |
| 147 | // request by an external profiling service |
| 148 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 149 | break; |
| 150 | default: |
| 151 | throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1") |
| 152 | % static_cast<int>(currentState))); |
Sadik Armagan | bd9e2c5 | 2019-09-26 23:13:31 +0100 | [diff] [blame] | 153 | } |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 154 | } |
| 155 | |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 156 | void ProfilingService::Disconnect() |
| 157 | { |
| 158 | ProfilingState currentState = m_StateMachine.GetCurrentState(); |
| 159 | switch (currentState) |
| 160 | { |
| 161 | case ProfilingState::Uninitialised: |
| 162 | case ProfilingState::NotConnected: |
| 163 | case ProfilingState::WaitingForAck: |
| 164 | return; // NOP |
| 165 | case ProfilingState::Active: |
| 166 | // Stop the command thread (if running) |
| 167 | Stop(); |
| 168 | |
| 169 | break; |
| 170 | default: |
| 171 | throw RuntimeException(boost::str(boost::format("Unknown profiling service state: %1") |
| 172 | % static_cast<int>(currentState))); |
| 173 | } |
| 174 | } |
| 175 | |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 176 | const ICounterDirectory& ProfilingService::GetCounterDirectory() const |
| 177 | { |
| 178 | return m_CounterDirectory; |
| 179 | } |
| 180 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 181 | ProfilingState ProfilingService::GetCurrentState() const |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 182 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 183 | return m_StateMachine.GetCurrentState(); |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | uint16_t ProfilingService::GetCounterCount() const |
| 187 | { |
| 188 | return m_CounterDirectory.GetCounterCount(); |
| 189 | } |
| 190 | |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 191 | bool ProfilingService::IsCounterRegistered(uint16_t counterUid) const |
| 192 | { |
| 193 | return counterUid < m_CounterIndex.size(); |
| 194 | } |
| 195 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 196 | uint32_t ProfilingService::GetCounterValue(uint16_t counterUid) const |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 197 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 198 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 199 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 200 | BOOST_ASSERT(counterValuePtr); |
| 201 | return counterValuePtr->load(std::memory_order::memory_order_relaxed); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 202 | } |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 203 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 204 | void ProfilingService::SetCounterValue(uint16_t counterUid, uint32_t value) |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 205 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 206 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 207 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 208 | BOOST_ASSERT(counterValuePtr); |
| 209 | counterValuePtr->store(value, std::memory_order::memory_order_relaxed); |
| 210 | } |
| 211 | |
| 212 | uint32_t ProfilingService::AddCounterValue(uint16_t counterUid, uint32_t value) |
| 213 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 214 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 215 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 216 | BOOST_ASSERT(counterValuePtr); |
| 217 | return counterValuePtr->fetch_add(value, std::memory_order::memory_order_relaxed); |
| 218 | } |
| 219 | |
| 220 | uint32_t ProfilingService::SubtractCounterValue(uint16_t counterUid, uint32_t value) |
| 221 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 222 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 223 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 224 | BOOST_ASSERT(counterValuePtr); |
| 225 | return counterValuePtr->fetch_sub(value, std::memory_order::memory_order_relaxed); |
| 226 | } |
| 227 | |
| 228 | uint32_t ProfilingService::IncrementCounterValue(uint16_t counterUid) |
| 229 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 230 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 231 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 232 | BOOST_ASSERT(counterValuePtr); |
| 233 | return counterValuePtr->operator++(std::memory_order::memory_order_relaxed); |
| 234 | } |
| 235 | |
| 236 | uint32_t ProfilingService::DecrementCounterValue(uint16_t counterUid) |
| 237 | { |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 238 | CheckCounterUid(counterUid); |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 239 | std::atomic<uint32_t>* counterValuePtr = m_CounterIndex.at(counterUid); |
| 240 | BOOST_ASSERT(counterValuePtr); |
| 241 | return counterValuePtr->operator--(std::memory_order::memory_order_relaxed); |
| 242 | } |
| 243 | |
Jim Flynn | 00f3aaf | 2019-10-24 11:58:06 +0100 | [diff] [blame^] | 244 | ProfilingDynamicGuid ProfilingService::NextGuid() |
| 245 | { |
| 246 | return m_GuidGenerator.NextGuid(); |
| 247 | } |
| 248 | |
| 249 | ProfilingStaticGuid ProfilingService::GenerateStaticId(const std::string& str) |
| 250 | { |
| 251 | return m_GuidGenerator.GenerateStaticId(str); |
| 252 | } |
| 253 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 254 | void ProfilingService::Initialize() |
| 255 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 256 | // Register a category for the basic runtime counters |
| 257 | if (!m_CounterDirectory.IsCategoryRegistered("ArmNN_Runtime")) |
| 258 | { |
| 259 | m_CounterDirectory.RegisterCategory("ArmNN_Runtime"); |
| 260 | } |
| 261 | |
| 262 | // Register a counter for the number of loaded networks |
| 263 | if (!m_CounterDirectory.IsCounterRegistered("Loaded networks")) |
| 264 | { |
| 265 | const Counter* loadedNetworksCounter = |
| 266 | m_CounterDirectory.RegisterCounter("ArmNN_Runtime", |
| 267 | 0, |
| 268 | 0, |
| 269 | 1.f, |
| 270 | "Loaded networks", |
| 271 | "The number of networks loaded at runtime", |
| 272 | std::string("networks")); |
| 273 | BOOST_ASSERT(loadedNetworksCounter); |
| 274 | InitializeCounterValue(loadedNetworksCounter->m_Uid); |
| 275 | } |
| 276 | |
| 277 | // Register a counter for the number of registered backends |
| 278 | if (!m_CounterDirectory.IsCounterRegistered("Registered backends")) |
| 279 | { |
| 280 | const Counter* registeredBackendsCounter = |
| 281 | m_CounterDirectory.RegisterCounter("ArmNN_Runtime", |
| 282 | 0, |
| 283 | 0, |
| 284 | 1.f, |
| 285 | "Registered backends", |
| 286 | "The number of registered backends", |
| 287 | std::string("backends")); |
| 288 | BOOST_ASSERT(registeredBackendsCounter); |
| 289 | InitializeCounterValue(registeredBackendsCounter->m_Uid); |
| 290 | } |
| 291 | |
| 292 | // Register a counter for the number of inferences run |
| 293 | if (!m_CounterDirectory.IsCounterRegistered("Inferences run")) |
| 294 | { |
| 295 | const Counter* inferencesRunCounter = |
| 296 | m_CounterDirectory.RegisterCounter("ArmNN_Runtime", |
| 297 | 0, |
| 298 | 0, |
| 299 | 1.f, |
| 300 | "Inferences run", |
| 301 | "The number of inferences run", |
| 302 | std::string("inferences")); |
| 303 | BOOST_ASSERT(inferencesRunCounter); |
| 304 | InitializeCounterValue(inferencesRunCounter->m_Uid); |
| 305 | } |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame] | 306 | } |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 307 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 308 | void ProfilingService::InitializeCounterValue(uint16_t counterUid) |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 309 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 310 | // Increase the size of the counter index if necessary |
| 311 | if (counterUid >= m_CounterIndex.size()) |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 312 | { |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 313 | m_CounterIndex.resize(boost::numeric_cast<size_t>(counterUid) + 1); |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 314 | } |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 315 | |
| 316 | // Create a new atomic counter and add it to the list |
| 317 | m_CounterValues.emplace_back(0); |
| 318 | |
| 319 | // Register the new counter to the counter index for quick access |
| 320 | std::atomic<uint32_t>* counterValuePtr = &(m_CounterValues.back()); |
| 321 | m_CounterIndex.at(counterUid) = counterValuePtr; |
FinnWilliamsArm | f6e534a | 2019-09-16 15:45:42 +0100 | [diff] [blame] | 322 | } |
| 323 | |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 324 | void ProfilingService::Reset() |
| 325 | { |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 326 | // Stop the profiling service... |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 327 | Stop(); |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 328 | |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 329 | // ...then delete all the counter data and configuration... |
| 330 | m_CounterIndex.clear(); |
| 331 | m_CounterValues.clear(); |
| 332 | m_CounterDirectory.Clear(); |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 333 | |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 334 | // ...finally reset the profiling state machine |
| 335 | m_StateMachine.Reset(); |
| 336 | } |
| 337 | |
| 338 | void ProfilingService::Stop() |
| 339 | { |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 340 | // The order in which we reset/stop the components is not trivial! |
| 341 | |
| 342 | // First stop the threads (Command Handler first)... |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 343 | m_CommandHandler.Stop(); |
| 344 | m_SendCounterPacket.Stop(false); |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 345 | m_PeriodicCounterCapture.Stop(); |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 346 | |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 347 | // ...then close and destroy the profiling connection... |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 348 | if (m_ProfilingConnection != nullptr && m_ProfilingConnection->IsOpen()) |
| 349 | { |
| 350 | m_ProfilingConnection->Close(); |
| 351 | } |
Matteo Martincigh | d0613b5 | 2019-10-09 16:47:04 +0100 | [diff] [blame] | 352 | m_ProfilingConnection.reset(); |
| 353 | |
Matteo Martincigh | 8d9590e | 2019-10-15 09:35:29 +0100 | [diff] [blame] | 354 | // ...then move to the "NotConnected" state |
Jim Flynn | 53e4699 | 2019-10-14 12:31:10 +0100 | [diff] [blame] | 355 | m_StateMachine.TransitionToState(ProfilingState::NotConnected); |
Matteo Martincigh | 54fb957 | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 356 | } |
| 357 | |
Matteo Martincigh | e848538 | 2019-10-10 14:08:21 +0100 | [diff] [blame] | 358 | inline void ProfilingService::CheckCounterUid(uint16_t counterUid) const |
| 359 | { |
| 360 | if (!IsCounterRegistered(counterUid)) |
| 361 | { |
| 362 | throw InvalidArgumentException(boost::str(boost::format("Counter UID %1% is not registered") % counterUid)); |
| 363 | } |
| 364 | } |
| 365 | |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 366 | } // namespace profiling |
| 367 | |
Matteo Martincigh | a84edee | 2019-10-02 12:50:57 +0100 | [diff] [blame] | 368 | } // namespace armnn |