blob: 7afd5c100c904e7495a4be979f57aba6ac90f3a8 [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
Francis Murtagh33199c22021-02-15 10:11:28 +000019class IProfiler;
telsoa01c577f2c2018-08-31 09:22:23 +010020
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,
Francis Murtagh33199c22021-02-15 10:11:28 +000030 IProfiler* profiler,
Matteo Martincigh992d6dc2019-01-10 17:34:20 +000031 Event* parent,
32 const BackendId backendId,
33 std::vector<InstrumentPtr>&& instrument);
telsoa01c577f2c2018-08-31 09:22:23 +010034
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
Francis Murtagh33199c22021-02-15 10:11:28 +000059 const IProfiler* GetProfiler() const;
telsoa01c577f2c2018-08-31 09:22:23 +010060
61 /// Get the pointer of the parent event
62 /// \return Pointer of the parent event
63 const Event* GetParentEvent() const;
64
Matteo Martincigh992d6dc2019-01-10 17:34:20 +000065 /// Get the backend id of the event
66 /// \return Backend id of the event
67 BackendId GetBackendId() const;
telsoa01c577f2c2018-08-31 09:22:23 +010068
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
Francis Murtagh33199c22021-02-15 10:11:28 +000080 IProfiler* m_Profiler;
telsoa01c577f2c2018-08-31 09:22:23 +010081
82 /// Stores optional parent event
83 Event* m_Parent;
84
Matteo Martincigh992d6dc2019-01-10 17:34:20 +000085 /// Backend id
86 BackendId m_BackendId;
telsoa01c577f2c2018-08-31 09:22:23 +010087
88 /// Instruments to use
89 Instruments m_Instruments;
90};
91
92} // namespace armnn