ArmNN
 25.11
Loading...
Searching...
No Matches
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
19namespace armnn
20{
21
22/// Forward declaration
23class IProfiler;
24
25/// Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when
26/// Event::GetMeasurements() is called.
27class Event
28{
29public:
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
88private:
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
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.
Event(const Event &other)=delete
const std::string & GetName() const
Get the name of the event.
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.
std::vector< InstrumentPtr > Instruments
std::unique_ptr< Instrument > InstrumentPtr
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.