From 8a2b4685fde869c46ad4ebb19cbfefc4adc2a654 Mon Sep 17 00:00:00 2001 From: Finn Williams Date: Wed, 26 Feb 2020 10:25:26 +0000 Subject: IVGCVSW-4160 Make the ARM Developer Studio code a self contained build entity !armnn:2773 Signed-off-by: Finn Williams Change-Id: I246cf0de04a1d29dd135cb0fc7e55bc5f0d4b854 --- .../TimelineCaptureCommandHandler.cpp | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/timelineDecoder/TimelineCaptureCommandHandler.cpp (limited to 'src/timelineDecoder/TimelineCaptureCommandHandler.cpp') diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp new file mode 100644 index 0000000000..01f55bd6d9 --- /dev/null +++ b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp @@ -0,0 +1,124 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "TimelineCaptureCommandHandler.hpp" + +#include + +namespace armnn +{ + +namespace timelinedecoder +{ + +//Array of member functions, the array index matches the decl_id +const TimelineCaptureCommandHandler::ReadFunction TimelineCaptureCommandHandler::m_ReadFunctions[] +{ + &TimelineCaptureCommandHandler::ReadLabel, // Label decl_id = 0 + &TimelineCaptureCommandHandler::ReadEntity, // Entity decl_id = 1 + &TimelineCaptureCommandHandler::ReadEventClass, // EventClass decl_id = 2 + &TimelineCaptureCommandHandler::ReadRelationship, // Relationship decl_id = 3 + &TimelineCaptureCommandHandler::ReadEvent // Event decl_id = 4 +}; + +void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet) +{ + uint32_t offset = 0; + + if (packet.GetLength() < 8) + { + return; + } + + const unsigned char* data = reinterpret_cast(packet.GetData()); + + uint32_t declId = 0; + + declId = profiling::ReadUint32(data, offset); + offset += uint32_t_size; + + (this->*m_ReadFunctions[declId])(data, offset); +} + +void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t offset) +{ + ITimelineDecoder::Label label; + label.m_Guid = profiling::ReadUint64(data, offset); + offset += uint64_t_size; + + uint32_t nameLength = profiling::ReadUint32(data, offset); + offset += uint32_t_size; + + for (uint32_t i = 0; i < nameLength-1; ++i) + { + label.m_Name += static_cast(profiling::ReadUint8(data, offset + i)); + } + m_TimelineDecoder.CreateLabel(label); +} + +void TimelineCaptureCommandHandler::ReadEntity(const unsigned char* data, uint32_t offset) +{ + ITimelineDecoder::Entity entity; + entity.m_Guid = profiling::ReadUint64(data, offset); + + m_TimelineDecoder.CreateEntity(entity); +} + +void TimelineCaptureCommandHandler::ReadEventClass(const unsigned char* data, uint32_t offset) +{ + ITimelineDecoder::EventClass eventClass; + eventClass.m_Guid = profiling::ReadUint64(data, offset); + + m_TimelineDecoder.CreateEventClass(eventClass); +} + +void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, uint32_t offset) +{ + ITimelineDecoder::Relationship relationship; + relationship.m_RelationshipType = + static_cast(profiling::ReadUint32(data, offset)); + offset += uint32_t_size; + + relationship.m_Guid = profiling::ReadUint64(data, offset); + offset += uint64_t_size; + + relationship.m_HeadGuid = profiling::ReadUint64(data, offset); + offset += uint64_t_size; + + relationship.m_TailGuid = profiling::ReadUint64(data, offset); + + m_TimelineDecoder.CreateRelationship(relationship); +} + +void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_t offset) +{ + ITimelineDecoder::Event event; + event.m_TimeStamp = profiling::ReadUint64(data, offset); + offset += uint64_t_size; + + if (m_ThreadIdSize == 4) + { + event.m_ThreadId = profiling::ReadUint32(data, offset); + } + else if (m_ThreadIdSize == 8) + { + event.m_ThreadId = profiling::ReadUint64(data, offset); + } + + offset += m_ThreadIdSize; + + event.m_Guid = profiling::ReadUint64(data, offset); + + m_TimelineDecoder.CreateEvent(event); +} + +void TimelineCaptureCommandHandler::operator()(const profiling::Packet& packet) +{ + ParseData(packet); +} + +} //namespace gatordmock + +} //namespace armnn -- cgit v1.2.1