ArmNN
 22.05.01
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 name of the event
59  /// \return Name of the event
60  const std::string& GetName() const;
61 
62  /// Get the pointer of the profiler associated with this event
63  /// \return Pointer of the profiler associated with this event
64  const IProfiler* GetProfiler() const;
65 
66  /// Get the pointer of the parent event
67  /// \return Pointer of the parent event
68  const Event* GetParentEvent() const;
69 
70  /// Get the backend id of the event
71  /// \return Backend id of the event
72  BackendId GetBackendId() const;
73 
74  /// Get the associated profiling GUID if the event is a workload
75  /// \return Optional GUID of the event
76  Optional<arm::pipe::ProfilingGuid> GetProfilingGuid() const;
77 
78  /// Assignment operator
79  Event& operator=(const Event& other) = delete;
80 
81  /// Move Assignment operator
82  Event& operator=(Event&& other) noexcept;
83 
84 private:
85  /// Name of the event
86  std::string m_EventName;
87 
88  /// Stored associated profiler
89  IProfiler* m_Profiler;
90 
91  /// Stores optional parent event
92  Event* m_Parent;
93 
94  /// Backend id
95  BackendId m_BackendId;
96 
97  /// Instruments to use
98  Instruments m_Instruments;
99 
100  /// Workload Profiling id
101  Optional<arm::pipe::ProfilingGuid> m_ProfilingGuid;
102 };
103 
104 } // namespace armnn
Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when Ev...
~Event() noexcept
Destructor.
std::vector< InstrumentPtr > Instruments
const std::string & GetName() const
Get the name of the event.
Copyright (c) 2021 ARM Limited and Contributors.
void Start()
Start the Event.
void Stop()
Stop the Event.
Optional< arm::pipe::ProfilingGuid > GetProfilingGuid() const
Get the associated profiling GUID if the event is a workload.
BackendId GetBackendId() const
Get the backend id of the event.
const std::vector< Measurement > GetMeasurements() const
Get the recorded measurements calculated between Start() and Stop()
std::unique_ptr< Instrument > InstrumentPtr
const IProfiler * GetProfiler() const
Get the pointer of the profiler associated with this event.
const Event * GetParentEvent() const
Get the pointer of the parent event.
Event(const std::string &eventName, IProfiler *profiler, Event *parent, const BackendId backendId, std::vector< InstrumentPtr > &&instrument, const Optional< arm::pipe::ProfilingGuid > guid)