ArmNN
 25.11
Loading...
Searching...
No Matches
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
9namespace armnn
10{
11Event::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
26Event::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
36Event::~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
56const 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
69const std::vector<Event::InstrumentPtr>& Event::GetInstruments() const
70{
71 return m_Instruments;
72}
73
74const 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
100Event& 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
void Start()
Start the Event.
const Event * GetParentEvent() const
Get the pointer of the parent event.
void Stop()
Stop the Event.
const IProfiler * GetProfiler() const
Get the pointer of the profiler associated with this event.
const std::string & GetName() const
Get the name of the event.
Event & operator=(const Event &other)=delete
Assignment operator.
Event(const std::string &eventName, IProfiler *profiler, Event *parent, const BackendId backendId, std::vector< InstrumentPtr > &&instrument, const Optional< arm::pipe::ProfilingGuid > guid)
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()
const std::vector< InstrumentPtr > & GetInstruments() const
Get the Instruments used by this Event.
~Event() noexcept
Destructor.
Copyright (c) 2021 ARM Limited and Contributors.