From 3201eea0565ce2bb0418d1936fec71bdeb14c084 Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Thu, 24 Oct 2019 17:30:41 +0100 Subject: 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 Signed-off-by: Colm Donelan Change-Id: I77b2aedece24150dd31691b577f3b5d81b2e226f --- src/profiling/DirectoryCaptureCommandHandler.hpp | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/profiling/DirectoryCaptureCommandHandler.hpp (limited to 'src/profiling/DirectoryCaptureCommandHandler.hpp') 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 + +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 categoryOffsets); + + std::vector + ReadEventRecords(const unsigned char* data, uint32_t offset, std::vector eventRecordsOffsets); + + std::string GetStringNameFromBuffer(const unsigned char* data, uint32_t offset); + bool IsValidChar(unsigned char c); + + CounterDirectory m_CounterDirectory; + std::unordered_map 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 m_AlreadyParsed; +}; + +} // namespace profiling + +} // namespace armnn -- cgit v1.2.1