ArmNN
 24.02
ProfilingEvent.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <stack>
9 #include <vector>
10 #include <chrono>
11 #include <memory>
12 
13 #include <common/include/ProfilingGuid.hpp>
14 #include <armnn/Optional.hpp>
15 
16 #include "Instrument.hpp"
17 #include "armnn/Types.hpp"
18 
19 namespace armnn
20 {
21 
22 /// Forward declaration
23 class IProfiler;
24 
25 /// Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when
26 /// Event::GetMeasurements() is called.
27 class Event
28 {
29 public:
30  using InstrumentPtr = std::unique_ptr<Instrument>;
31  using Instruments = std::vector<InstrumentPtr>;
32 
33  Event(const std::string& eventName,
34  IProfiler* profiler,
35  Event* parent,
36  const BackendId backendId,
37  std::vector<InstrumentPtr>&& instrument,
39 
40  Event(const Event& other) = delete;
41 
42  /// Move Constructor
43  Event(Event&& other) noexcept;
44 
45  /// Destructor
46  ~Event() noexcept;
47 
48  /// Start the Event
49  void Start();
50 
51  /// Stop the Event
52  void Stop();
53 
54  /// Get the recorded measurements calculated between Start() and Stop()
55  /// \return Recorded measurements of the event
56  const std::vector<Measurement> GetMeasurements() const;
57 
58  /// Get the Instruments used by this Event
59  /// \return Return a reference to the collection of Instruments
60  const std::vector<InstrumentPtr>& GetInstruments() const;
61 
62  /// Get the name of the event
63  /// \return Name of the event
64  const std::string& GetName() const;
65 
66  /// Get the pointer of the profiler associated with this event
67  /// \return Pointer of the profiler associated with this event
68  const IProfiler* GetProfiler() const;
69 
70  /// Get the pointer of the parent event
71  /// \return Pointer of the parent event
72  const Event* GetParentEvent() const;
73 
74  /// Get the backend id of the event
75  /// \return Backend id of the event
76  BackendId GetBackendId() const;
77 
78  /// Get the associated profiling GUID if the event is a workload
79  /// \return Optional GUID of the event
80  Optional<arm::pipe::ProfilingGuid> GetProfilingGuid() const;
81 
82  /// Assignment operator
83  Event& operator=(const Event& other) = delete;
84 
85  /// Move Assignment operator
86  Event& operator=(Event&& other) noexcept;
87 
88 private:
89  /// Name of the event
90  std::string m_EventName;
91 
92  /// Stored associated profiler
93  IProfiler* m_Profiler;
94 
95  /// Stores optional parent event
96  Event* m_Parent;
97 
98  /// Backend id
99  BackendId m_BackendId;
100 
101  /// Instruments to use
102  Instruments m_Instruments;
103 
104  /// Workload Profiling id
105  Optional<arm::pipe::ProfilingGuid> m_ProfilingGuid;
106 };
107 
108 } // namespace armnn
armnn::Event::InstrumentPtr
std::unique_ptr< Instrument > InstrumentPtr
Definition: ProfilingEvent.hpp:30
armnn::Event::GetName
const std::string & GetName() const
Get the name of the event.
Definition: ProfilingEvent.cpp:74
arm
Definition: BackendRegistry.hpp:15
armnn::Optional< arm::pipe::ProfilingGuid >
armnn::Event::GetParentEvent
const Event * GetParentEvent() const
Get the pointer of the parent event.
Definition: ProfilingEvent.cpp:84
armnn::Event::GetMeasurements
const std::vector< Measurement > GetMeasurements() const
Get the recorded measurements calculated between Start() and Stop()
Definition: ProfilingEvent.cpp:56
armnn::Event::Event
Event(const std::string &eventName, IProfiler *profiler, Event *parent, const BackendId backendId, std::vector< InstrumentPtr > &&instrument, const Optional< arm::pipe::ProfilingGuid > guid)
Definition: ProfilingEvent.cpp:11
Optional.hpp
armnn::Event::GetProfilingGuid
Optional< arm::pipe::ProfilingGuid > GetProfilingGuid() const
Get the associated profiling GUID if the event is a workload.
Definition: ProfilingEvent.cpp:94
armnn::Event
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
Definition: ProfilingEvent.hpp:27
armnn::Event::GetInstruments
const std::vector< InstrumentPtr > & GetInstruments() const
Get the Instruments used by this Event.
Definition: ProfilingEvent.cpp:69
Instrument.hpp
armnn::Measurement
Definition: Instrument.hpp:14
armnn::Event::GetProfiler
const IProfiler * GetProfiler() const
Get the pointer of the profiler associated with this event.
Definition: ProfilingEvent.cpp:79
armnn::Event::Start
void Start()
Start the Event.
Definition: ProfilingEvent.cpp:40
armnn::Event::~Event
~Event() noexcept
Destructor.
Definition: ProfilingEvent.cpp:36
std
Definition: BackendId.hpp:149
armnn::Event::Instruments
std::vector< InstrumentPtr > Instruments
Definition: ProfilingEvent.hpp:31
armnn::BackendId
Definition: BackendId.hpp:75
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
Types.hpp
armnn::IProfiler
Definition: IProfiler.hpp:21
armnn::Event::GetBackendId
BackendId GetBackendId() const
Get the backend id of the event.
Definition: ProfilingEvent.cpp:89
armnn::Event::Stop
void Stop()
Stop the Event.
Definition: ProfilingEvent.cpp:48