aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/ProfilingEvent.hpp
blob: b0d5be70baa058f9adcdbfd1c823efe56f7a1a32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#pragma once

#include <stack>
#include <vector>
#include <chrono>
#include <memory>

#include <common/include/ProfilingGuid.hpp>
#include <armnn/Optional.hpp>

#include "Instrument.hpp"
#include "armnn/Types.hpp"

namespace armnn
{

/// Forward declaration
class IProfiler;

/// Event class records measurements reported by BeginEvent()/EndEvent() and returns measurements when
/// Event::GetMeasurements() is called.
class Event
{
public:
    using InstrumentPtr = std::unique_ptr<Instrument>;
    using Instruments = std::vector<InstrumentPtr>;

    Event(const std::string& eventName,
          IProfiler* profiler,
          Event* parent,
          const BackendId backendId,
          std::vector<InstrumentPtr>&& instrument,
          const Optional<profiling::ProfilingGuid> guid);

    Event(const Event& other) = delete;

    /// Move Constructor
    Event(Event&& other) noexcept;

    /// Destructor
    ~Event() noexcept;

    /// Start the Event
    void Start();

    /// Stop the Event
    void Stop();

    /// Get the recorded measurements calculated between Start() and Stop()
    /// \return Recorded measurements of the event
    const std::vector<Measurement> GetMeasurements() const;

    /// Get the name of the event
    /// \return Name of the event
    const std::string& GetName() const;

    /// Get the pointer of the profiler associated with this event
    /// \return Pointer of the profiler associated with this event
    const IProfiler* GetProfiler() const;

    /// Get the pointer of the parent event
    /// \return Pointer of the parent event
    const Event* GetParentEvent() const;

    /// Get the backend id of the event
    /// \return Backend id of the event
    BackendId GetBackendId() const;

    /// Get the associated profiling GUID if the event is a workload
    /// \return Optional GUID of the event
    Optional<profiling::ProfilingGuid> GetProfilingGuid() const;

    /// Assignment operator
    Event& operator=(const Event& other) = delete;

    /// Move Assignment operator
    Event& operator=(Event&& other) noexcept;

private:
    /// Name of the event
    std::string m_EventName;

    /// Stored associated profiler
    IProfiler* m_Profiler;

    /// Stores optional parent event
    Event* m_Parent;

    /// Backend id
    BackendId m_BackendId;

    /// Instruments to use
    Instruments m_Instruments;

    /// Workload Profiling id
    Optional<profiling::ProfilingGuid> m_ProfilingGuid;
};

} // namespace armnn