diff options
author | Finn Williams <Finn.Williams@arm.com> | 2020-02-26 10:25:26 +0000 |
---|---|---|
committer | Jim Flynn <jim.flynn@arm.com> | 2020-03-04 14:24:29 +0000 |
commit | 8a2b4685fde869c46ad4ebb19cbfefc4adc2a654 (patch) | |
tree | 4f4c87fe502ebbc595ff60ee588183e3b230ad7c /tests/profiling | |
parent | a97a0be5f16cb876d7226b733ac6aaa3b79dabd3 (diff) | |
download | armnn-8a2b4685fde869c46ad4ebb19cbfefc4adc2a654.tar.gz |
IVGCVSW-4160 Make the ARM Developer Studio code a self contained build entity
!armnn:2773
Signed-off-by: Finn Williams <Finn.Williams@arm.com>
Change-Id: I246cf0de04a1d29dd135cb0fc7e55bc5f0d4b854
Diffstat (limited to 'tests/profiling')
9 files changed, 2 insertions, 1017 deletions
diff --git a/tests/profiling/gatordmock/tests/GatordMockTests.cpp b/tests/profiling/gatordmock/tests/GatordMockTests.cpp index fecfce42d0..78c6f117ac 100644 --- a/tests/profiling/gatordmock/tests/GatordMockTests.cpp +++ b/tests/profiling/gatordmock/tests/GatordMockTests.cpp @@ -9,6 +9,7 @@ #include <GatordMockService.hpp> #include <PeriodicCounterCaptureCommandHandler.hpp> #include <StreamMetadataCommandHandler.hpp> + #include <TimelineDirectoryCaptureCommandHandler.hpp> #include <test/ProfilingMocks.hpp> @@ -127,7 +128,7 @@ BOOST_AUTO_TEST_CASE(GatorDMockEndToEnd) profiling::DirectoryCaptureCommandHandler directoryCaptureCommandHandler( 0, 2, packetVersionResolver.ResolvePacketVersion(0, 2).GetEncodedValue(), true); - gatordmock::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler( + timelinedecoder::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler( 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(), true); // Register different derived functors diff --git a/tests/profiling/timelineDecoder/ITimelineDecoder.hpp b/tests/profiling/timelineDecoder/ITimelineDecoder.hpp deleted file mode 100644 index 7199b38d24..0000000000 --- a/tests/profiling/timelineDecoder/ITimelineDecoder.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright © 2020 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include <cstdint> -#include <string> - -class ITimelineDecoder -{ - -public: - - enum class ErrorCode - { - ErrorCode_Success, - ErrorCode_Fail - }; - - enum class RelationshipType - { - RetentionLink, /// Head retains(parents) Tail - ExecutionLink, /// Head execution start depends on Tail execution completion - DataLink, /// Head uses data of Tail - LabelLink /// Head uses label Tail (Tail MUST be a guid of a label). - }; - - struct Entity - { - uint64_t m_Guid; - }; - - struct EventClass - { - uint64_t m_Guid; - }; - - struct Event - { - uint64_t m_Guid; - uint64_t m_TimeStamp; - uint64_t m_ThreadId; - }; - - struct Label - { - uint64_t m_Guid; - std::string m_Name; - }; - - struct Relationship - { - RelationshipType m_RelationshipType; - uint64_t m_Guid; - uint64_t m_HeadGuid; - uint64_t m_TailGuid; - }; - - virtual ~ITimelineDecoder() = default; - - virtual ErrorCode CreateEntity(const Entity&) = 0; - virtual ErrorCode CreateEventClass(const EventClass&) = 0; - virtual ErrorCode CreateEvent(const Event&) = 0; - virtual ErrorCode CreateLabel(const Label&) = 0; - virtual ErrorCode CreateRelationship(const Relationship&) = 0; -};
\ No newline at end of file diff --git a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp deleted file mode 100644 index 1fd0d4745a..0000000000 --- a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "TimelineCaptureCommandHandler.hpp" - -#include <iostream> -#include <string> - -namespace armnn -{ - -namespace gatordmock -{ - -//Array of member functions, the array index matches the decl_id -const TimelineCaptureCommandHandler::ReadFunction TimelineCaptureCommandHandler::m_ReadFunctions[5] -{ - &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<const unsigned char*>(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<char>(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<ITimelineDecoder::RelationshipType>(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 diff --git a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp b/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp deleted file mode 100644 index 9cdbbdc32a..0000000000 --- a/tests/profiling/timelineDecoder/TimelineCaptureCommandHandler.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - -#include "ITimelineDecoder.hpp" - -#include <CommandHandlerFunctor.hpp> -#include <Packet.hpp> -#include <ProfilingUtils.hpp> - -namespace armnn -{ - -namespace gatordmock -{ - -class TimelineCaptureCommandHandler : public profiling::CommandHandlerFunctor -{ - // Utils - uint32_t uint32_t_size = sizeof(uint32_t); - uint32_t uint64_t_size = sizeof(uint64_t); - - using ReadFunction = void (TimelineCaptureCommandHandler::*)(const unsigned char*, uint32_t); - -public: - TimelineCaptureCommandHandler(uint32_t familyId, - uint32_t packetId, - uint32_t version, - ITimelineDecoder& timelineDecoder, - uint32_t threadId_size) - : CommandHandlerFunctor(familyId, packetId, version) - , m_TimelineDecoder(timelineDecoder) - , m_ThreadIdSize(threadId_size) - {} - - void operator()(const armnn::profiling::Packet& packet) override; - - void ReadLabel(const unsigned char* data, uint32_t offset); - void ReadEntity(const unsigned char* data, uint32_t offset); - void ReadEventClass(const unsigned char* data, uint32_t offset); - void ReadRelationship(const unsigned char* data, uint32_t offset); - void ReadEvent(const unsigned char* data, uint32_t offset); - -private: - void ParseData(const armnn::profiling::Packet& packet); - - ITimelineDecoder& m_TimelineDecoder; - const uint32_t m_ThreadIdSize; - static const ReadFunction m_ReadFunctions[]; -}; - -} //namespace gatordmock - -} //namespace armnn diff --git a/tests/profiling/timelineDecoder/TimelineDecoder.cpp b/tests/profiling/timelineDecoder/TimelineDecoder.cpp deleted file mode 100644 index 2924b7a287..0000000000 --- a/tests/profiling/timelineDecoder/TimelineDecoder.cpp +++ /dev/null @@ -1,285 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "TimelineDecoder.hpp" - -#include <ProfilingUtils.hpp> - -#include <iostream> -namespace armnn -{ -TimelineDecoder::ErrorCode TimelineDecoder::CreateEntity(const Entity &entity) -{ - if (m_OnNewEntityCallback == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEntityCallback(m_Model, entity); - - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::CreateEventClass(const EventClass &eventClass) -{ - if (m_OnNewEventClassCallback == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEventClassCallback(m_Model, eventClass); - - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::CreateEvent(const Event &event) -{ - if (m_OnNewEventCallback == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEventCallback(m_Model, event); - - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::CreateLabel(const Label &label) -{ - if (m_OnNewLabelCallback == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewLabelCallback(m_Model, label); - - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::CreateRelationship(const Relationship &relationship) -{ - if (m_OnNewRelationshipCallback == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewRelationshipCallback(m_Model, relationship); - return ErrorCode::ErrorCode_Success; -} - -const TimelineDecoder::Model &TimelineDecoder::GetModel() -{ - return m_Model; -} - -TimelineDecoder::ErrorCode TimelineDecoder::SetEntityCallback(OnNewEntityCallback cb) -{ - if (cb == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEntityCallback = cb; - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::SetEventClassCallback(OnNewEventClassCallback cb) -{ - if (cb == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEventClassCallback = cb; - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::SetEventCallback(OnNewEventCallback cb) -{ - if (cb == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewEventCallback = cb; - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::SetLabelCallback(OnNewLabelCallback cb) -{ - if (cb == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewLabelCallback = cb; - return ErrorCode::ErrorCode_Success; -} - -TimelineDecoder::ErrorCode TimelineDecoder::SetRelationshipCallback(OnNewRelationshipCallback cb) -{ - if (cb == nullptr) - { - return ErrorCode::ErrorCode_Fail; - } - m_OnNewRelationshipCallback = cb; - return ErrorCode::ErrorCode_Success; -} - -void TimelineDecoder::print() -{ - printLabels(); - printEntities(); - printEventClasses(); - printEvents(); - printRelationships(); -} - -void TimelineDecoder::printLabels() -{ - std::string header; - - header.append(profiling::CentreAlignFormatting("guid", 12)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("value", 30)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("LABELS", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - std::cout << header; - - for (uint32_t i = 0; i < m_Model.m_Labels.size(); ++i) - { - std::string body; - - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Labels[i].m_Guid), 12)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(m_Model.m_Labels[i].m_Name, 30)); - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - std::cout << body; - } -} - -void TimelineDecoder::printEntities() -{ - std::string header; - header.append(profiling::CentreAlignFormatting("guid", 12)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("ENTITIES", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - std::cout << header; - - for (uint32_t i = 0; i < m_Model.m_Entities.size(); ++i) - { - std::string body; - - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Entities[i].m_Guid), 12)); - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - std::cout << body; - } -} - -void TimelineDecoder::printEventClasses() -{ - std::string header; - header.append(profiling::CentreAlignFormatting("guid", 12)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("EVENT CLASSES", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - std::cout << header; - - for (uint32_t i = 0; i < m_Model.m_EventClasses.size(); ++i) - { - std::string body; - - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_EventClasses[i].m_Guid), 12)); - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - std::cout << body; - } -} - -void TimelineDecoder::printEvents() -{ - std::string header; - - header.append(profiling::CentreAlignFormatting("timestamp", 12)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("threadId", 12)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("eventGuid", 12)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("EVENTS", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - std::cout << header; - - for (uint32_t i = 0; i < m_Model.m_Events.size(); ++i) - { - std::string body; - - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_TimeStamp), 12)); - body.append(" | "); - - std::stringstream ss; - ss << m_Model.m_Events[i].m_ThreadId; - std::string threadId = ss.str();; - - body.append(profiling::CentreAlignFormatting(threadId, 12)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Events[i].m_Guid), 12)); - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - std::cout << body; - } -} - -void TimelineDecoder::printRelationships() -{ - std::string header; - header.append(profiling::CentreAlignFormatting("relationshipType", 20)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("relationshipGuid", 20)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("headGuid", 12)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("tailGuid", 12)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("RELATIONSHIPS", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - std::cout << header; - - for (uint32_t i = 0; i < m_Model.m_Relationships.size(); ++i) - { - std::string body; - - body.append( - profiling::CentreAlignFormatting(std::to_string(static_cast<unsigned int> - (m_Model.m_Relationships[i].m_RelationshipType)), - 20)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_Guid), 20)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_HeadGuid), 12)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(std::to_string(m_Model.m_Relationships[i].m_TailGuid), 12)); - body.append(" | "); - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - std::cout << body; - } -} -}
\ No newline at end of file diff --git a/tests/profiling/timelineDecoder/TimelineDecoder.hpp b/tests/profiling/timelineDecoder/TimelineDecoder.hpp deleted file mode 100644 index 81e6a95c09..0000000000 --- a/tests/profiling/timelineDecoder/TimelineDecoder.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// -// Copyright © 2020 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - -#include "ITimelineDecoder.hpp" -#include <vector> -namespace armnn -{ -class TimelineDecoder : public ITimelineDecoder -{ - -public: - - struct Model - { - std::vector<Entity> m_Entities; - std::vector<EventClass> m_EventClasses; - std::vector<Event> m_Events; - std::vector<Label> m_Labels; - std::vector<Relationship> m_Relationships; - }; - - using OnNewEntityCallback = void (*)(Model &, const Entity); - using OnNewEventClassCallback = void (*)(Model &, const EventClass); - using OnNewEventCallback = void (*)(Model &, const Event); - using OnNewLabelCallback = void (*)(Model &, const Label); - using OnNewRelationshipCallback = void (*)(Model &, const Relationship); - - virtual ErrorCode CreateEntity(const Entity &) override; - virtual ErrorCode CreateEventClass(const EventClass &) override; - virtual ErrorCode CreateEvent(const Event &) override; - virtual ErrorCode CreateLabel(const Label &) override; - virtual ErrorCode CreateRelationship(const Relationship &) override; - - const Model& GetModel(); - - - ErrorCode SetEntityCallback(const OnNewEntityCallback); - ErrorCode SetEventClassCallback(const OnNewEventClassCallback); - ErrorCode SetEventCallback(const OnNewEventCallback); - ErrorCode SetLabelCallback(const OnNewLabelCallback); - ErrorCode SetRelationshipCallback(const OnNewRelationshipCallback); - - void print(); - -private: - Model m_Model; - - OnNewEntityCallback m_OnNewEntityCallback; - OnNewEventClassCallback m_OnNewEventClassCallback; - OnNewEventCallback m_OnNewEventCallback; - OnNewLabelCallback m_OnNewLabelCallback; - OnNewRelationshipCallback m_OnNewRelationshipCallback; - - void printLabels(); - void printEntities(); - void printEventClasses(); - void printRelationships(); - void printEvents(); -}; -}
\ No newline at end of file diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp deleted file mode 100644 index f28c7b50bf..0000000000 --- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "TimelineDirectoryCaptureCommandHandler.hpp" - -#include <ProfilingUtils.hpp> - -#include <iostream> -#include <string> - -using namespace armnn::profiling; - -namespace armnn -{ - -namespace gatordmock -{ - -void TimelineDirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet) -{ - uint32_t offset = 0; - - if (packet.GetLength() < 8) - { - return; - } - - const unsigned char* data = packet.GetData(); - - m_SwTraceHeader.m_StreamVersion = ReadUint8(data, offset); - offset += uint8_t_size; - m_SwTraceHeader.m_PointerBytes = ReadUint8(data, offset); - offset += uint8_t_size; - m_SwTraceHeader.m_ThreadIdBytes = ReadUint8(data, offset); - offset += uint8_t_size; - - uint32_t numberOfDeclarations = profiling::ReadUint32(data, offset); - offset += uint32_t_size; - - for (uint32_t declaration = 0; declaration < numberOfDeclarations; ++declaration) - { - m_SwTraceMessages.push_back(profiling::ReadSwTraceMessage(data, offset)); - } -} - -void TimelineDirectoryCaptureCommandHandler::Print() -{ - std::string header; - - header.append(profiling::CentreAlignFormatting("decl_id", 12)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("decl_name", 20)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("ui_name", 20)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("arg_types", 16)); - header.append(" | "); - header.append(profiling::CentreAlignFormatting("arg_names", 80)); - header.append("\n"); - - std::cout << "\n" << "\n"; - std::cout << profiling::CentreAlignFormatting("SW DIRECTORY", static_cast<int>(header.size())); - std::cout << "\n"; - std::cout << std::string(header.size(), '=') << "\n"; - - std::cout << header; - - for (const auto& swTraceMessage : m_SwTraceMessages) - { - std::string body; - - body.append(profiling::CentreAlignFormatting(std::to_string(swTraceMessage.m_Id), 12)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(swTraceMessage.m_Name, 20)); - body.append(" | "); - body.append(profiling::CentreAlignFormatting(swTraceMessage.m_UiName, 20)); - body.append(" | "); - - std::string argTypes; - for (auto argType: swTraceMessage.m_ArgTypes) - { - argTypes += argType; - argTypes += " "; - } - body.append(profiling::CentreAlignFormatting(argTypes, 16)); - body.append(" | "); - - std::string argNames; - for (auto argName: swTraceMessage.m_ArgNames) - { - argNames += argName + " "; - } - body.append(profiling::CentreAlignFormatting(argNames, 80)); - - body.append("\n"); - - std::cout << std::string(body.size(), '-') << "\n"; - - std::cout << body; - } -} - -void TimelineDirectoryCaptureCommandHandler::operator()(const profiling::Packet& packet) -{ - ParseData(packet); - - if (!m_QuietOperation) - { - Print(); - } -} - -} //namespace gatordmock - -} //namespace armnn diff --git a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp b/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp deleted file mode 100644 index 36a82b5510..0000000000 --- a/tests/profiling/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#pragma once - - -#include <CommandHandlerFunctor.hpp> -#include <Packet.hpp> -#include <PacketBuffer.hpp> -#include <ProfilingUtils.hpp> - -namespace armnn -{ - -namespace gatordmock -{ - -class TimelineDirectoryCaptureCommandHandler : public profiling::CommandHandlerFunctor -{ - // Utils - uint32_t uint8_t_size = sizeof(uint8_t); - uint32_t uint32_t_size = sizeof(uint32_t); - -public: - TimelineDirectoryCaptureCommandHandler(uint32_t familyId, - uint32_t packetId, - uint32_t version, - bool quietOperation = false) - : CommandHandlerFunctor(familyId, packetId, version) - , m_QuietOperation(quietOperation) - {} - - void operator()(const armnn::profiling::Packet& packet) override; - - profiling::SwTraceHeader m_SwTraceHeader; - std::vector<profiling::SwTraceMessage> m_SwTraceMessages; - -private: - void ParseData(const armnn::profiling::Packet& packet); - void Print(); - - bool m_QuietOperation; -}; - -} //namespace gatordmock - -} //namespace armnn diff --git a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp b/tests/profiling/timelineDecoder/tests/TimelineTests.cpp deleted file mode 100644 index 5d3c3eaea9..0000000000 --- a/tests/profiling/timelineDecoder/tests/TimelineTests.cpp +++ /dev/null @@ -1,252 +0,0 @@ -// -// Copyright © 2019 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "../TimelineCaptureCommandHandler.hpp" -#include "../TimelineDirectoryCaptureCommandHandler.hpp" -#include "timelineDecoder/TimelineDecoder.hpp" - -#include <CommandHandlerFunctor.hpp> -#include <ProfilingService.hpp> -#include <PacketBuffer.hpp> -#include <TimelinePacketWriterFactory.hpp> - -#include <boost/test/test_tools.hpp> -#include <boost/test/unit_test_suite.hpp> - -BOOST_AUTO_TEST_SUITE(TimelineDecoderTests) - -using namespace armnn; - -void SendTimelinePacketToCommandHandler(const unsigned char* packetBuffer, - profiling::CommandHandlerFunctor &CommandHandler) -{ - uint32_t uint32_t_size = sizeof(uint32_t); - unsigned int offset = 0; - - uint32_t header[2]; - header[0] = profiling::ReadUint32(packetBuffer, offset); - offset += uint32_t_size; - header[1] = profiling::ReadUint32(packetBuffer, offset); - offset += uint32_t_size; - - uint32_t PacketDataLength = header[1] & 0x00FFFFFF; - - auto uniquePacketData = std::make_unique<unsigned char[]>(PacketDataLength); - std::memcpy(uniquePacketData.get(), packetBuffer + offset, PacketDataLength); - - armnn::profiling::Packet packet(header[0], PacketDataLength, uniquePacketData); - - BOOST_CHECK(std::memcmp(packetBuffer + offset, packet.GetData(), packet.GetLength()) == 0); - - CommandHandler(packet); -} - -void PushEntity(TimelineDecoder::Model& model, const ITimelineDecoder::Entity entity) -{ - model.m_Entities.emplace_back(entity); -} - -void PushEventClass(TimelineDecoder::Model& model, const ITimelineDecoder::EventClass eventClass) -{ - model.m_EventClasses.emplace_back(eventClass); -} - -void PushEvent(TimelineDecoder::Model& model, const ITimelineDecoder::Event event) -{ - model.m_Events.emplace_back(event); -} - -void PushLabel(TimelineDecoder::Model& model, const ITimelineDecoder::Label label) -{ - model.m_Labels.emplace_back(label); -} - -void PushRelationship(TimelineDecoder::Model& model, const ITimelineDecoder::Relationship relationship) -{ - model.m_Relationships.emplace_back(relationship); -} - -BOOST_AUTO_TEST_CASE(TimelineDirectoryTest) -{ - uint32_t uint8_t_size = sizeof(uint8_t); - uint32_t uint32_t_size = sizeof(uint32_t); - uint32_t uint64_t_size = sizeof(uint64_t); - uint32_t threadId_size = sizeof(std::thread::id); - - profiling::BufferManager bufferManager(5); - profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); - - std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket = - timelinePacketWriterFactory.GetSendTimelinePacket(); - - profiling::PacketVersionResolver packetVersionResolver; - - gatordmock::TimelineDirectoryCaptureCommandHandler timelineDirectoryCaptureCommandHandler( - 1, 0, packetVersionResolver.ResolvePacketVersion(1, 0).GetEncodedValue(), true); - - sendTimelinePacket->SendTimelineMessageDirectoryPackage(); - sendTimelinePacket->Commit(); - - std::vector<profiling::SwTraceMessage> swTraceBufferMessages; - - unsigned int offset = uint32_t_size * 2; - - std::unique_ptr<profiling::IPacketBuffer> packetBuffer = bufferManager.GetReadableBuffer(); - - uint8_t readStreamVersion = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readStreamVersion == 4); - offset += uint8_t_size; - uint8_t readPointerBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readPointerBytes == uint64_t_size); - offset += uint8_t_size; - uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset); - BOOST_CHECK(readThreadIdBytes == threadId_size); - offset += uint8_t_size; - - uint32_t declarationSize = profiling::ReadUint32(packetBuffer, offset); - offset += uint32_t_size; - for(uint32_t i = 0; i < declarationSize; ++i) - { - swTraceBufferMessages.push_back(profiling::ReadSwTraceMessage(packetBuffer->GetReadableData(), offset)); - } - - SendTimelinePacketToCommandHandler(packetBuffer->GetReadableData(), timelineDirectoryCaptureCommandHandler); - - for(uint32_t index = 0; index < declarationSize; ++index) - { - profiling::SwTraceMessage& bufferMessage = swTraceBufferMessages[index]; - profiling::SwTraceMessage& handlerMessage = timelineDirectoryCaptureCommandHandler.m_SwTraceMessages[index]; - - BOOST_CHECK(bufferMessage.m_Name == handlerMessage.m_Name); - BOOST_CHECK(bufferMessage.m_UiName == handlerMessage.m_UiName); - BOOST_CHECK(bufferMessage.m_Id == handlerMessage.m_Id); - - BOOST_CHECK(bufferMessage.m_ArgTypes.size() == handlerMessage.m_ArgTypes.size()); - for(uint32_t i = 0; i < bufferMessage.m_ArgTypes.size(); ++i) - { - BOOST_CHECK(bufferMessage.m_ArgTypes[i] == handlerMessage.m_ArgTypes[i]); - } - - BOOST_CHECK(bufferMessage.m_ArgNames.size() == handlerMessage.m_ArgNames.size()); - for(uint32_t i = 0; i < bufferMessage.m_ArgNames.size(); ++i) - { - BOOST_CHECK(bufferMessage.m_ArgNames[i] == handlerMessage.m_ArgNames[i]); - } - } -} - -BOOST_AUTO_TEST_CASE(TimelineCaptureTest) -{ - unsigned int threadIdSize = sizeof(std::thread::id); - profiling::BufferManager bufferManager(50); - profiling::TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); - - std::unique_ptr<profiling::ISendTimelinePacket> sendTimelinePacket = - timelinePacketWriterFactory.GetSendTimelinePacket(); - - profiling::PacketVersionResolver packetVersionResolver; - - TimelineDecoder timelineDecoder; - const TimelineDecoder::Model& model = timelineDecoder.GetModel(); - - gatordmock::TimelineCaptureCommandHandler timelineCaptureCommandHandler( - 1, 1, packetVersionResolver.ResolvePacketVersion(1, 1).GetEncodedValue(), timelineDecoder, threadIdSize); - - BOOST_CHECK(timelineDecoder.SetEntityCallback(PushEntity) == ITimelineDecoder::ErrorCode::ErrorCode_Success); - BOOST_CHECK( - timelineDecoder.SetEventClassCallback(PushEventClass )== ITimelineDecoder::ErrorCode::ErrorCode_Success); - BOOST_CHECK(timelineDecoder.SetEventCallback(PushEvent) == ITimelineDecoder::ErrorCode::ErrorCode_Success); - BOOST_CHECK(timelineDecoder.SetLabelCallback(PushLabel) == ITimelineDecoder::ErrorCode::ErrorCode_Success); - BOOST_CHECK( - timelineDecoder.SetRelationshipCallback(PushRelationship) == ITimelineDecoder::ErrorCode::ErrorCode_Success); - - const uint64_t entityGuid = 111111u ; - const uint64_t eventClassGuid = 22222u; - const uint64_t timestamp = 33333u; - const uint64_t eventGuid = 44444u; - - const std::thread::id threadId = std::this_thread::get_id(); - - // need to do a bit of work here to extract the value from threadId - unsigned char* uCharThreadId = new unsigned char[threadIdSize]();; - uint64_t uint64ThreadId; - - profiling::WriteBytes(uCharThreadId, 0, &threadId, threadIdSize); - - if (threadIdSize == 4) - { - uint64ThreadId = profiling::ReadUint32(uCharThreadId, 0); - } - else if (threadIdSize == 8) - { - uint64ThreadId = profiling::ReadUint64(uCharThreadId, 0); - } - delete[] uCharThreadId; - - const uint64_t labelGuid = 66666u; - std::string labelName = "test_label"; - - const uint64_t relationshipGuid = 77777u; - const uint64_t headGuid = 888888u; - const uint64_t tailGuid = 999999u; - - for (int i = 0; i < 10; ++i) - { - // Send entity - sendTimelinePacket->SendTimelineEntityBinaryPacket(entityGuid); - sendTimelinePacket->Commit(); - SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(), - timelineCaptureCommandHandler); - - // Send event class - sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassGuid); - sendTimelinePacket->Commit(); - SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(), - timelineCaptureCommandHandler); - - // Send event - sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventGuid); - sendTimelinePacket->Commit(); - SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(), - timelineCaptureCommandHandler); - - // Send label - sendTimelinePacket->SendTimelineLabelBinaryPacket(labelGuid, labelName); - sendTimelinePacket->Commit(); - SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(), - timelineCaptureCommandHandler); - - // Send relationship - profiling::ProfilingRelationshipType relationshipType = profiling::ProfilingRelationshipType::DataLink; - sendTimelinePacket->SendTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid); - sendTimelinePacket->Commit(); - SendTimelinePacketToCommandHandler(bufferManager.GetReadableBuffer()->GetReadableData(), - timelineCaptureCommandHandler); - } - - for (unsigned long i = 0; i < 10; ++i) - { - BOOST_CHECK(model.m_Entities[i].m_Guid == entityGuid); - - BOOST_CHECK(model.m_EventClasses[i].m_Guid == eventClassGuid); - - BOOST_CHECK(model.m_Events[i].m_TimeStamp == timestamp); - BOOST_CHECK(model.m_Events[i].m_ThreadId == uint64ThreadId); - BOOST_CHECK(model.m_Events[i].m_Guid == eventGuid); - - BOOST_CHECK(model.m_Labels[i].m_Guid == labelGuid); - BOOST_CHECK(model.m_Labels[i].m_Name == labelName); - - BOOST_CHECK(model.m_Relationships[i].m_RelationshipType == ITimelineDecoder::RelationshipType::DataLink); - BOOST_CHECK(model.m_Relationships[i].m_Guid == relationshipGuid); - BOOST_CHECK(model.m_Relationships[i].m_HeadGuid == headGuid); - BOOST_CHECK(model.m_Relationships[i].m_TailGuid == tailGuid); - } -} - -BOOST_AUTO_TEST_SUITE_END() |