ArmNN
 20.08
DirectoryCaptureCommandHandler.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include "CounterDirectory.hpp"
9 
10 #include <common/include/CommandHandlerFunctor.hpp>
11 
12 #include <atomic>
13 
14 namespace armnn
15 {
16 
17 namespace profiling
18 {
19 
21 {
22  uint16_t m_CounterClass;
23  std::string m_CounterDescription;
26  std::string m_CounterName;
27  uint16_t m_CounterSetUid;
28  uint16_t m_CounterUid;
30  uint16_t m_DeviceUid;
31  uint16_t m_MaxCounterUid;
32 };
33 
34 class DirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor
35 {
36 
37 public:
38  DirectoryCaptureCommandHandler(uint32_t familyId, uint32_t packetId, uint32_t version, bool quietOperation = true)
39  : CommandHandlerFunctor(familyId, packetId, version)
40  , m_QuietOperation(quietOperation)
41  , m_AlreadyParsed(false)
42  {}
43 
44  void operator()(const arm::pipe::Packet& packet) override;
45 
46  const ICounterDirectory& GetCounterDirectory() const;
47 
49  {
50  return m_AlreadyParsed.load();
51  }
52 
53  /**
54  * Given a Uid that came from a copy of the counter directory translate it to the original.
55  *
56  * @param copyUid
57  * @return the original Uid that the copy maps to.
58  */
59  uint16_t TranslateUIDCopyToOriginal(uint16_t copyUid)
60  {
61  return m_UidTranslation[copyUid];
62  }
63 
64 private:
65  void ParseData(const arm::pipe::Packet& packet);
66 
67  void ReadCategoryRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> categoryOffsets);
68 
69  std::vector<CounterDirectoryEventRecord>
70  ReadEventRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> eventRecordsOffsets);
71 
72  std::string GetStringNameFromBuffer(const unsigned char* data, uint32_t offset);
73  bool IsValidChar(unsigned char c);
74 
75  CounterDirectory m_CounterDirectory;
76  std::unordered_map<uint16_t, uint16_t> m_UidTranslation;
77  bool m_QuietOperation;
78  // We can only parse the counter directory once per instance. It won't change anyway as it's static
79  // per instance of ArmNN.
80  std::atomic<bool> m_AlreadyParsed;
81 };
82 
83 } // namespace profiling
84 
85 } // namespace armnn
DirectoryCaptureCommandHandler(uint32_t familyId, uint32_t packetId, uint32_t version, bool quietOperation=true)
uint16_t TranslateUIDCopyToOriginal(uint16_t copyUid)
Given a Uid that came from a copy of the counter directory translate it to the original.
DataLayout::NHWC false
Copyright (c) 2020 ARM Limited.