ArmNN
 21.08
PeriodicCounterCapture.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 #include "Holder.hpp"
10 #include "SendCounterPacket.hpp"
11 #include "ICounterValues.hpp"
12 #include "CounterIdMap.hpp"
13 
15 
16 #include <common/include/Packet.hpp>
17 
18 #include <atomic>
19 #include <mutex>
20 #include <thread>
21 
22 namespace armnn
23 {
24 
25 namespace profiling
26 {
27 
29 {
30 public:
32  ISendCounterPacket& packet,
33  IReadCounterValues& readCounterValue,
34  const ICounterMappings& counterIdMap,
35  const std::unordered_map<armnn::BackendId,
36  std::shared_ptr<armnn::profiling::IBackendProfilingContext>>&
37  backendProfilingContexts)
38  : m_CaptureDataHolder(data)
39  , m_IsRunning(false)
40  , m_KeepRunning(false)
41  , m_ReadCounterValues(readCounterValue)
42  , m_SendCounterPacket(packet)
43  , m_CounterIdMap(counterIdMap)
44  , m_BackendProfilingContexts(backendProfilingContexts)
45  {}
47 
48  void Start() override;
49  void Stop() override;
50  bool IsRunning() const { return m_IsRunning; }
51 
52 private:
53  CaptureData ReadCaptureData();
54  void Capture(IReadCounterValues& readCounterValues);
55  void DispatchPeriodicCounterCapturePacket(
56  const armnn::BackendId& backendId, const std::vector<Timestamp>& timestampValues);
57 
58  const Holder& m_CaptureDataHolder;
59  bool m_IsRunning;
60  std::atomic<bool> m_KeepRunning;
61  std::thread m_PeriodCaptureThread;
62  IReadCounterValues& m_ReadCounterValues;
63  ISendCounterPacket& m_SendCounterPacket;
64  const ICounterMappings& m_CounterIdMap;
65  const std::unordered_map<armnn::BackendId,
66  std::shared_ptr<armnn::profiling::IBackendProfilingContext>>& m_BackendProfilingContexts;
67 };
68 
69 } // namespace profiling
70 
71 } // namespace armnn
Copyright (c) 2021 ARM Limited and Contributors.
PeriodicCounterCapture(const Holder &data, ISendCounterPacket &packet, IReadCounterValues &readCounterValue, const ICounterMappings &counterIdMap, const std::unordered_map< armnn::BackendId, std::shared_ptr< armnn::profiling::IBackendProfilingContext >> &backendProfilingContexts)