• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "Instrument.hpp"
13 #include "armnn/Types.hpp"
14 
15 namespace armnn
16 {
17 
18 /// Forward declaration
19 class Profiler;
20 
21 /// Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when
22 /// Event::GetMeasurements() is called.
23 class Event
24 {
25 public:
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 BackendId backendId,
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 backend id of the event
66     /// \return Backend id of the event
67     BackendId GetBackendId() const;
68 
69     /// Assignment operator
70     Event& operator=(const Event& other) = delete;
71 
72     /// Move Assignment operator
73     Event& operator=(Event&& other) noexcept;
74 
75 private:
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     /// Backend id
86     BackendId m_BackendId;
87 
88     /// Instruments to use
89     Instruments m_Instruments;
90 };
91 
92 } // namespace armnn
93