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 | |
| 8 | namespace armnn |
| 9 | { |
| 10 | |
| 11 | namespace profiling |
| 12 | { |
| 13 | |
| 14 | ProfilingService::ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options) |
| 15 | : m_Options(options) |
| 16 | { |
| 17 | Initialise(); |
| 18 | } |
| 19 | |
| 20 | void ProfilingService::Initialise() |
| 21 | { |
| 22 | if (m_Options.m_EnableProfiling == true) |
| 23 | { |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame^] | 24 | // Setup provisional Counter Directory example - this should only be created if profiling is enabled |
| 25 | // Setup provisional Counter meta example |
| 26 | const std::string categoryName = "Category"; |
| 27 | |
| 28 | m_CounterDirectory.RegisterCategory(categoryName); |
| 29 | m_CounterDirectory.RegisterDevice("device name", 0, categoryName); |
| 30 | m_CounterDirectory.RegisterCounterSet("counterSet_name", 2, categoryName); |
| 31 | |
| 32 | m_CounterDirectory.RegisterCounter(categoryName, |
| 33 | 0, |
| 34 | 1, |
| 35 | 123.45f, |
| 36 | "counter name 1", |
| 37 | "counter description"); |
| 38 | |
| 39 | m_CounterDirectory.RegisterCounter(categoryName, |
| 40 | 0, |
| 41 | 1, |
| 42 | 123.45f, |
| 43 | "counter name 2", |
| 44 | "counter description"); |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 45 | |
| 46 | // For now until CounterDirectory setup is implemented, change m_State once everything initialised |
| 47 | m_State.TransitionToState(ProfilingState::NotConnected); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void ProfilingService::Run() |
| 52 | { |
| 53 | if (m_State.GetCurrentState() == ProfilingState::NotConnected) |
| 54 | { |
| 55 | // Since GetProfilingConnection is not implemented, if !NULL, |
| 56 | // then change to WaitingForAck. This will need to change once there is implementation |
| 57 | // for the IProfilingConnection |
| 58 | if (!m_Factory.GetProfilingConnection(m_Options)) |
| 59 | { |
| 60 | m_State.TransitionToState(ProfilingState::WaitingForAck); |
| 61 | } |
| 62 | } else if (m_State.GetCurrentState() == ProfilingState::Uninitialised && m_Options.m_EnableProfiling == true) |
| 63 | { |
| 64 | Initialise(); |
| 65 | } |
| 66 | } |
| 67 | |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame^] | 68 | const ICounterDirectory& ProfilingService::GetCounterDirectory() const |
| 69 | { |
| 70 | return m_CounterDirectory; |
| 71 | } |
| 72 | |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 73 | ProfilingState ProfilingService::GetCurrentState() const |
| 74 | { |
| 75 | return m_State.GetCurrentState(); |
| 76 | } |
FinnWilliamsArm | ce2d9d1 | 2019-09-18 10:28:16 +0100 | [diff] [blame^] | 77 | |
| 78 | void ProfilingService::ResetExternalProfilingOptions(const Runtime::CreationOptions::ExternalProfilingOptions& options) |
| 79 | { |
| 80 | if(!m_Options.m_EnableProfiling) |
| 81 | { |
| 82 | m_Options = options; |
| 83 | Initialise(); |
| 84 | return; |
| 85 | } |
| 86 | m_Options = options; |
| 87 | } |
Keith Davis | 02356de | 2019-08-26 18:28:17 +0100 | [diff] [blame] | 88 | } // namespace profiling |
| 89 | |
| 90 | } // namespace armnn |