ArmNN
 24.02
ProfilingEvent.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "Profiling.hpp"
7 #include "ProfilingEvent.hpp"
8 
9 namespace armnn
10 {
11 Event::Event(const std::string& eventName,
12  IProfiler* profiler,
13  Event* parent,
14  const BackendId backendId,
15  std::vector<InstrumentPtr>&& instruments,
17  : m_EventName(eventName)
18  , m_Profiler(profiler)
19  , m_Parent(parent)
20  , m_BackendId(backendId)
21  , m_Instruments(std::move(instruments))
22  , m_ProfilingGuid(guid)
23 {
24 }
25 
26 Event::Event(Event&& other) noexcept
27  : m_EventName(std::move(other.m_EventName))
28  , m_Profiler(other.m_Profiler)
29  , m_Parent(other.m_Parent)
30  , m_BackendId(other.m_BackendId)
31  , m_Instruments(std::move(other.m_Instruments))
32  , m_ProfilingGuid(other.m_ProfilingGuid)
33 {
34 }
35 
36 Event::~Event() noexcept
37 {
38 }
39 
41 {
42  for (auto& instrument : m_Instruments)
43  {
44  instrument->Start();
45  }
46 }
47 
49 {
50  for (auto& instrument : m_Instruments)
51  {
52  instrument->Stop();
53  }
54 }
55 
56 const std::vector<Measurement> Event::GetMeasurements() const
57 {
58  std::vector<Measurement> measurements;
59  for (auto& instrument : m_Instruments)
60  {
61  for (auto& measurement : instrument->GetMeasurements())
62  {
63  measurements.emplace_back(std::move(measurement));
64  }
65  }
66  return measurements;
67 }
68 
69 const std::vector<Event::InstrumentPtr>& Event::GetInstruments() const
70 {
71  return m_Instruments;
72 }
73 
74 const std::string& Event::GetName() const
75 {
76  return m_EventName;
77 }
78 
80 {
81  return m_Profiler;
82 }
83 
85 {
86  return m_Parent;
87 }
88 
90 {
91  return m_BackendId;
92 }
93 
95 {
96  return m_ProfilingGuid;
97 }
98 
99 
100 Event& Event::operator=(Event&& other) noexcept
101 {
102  if (this == &other)
103  {
104  return *this;
105  }
106 
107  m_EventName = other.m_EventName;
108  m_Profiler = other.m_Profiler;
109  m_Parent = other.m_Parent;
110  m_BackendId = other.m_BackendId;
111  m_ProfilingGuid = other.m_ProfilingGuid;
112  other.m_Profiler = nullptr;
113  other.m_Parent = nullptr;
114  return *this;
115 }
116 
117 } // namespace armnn
armnn::Event::GetName
const std::string & GetName() const
Get the name of the event.
Definition: ProfilingEvent.cpp:74
armnn::Optional< arm::pipe::ProfilingGuid >
armnn::Event::GetParentEvent
const Event * GetParentEvent() const
Get the pointer of the parent event.
Definition: ProfilingEvent.cpp:84
Profiling.hpp
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
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
ProfilingEvent.hpp
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::operator=
Event & operator=(const Event &other)=delete
Assignment operator.
armnn::Event::~Event
~Event() noexcept
Destructor.
Definition: ProfilingEvent.cpp:36
std
Definition: BackendId.hpp:149
armnn::BackendId
Definition: BackendId.hpp:75
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
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