Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Finn Williams | 8a2b468 | 2020-02-26 10:25:26 +0000 | [diff] [blame] | 8 | #include "armnn/profiling/ITimelineDecoder.hpp" |
| 9 | |
Finn Williams | e6a2ccd | 2020-02-27 16:21:41 +0000 | [diff] [blame] | 10 | #include <CommandHandlerFunctor.hpp> |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 11 | #include <Packet.hpp> |
| 12 | #include <ProfilingUtils.hpp> |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
Finn Williams | 8a2b468 | 2020-02-26 10:25:26 +0000 | [diff] [blame] | 17 | namespace timelinedecoder |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 18 | { |
| 19 | |
Keith Davis | 5238aff | 2020-03-11 12:17:05 +0000 | [diff] [blame] | 20 | class TimelineCaptureCommandHandler : |
| 21 | public profiling::CommandHandlerFunctor |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 22 | { |
| 23 | // Utils |
| 24 | uint32_t uint32_t_size = sizeof(uint32_t); |
| 25 | uint32_t uint64_t_size = sizeof(uint64_t); |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 26 | |
Keith Davis | 5238aff | 2020-03-11 12:17:05 +0000 | [diff] [blame] | 27 | using ReadFunction = void (TimelineCaptureCommandHandler::*)(const unsigned char*, uint32_t&); |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 28 | |
| 29 | public: |
| 30 | TimelineCaptureCommandHandler(uint32_t familyId, |
| 31 | uint32_t packetId, |
| 32 | uint32_t version, |
Finn Williams | 510f618 | 2020-02-21 11:14:08 +0000 | [diff] [blame] | 33 | ITimelineDecoder& timelineDecoder, |
Finn Williams | e6a2ccd | 2020-02-27 16:21:41 +0000 | [diff] [blame] | 34 | uint32_t threadIdSize = 0) |
| 35 | : CommandHandlerFunctor(familyId, packetId, version) |
| 36 | , m_TimelineDecoder(timelineDecoder) |
| 37 | , m_ThreadIdSize(threadIdSize) |
| 38 | , m_PacketLength(0) |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 39 | {} |
| 40 | |
| 41 | void operator()(const armnn::profiling::Packet& packet) override; |
| 42 | |
Keith Davis | 5238aff | 2020-03-11 12:17:05 +0000 | [diff] [blame] | 43 | void ReadLabel(const unsigned char* data, uint32_t& offset); |
| 44 | void ReadEntity(const unsigned char* data, uint32_t& offset); |
| 45 | void ReadEventClass(const unsigned char* data, uint32_t& offset); |
| 46 | void ReadRelationship(const unsigned char* data, uint32_t& offset); |
| 47 | void ReadEvent(const unsigned char* data, uint32_t& offset); |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 48 | |
Finn Williams | e6a2ccd | 2020-02-27 16:21:41 +0000 | [diff] [blame] | 49 | void SetThreadIdSize(uint32_t size); |
| 50 | |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 51 | private: |
| 52 | void ParseData(const armnn::profiling::Packet& packet); |
| 53 | |
Finn Williams | 510f618 | 2020-02-21 11:14:08 +0000 | [diff] [blame] | 54 | ITimelineDecoder& m_TimelineDecoder; |
Finn Williams | e6a2ccd | 2020-02-27 16:21:41 +0000 | [diff] [blame] | 55 | uint32_t m_ThreadIdSize; |
Keith Davis | 5238aff | 2020-03-11 12:17:05 +0000 | [diff] [blame] | 56 | unsigned int m_PacketLength; |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 57 | static const ReadFunction m_ReadFunctions[]; |
Keith Davis | 5238aff | 2020-03-11 12:17:05 +0000 | [diff] [blame] | 58 | |
Finn Williams | e63a026 | 2019-10-22 10:30:49 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } //namespace gatordmock |
| 62 | |
| 63 | } //namespace armnn |