diff options
author | Keith Davis <keith.davis@arm.com> | 2019-10-24 17:30:41 +0100 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2019-11-06 08:30:31 +0000 |
commit | 3201eea0565ce2bb0418d1936fec71bdeb14c084 (patch) | |
tree | f73017f6338d707165dbcfd717ddc9793b1858e0 /src/profiling/DirectoryCaptureCommandHandler.hpp | |
parent | fe2e2cbbbe5294072b2d58755b8a095f32a97e75 (diff) | |
download | armnn-3201eea0565ce2bb0418d1936fec71bdeb14c084.tar.gz |
IVGCVSW-3444 File Only Profiling Connection
* Add FileOnlyProfilingConnection Decorator
* Fix bug where Conn Ack not automatically sent back
* Modify GatordMock to use the Counter Directory class.
* Promote DirectoryCaptureCommandHandler from GatordMock into ArmNN.
* Remove MockUtils as it's contents were moved or deleted.
* Rewrite GatordMockTests to use Counter Directory class.
* Flush streams in ProfilingConnectionDumpToFileDecorator::Close.
Signed-off-by: Keith Davis <keith.davis@arm.com>
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: I77b2aedece24150dd31691b577f3b5d81b2e226f
Diffstat (limited to 'src/profiling/DirectoryCaptureCommandHandler.hpp')
-rw-r--r-- | src/profiling/DirectoryCaptureCommandHandler.hpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/profiling/DirectoryCaptureCommandHandler.hpp b/src/profiling/DirectoryCaptureCommandHandler.hpp new file mode 100644 index 0000000000..03bbb1eb09 --- /dev/null +++ b/src/profiling/DirectoryCaptureCommandHandler.hpp @@ -0,0 +1,84 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "CommandHandlerFunctor.hpp" +#include "CounterDirectory.hpp" + +#include <atomic> + +namespace armnn +{ + +namespace profiling +{ + +struct CounterDirectoryEventRecord +{ + uint16_t m_CounterClass; + std::string m_CounterDescription; + uint16_t m_CounterInterpolation; + double m_CounterMultiplier; + std::string m_CounterName; + uint16_t m_CounterSetUid; + uint16_t m_CounterUid; + std::string m_CounterUnits; + uint16_t m_DeviceUid; + uint16_t m_MaxCounterUid; +}; + +class DirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor +{ + +public: + DirectoryCaptureCommandHandler(uint32_t familyId, uint32_t packetId, uint32_t version, bool quietOperation = true) + : CommandHandlerFunctor(familyId, packetId, version) + , m_QuietOperation(quietOperation) + , m_AlreadyParsed(false) + {} + + void operator()(const armnn::profiling::Packet& packet) override; + + const ICounterDirectory& GetCounterDirectory() const; + + bool ParsedCounterDirectory() + { + return m_AlreadyParsed.load(); + } + + /** + * Given a Uid that came from a copy of the counter directory translate it to the original. + * + * @param copyUid + * @return the original Uid that the copy maps to. + */ + uint16_t TranslateUIDCopyToOriginal(uint16_t copyUid) + { + return m_UidTranslation[copyUid]; + } + +private: + void ParseData(const armnn::profiling::Packet& packet); + + void ReadCategoryRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> categoryOffsets); + + std::vector<CounterDirectoryEventRecord> + ReadEventRecords(const unsigned char* data, uint32_t offset, std::vector<uint32_t> eventRecordsOffsets); + + std::string GetStringNameFromBuffer(const unsigned char* data, uint32_t offset); + bool IsValidChar(unsigned char c); + + CounterDirectory m_CounterDirectory; + std::unordered_map<uint16_t, uint16_t> m_UidTranslation; + bool m_QuietOperation; + // We can only parse the counter directory once per instance. It won't change anyway as it's static + // per instance of ArmNN. + std::atomic<bool> m_AlreadyParsed; +}; + +} // namespace profiling + +} // namespace armnn |