blob: 134735530fdcc3c7076a2b844a1da0edaf8648b4 [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
5
6#pragma once
7
8#include <stack>
9#include <vector>
10#include <chrono>
11#include <memory>
12#include "Instrument.hpp"
13#include "armnn/Types.hpp"
14
15namespace armnn
16{
17
18/// Forward declaration
19class Profiler;
20
21/// Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when
22/// Event::GetMeasurements() is called.
23class Event
24{
25public:
26 using InstrumentPtr = std::unique_ptr<Instrument>;
27 using Instruments = std::vector<InstrumentPtr>;
28
29 Event(const std::string& eventName,
30 Profiler* profiler,
31 Event* parent,
32 const Compute computeDevice,
33 std::vector<InstrumentPtr>&& instrument);
34
35 Event(const Event& other) = delete;
36
37 /// Move Constructor
38 Event(Event&& other) noexcept;
39
40 /// Destructor
41 ~Event() noexcept;
42
43 /// Start the Event
44 void Start();
45
46 /// Stop the Event
47 void Stop();
48
49 /// Get the recorded measurements calculated between Start() and Stop()
50 /// \return Recorded measurements of the event
51 const std::vector<Measurement> GetMeasurements() const;
52
53 /// Get the name of the event
54 /// \return Name of the event
55 const std::string& GetName() const;
56
57 /// Get the pointer of the profiler associated with this event
58 /// \return Pointer of the profiler associated with this event
59 const Profiler* GetProfiler() const;
60
61 /// Get the pointer of the parent event
62 /// \return Pointer of the parent event
63 const Event* GetParentEvent() const;
64
65 /// Get the compute device of the event
66 /// \return Compute device of the event
67 Compute GetComputeDevice() const;
68
69 /// Assignment operator
70 Event& operator=(const Event& other) = delete;
71
72 /// Move Assignment operator
73 Event& operator=(Event&& other) noexcept;
74
75private:
76 /// Name of the event
77 std::string m_EventName;
78
79 /// Stored associated profiler
80 Profiler* m_Profiler;
81
82 /// Stores optional parent event
83 Event* m_Parent;
84
85 /// Compute device
86 Compute m_ComputeDevice;
87
88 /// Instruments to use
89 Instruments m_Instruments;
90};
91
92} // namespace armnn