diff options
author | Jim Flynn <jim.flynn@arm.com> | 2022-03-16 18:43:18 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2022-03-16 21:41:51 +0000 |
commit | c454ac95267beecd67b1ec3ef8851d5089f99c4c (patch) | |
tree | 56a240e14004d05e8a4454374bac8fe80fca8d3c /profiling/server/include | |
parent | 9c85b41a9fcb3c64d7a686373e7dde75630ccd49 (diff) | |
download | armnn-c454ac95267beecd67b1ec3ef8851d5089f99c4c.tar.gz |
IVGCVSW-6851 Move DirectoryCaptureCommandHandler to the profiling server library
Change-Id: Ib14fdcca15f40fedc0f992b0fd882458dc58c9ba
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'profiling/server/include')
-rw-r--r-- | profiling/server/include/timelineDecoder/DirectoryCaptureCommandHandler.hpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/profiling/server/include/timelineDecoder/DirectoryCaptureCommandHandler.hpp b/profiling/server/include/timelineDecoder/DirectoryCaptureCommandHandler.hpp new file mode 100644 index 0000000000..de10ec8892 --- /dev/null +++ b/profiling/server/include/timelineDecoder/DirectoryCaptureCommandHandler.hpp @@ -0,0 +1,90 @@ +// +// Copyright © 2019 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <common/include/CommandHandlerFunctor.hpp> +#include <common/include/CounterDirectory.hpp> + +#include <atomic> + +namespace arm +{ + +namespace pipe +{ + +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; + arm::pipe::Optional<std::string> m_CounterUnits; + uint16_t m_DeviceUid; + uint16_t m_MaxCounterUid; +}; + +class DirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor +{ + +public: + DirectoryCaptureCommandHandler(const std::string& applicationName, + uint32_t familyId, + uint32_t packetId, + uint32_t version, + bool quietOperation = true) + : CommandHandlerFunctor(familyId, packetId, version) + , m_ApplicationName(applicationName) + , m_QuietOperation(quietOperation) + , m_AlreadyParsed(false) + {} + + void operator()(const arm::pipe::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 arm::pipe::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); + + std::string m_ApplicationName; + 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 pipe + +} // namespace arm |