blob: 4e613838c210590677ad60659b45f792d278ebfb [file] [log] [blame]
Keith Davis02356de2019-08-26 18:28:17 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ProfilingService.hpp"
7
8namespace armnn
9{
10
11namespace profiling
12{
13
14ProfilingService::ProfilingService(const Runtime::CreationOptions::ExternalProfilingOptions& options)
15 : m_Options(options)
16{
17 Initialise();
18}
19
20void ProfilingService::Initialise()
21{
22 if (m_Options.m_EnableProfiling == true)
23 {
FinnWilliamsArmce2d9d12019-09-18 10:28:16 +010024 // 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 Davis02356de2019-08-26 18:28:17 +010045
46 // For now until CounterDirectory setup is implemented, change m_State once everything initialised
47 m_State.TransitionToState(ProfilingState::NotConnected);
48 }
49}
50
51void 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
FinnWilliamsArmce2d9d12019-09-18 10:28:16 +010068const ICounterDirectory& ProfilingService::GetCounterDirectory() const
69{
70 return m_CounterDirectory;
71}
72
Keith Davis02356de2019-08-26 18:28:17 +010073ProfilingState ProfilingService::GetCurrentState() const
74{
75 return m_State.GetCurrentState();
76}
FinnWilliamsArmce2d9d12019-09-18 10:28:16 +010077
78void 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 Davis02356de2019-08-26 18:28:17 +010088} // namespace profiling
89
90} // namespace armnn