telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 4 | // |
| 5 | |
| 6 | #include "Profiling.hpp" |
| 7 | #include "ProfilingEvent.hpp" |
| 8 | |
| 9 | namespace armnn |
| 10 | { |
| 11 | Event::Event(const std::string& eventName, |
| 12 | Profiler* profiler, |
| 13 | Event* parent, |
| 14 | const Compute computeDevice, |
| 15 | std::vector<InstrumentPtr>&& instruments) |
| 16 | : m_EventName(eventName) |
| 17 | , m_Profiler(profiler) |
| 18 | , m_Parent(parent) |
| 19 | , m_ComputeDevice(computeDevice) |
| 20 | , m_Instruments(std::move(instruments)) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | Event::Event(Event&& other) noexcept |
| 25 | : m_EventName(std::move(other.m_EventName)) |
| 26 | , m_Profiler(other.m_Profiler) |
| 27 | , m_Parent(other.m_Parent) |
| 28 | , m_ComputeDevice(other.m_ComputeDevice) |
| 29 | , m_Instruments(std::move(other.m_Instruments)) |
| 30 | |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | Event::~Event() noexcept |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | void Event::Start() |
| 39 | { |
| 40 | for (auto& instrument : m_Instruments) |
| 41 | { |
| 42 | instrument->Start(); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void Event::Stop() |
| 47 | { |
| 48 | for (auto& instrument : m_Instruments) |
| 49 | { |
| 50 | instrument->Stop(); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | const std::vector<Measurement> Event::GetMeasurements() const |
| 55 | { |
| 56 | std::vector<Measurement> measurements; |
| 57 | for (auto& instrument : m_Instruments) |
| 58 | { |
| 59 | for (auto& measurement : instrument->GetMeasurements()) |
| 60 | { |
| 61 | measurements.emplace_back(std::move(measurement)); |
| 62 | } |
| 63 | } |
| 64 | return measurements; |
| 65 | } |
| 66 | |
| 67 | const std::string& Event::GetName() const |
| 68 | { |
| 69 | return m_EventName; |
| 70 | } |
| 71 | |
| 72 | const Profiler* Event::GetProfiler() const |
| 73 | { |
| 74 | return m_Profiler; |
| 75 | } |
| 76 | |
| 77 | const Event* Event::GetParentEvent() const |
| 78 | { |
| 79 | return m_Parent; |
| 80 | } |
| 81 | |
| 82 | Compute Event::GetComputeDevice() const |
| 83 | { |
| 84 | return m_ComputeDevice; |
| 85 | } |
| 86 | |
| 87 | Event& Event::operator=(Event&& other) noexcept |
| 88 | { |
| 89 | if (this == &other) |
| 90 | { |
| 91 | return *this; |
| 92 | } |
| 93 | |
| 94 | m_EventName = other.m_EventName; |
| 95 | m_Profiler = other.m_Profiler; |
| 96 | m_Parent = other.m_Parent; |
| 97 | m_ComputeDevice = other.m_ComputeDevice; |
| 98 | other.m_Profiler = nullptr; |
| 99 | other.m_Parent = nullptr; |
| 100 | return *this; |
| 101 | } |
| 102 | |
| 103 | } // namespace armnn |