From 97da5e2e6c8aaaf4249af60e8305431315226f15 Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Thu, 5 Mar 2020 16:25:28 +0000 Subject: IVGCVSW-4541 Modify Timeline Packet construction * Changed TimelinePacket encoding so that there is only one header for multiple timeline swtrace messages * Refactored function names to have more suitable description * Refactored CodeStyle to coincide with ArmNN coding standards * Refactored profiling test names to be descriptive * Refactored ErrorCode name to TimelineStatus * Updated existing unit tests Signed-off-by: Keith Davis Change-Id: I83bd4bb9e7393617bca97eba96a6e1388916e5b0 --- src/profiling/test/ProfilingTestUtils.cpp | 1299 ++++++++++---------- src/profiling/test/ProfilingTestUtils.hpp | 38 +- src/profiling/test/SendTimelinePacketTests.cpp | 43 +- src/profiling/test/TimelinePacketTests.cpp | 443 +++---- src/profiling/test/TimelineUtilityMethodsTests.cpp | 359 +++--- 5 files changed, 991 insertions(+), 1191 deletions(-) (limited to 'src/profiling/test') diff --git a/src/profiling/test/ProfilingTestUtils.cpp b/src/profiling/test/ProfilingTestUtils.cpp index dd54ca9ebc..89b5926da7 100644 --- a/src/profiling/test/ProfilingTestUtils.cpp +++ b/src/profiling/test/ProfilingTestUtils.cpp @@ -25,19 +25,16 @@ inline unsigned int OffsetToNextWord(unsigned int numberOfBytes) return numberOfBytes + uint32_t_size - remainder; } -void VerifyTimelineLabelBinaryPacket(Optional guid, - const std::string& label, - const unsigned char* readableData, - unsigned int& offset) +void VerifyTimelineHeaderBinary(const unsigned char* readableData, + unsigned int& offset, + uint32_t packetDataLength) { BOOST_ASSERT(readableData); // Utils unsigned int uint32_t_size = sizeof(uint32_t); - unsigned int uint64_t_size = sizeof(uint64_t); - unsigned int label_size = boost::numeric_cast(label.size()); - // Check the TimelineLabelBinaryPacket header + // Check the TimelineEventClassBinaryPacket header uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; @@ -52,10 +49,23 @@ void VerifyTimelineLabelBinaryPacket(Optional guid, uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; BOOST_CHECK(eventBinaryPacketSequenceNumber == 0); - BOOST_CHECK(eventBinaryPacketDataLength == 16 + OffsetToNextWord(label_size + 1)); + BOOST_CHECK(eventBinaryPacketDataLength == packetDataLength); + offset += uint32_t_size; +} + +void VerifyTimelineLabelBinaryPacketData(Optional guid, + const std::string& label, + const unsigned char* readableData, + unsigned int& offset) +{ + BOOST_ASSERT(readableData); + + // Utils + unsigned int uint32_t_size = sizeof(uint32_t); + unsigned int uint64_t_size = sizeof(uint64_t); + unsigned int label_size = boost::numeric_cast(label.size()); // Check the decl id - offset += uint32_t_size; uint32_t eventClassDeclId = ReadUint32(readableData, offset); BOOST_CHECK(eventClassDeclId == 0); @@ -74,20 +84,19 @@ void VerifyTimelineLabelBinaryPacket(Optional guid, // Check the SWTrace label offset += uint64_t_size; uint32_t swTraceLabelLength = ReadUint32(readableData, offset); - BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator + BOOST_CHECK(swTraceLabelLength == label_size + 1); // Label length including the null-terminator offset += uint32_t_size; BOOST_CHECK(std::memcmp(readableData + offset, // Offset to the label in the buffer - label.data(), // The original label - swTraceLabelLength - 1) == 0); // The length of the label - BOOST_CHECK(readableData[offset + swTraceLabelLength] == '\0'); // The null-terminator + label.data(), // The original label + swTraceLabelLength - 1) == 0); // The length of the label // SWTrace strings are written in blocks of words, so the offset has to be updated to the next whole word offset += OffsetToNextWord(swTraceLabelLength); } -void VerifyTimelineEventClassBinaryPacket(ProfilingGuid guid, - const unsigned char* readableData, - unsigned int& offset) +void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, + const unsigned char* readableData, + unsigned int& offset) { BOOST_ASSERT(readableData); @@ -95,25 +104,7 @@ void VerifyTimelineEventClassBinaryPacket(ProfilingGuid guid, unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - // Check the TimelineEventClassBinaryPacket header - uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; - uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(entityBinaryPacketFamily == 1); - BOOST_CHECK(entityBinaryPacketClass == 0); - BOOST_CHECK(entityBinaryPacketType == 1); - BOOST_CHECK(entityBinaryPacketStreamId == 0); - offset += uint32_t_size; - uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset); - uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; - uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(eventBinaryPacketSequenceNumber == 0); - BOOST_CHECK(eventBinaryPacketDataLength == 12); - // Check the decl id - offset += uint32_t_size; uint32_t eventClassDeclId = ReadUint32(readableData, offset); BOOST_CHECK(eventClassDeclId == 2); @@ -126,7 +117,7 @@ void VerifyTimelineEventClassBinaryPacket(ProfilingGuid guid, offset += uint64_t_size; } -void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, +void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, Optional relationshipGuid, Optional headGuid, Optional tailGuid, @@ -158,25 +149,7 @@ void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationsh unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - // Check the TimelineLabelBinaryPacket header - uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; - uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(entityBinaryPacketFamily == 1); - BOOST_CHECK(entityBinaryPacketClass == 0); - BOOST_CHECK(entityBinaryPacketType == 1); - BOOST_CHECK(entityBinaryPacketStreamId == 0); - offset += uint32_t_size; - uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset); - uint32_t eventBinaryPacketSequenceNumber = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; - uint32_t eventBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(eventBinaryPacketSequenceNumber == 0); - BOOST_CHECK(eventBinaryPacketDataLength == 32); - // Check the decl id - offset += uint32_t_size; uint32_t eventClassDeclId = ReadUint32(readableData, offset); BOOST_CHECK(eventClassDeclId == 3); @@ -225,9 +198,9 @@ void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationsh offset += uint64_t_size; } -void VerifyTimelineEntityBinaryPacket(Optional guid, - const unsigned char* readableData, - unsigned int& offset) +void VerifyTimelineEntityBinaryPacketData(Optional guid, + const unsigned char* readableData, + unsigned int& offset) { BOOST_ASSERT(readableData); @@ -236,26 +209,7 @@ void VerifyTimelineEntityBinaryPacket(Optional guid, unsigned int uint64_t_size = sizeof(uint64_t); // Reading TimelineEntityClassBinaryPacket - uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; - uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; - - BOOST_CHECK(entityBinaryPacketFamily == 1); - BOOST_CHECK(entityBinaryPacketClass == 0); - BOOST_CHECK(entityBinaryPacketType == 1); - BOOST_CHECK(entityBinaryPacketStreamId == 0); - - offset += uint32_t_size; - uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; - uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0); - BOOST_CHECK(entityBinaryPacketDataLength == 12); - // Check the decl_id - offset += uint32_t_size; uint32_t entityDeclId = ReadUint32(readableData, offset); BOOST_CHECK(entityDeclId == 1); @@ -289,26 +243,7 @@ void VerifyTimelineEventBinaryPacket(Optional timestamp, unsigned int threadId_size = sizeof(std::thread::id); // Reading TimelineEventBinaryPacket - uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; - uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; - - BOOST_CHECK(entityBinaryPacketFamily == 1); - BOOST_CHECK(entityBinaryPacketClass == 0); - BOOST_CHECK(entityBinaryPacketType == 1); - BOOST_CHECK(entityBinaryPacketStreamId == 0); - - offset += uint32_t_size; - uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(readableData, offset); - uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; - uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0); - BOOST_CHECK(entityBinaryPacketDataLength == 20 + threadId_size); - // Check the decl_id - offset += uint32_t_size; uint32_t entityDeclId = ReadUint32(readableData, offset); BOOST_CHECK(entityDeclId == 4); @@ -368,18 +303,18 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) // Convolution details TensorInfo inputInfo({ 1, 2, 5, 1 }, DataType::Float32); - TensorInfo weightInfo({ 3, 2, 3, 1}, DataType::Float32); + TensorInfo weightInfo({ 3, 2, 3, 1 }, DataType::Float32); TensorInfo biasInfo({ 3 }, DataType::Float32); - TensorInfo outputInfo({ 1, 3, 7, 1}, DataType::Float32); + TensorInfo outputInfo({ 1, 3, 7, 1 }, DataType::Float32); std::vector weightsData{ - 1.0f, 0.0f, 0.0f, - 0.0f, 2.0f, -1.5f, + 1.0f, 0.0f, 0.0f, + 0.0f, 2.0f, -1.5f, - 0.0f, 0.0f, 0.0f, - 0.2f, 0.2f, 0.2f, + 0.0f, 0.0f, 0.0f, + 0.2f, 0.2f, 0.2f, - 0.5f, 0.0f, 0.5f, - 0.0f, -1.0f, 0.0f + 0.5f, 0.0f, 0.5f, + 0.0f, -1.0f, 0.0f }; ConstTensor weights(weightInfo, weightsData); @@ -393,8 +328,8 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) // Convolution2d layer Convolution2dDescriptor conv2dDesc; - conv2dDesc.m_StrideX = 1; - conv2dDesc.m_StrideY = 1; + conv2dDesc.m_StrideX = 1; + conv2dDesc.m_StrideY = 1; conv2dDesc.m_PadLeft = 0; conv2dDesc.m_PadRight = 0; conv2dDesc.m_PadTop = 2; @@ -435,386 +370,389 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_CHECK(size == 1980); + BOOST_CHECK(size == 1556); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); unsigned int offset = 0; + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 1548); + // Post-optimisation network // Network entity - VerifyTimelineEntityBinaryPacket(optNetGuid, readableData, offset); + VerifyTimelineEntityBinaryPacketData(optNetGuid, readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - optNetGuid, - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + optNetGuid, + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Input layer // Input layer entity - VerifyTimelineEntityBinaryPacket(input->GetGuid(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(input->GetGuid(), readableData, offset); // Name Entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), "input", readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "input", readableData, offset); // Entity - Name relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - input->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + input->GetGuid(), + EmptyOptional(), + readableData, + offset); // Name label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - input->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + input->GetGuid(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Network - Input layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - optNetGuid, - input->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + optNetGuid, + input->GetGuid(), + readableData, + offset); // Conv2d layer // Conv2d layer entity - VerifyTimelineEntityBinaryPacket(conv2d->GetGuid(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(conv2d->GetGuid(), readableData, offset); // Name entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), "", readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "", readableData, offset); // Entity - Name relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - conv2d->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + conv2d->GetGuid(), + EmptyOptional(), + readableData, + offset); // Name label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - conv2d->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + conv2d->GetGuid(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Network - Conv2d layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - optNetGuid, - conv2d->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + optNetGuid, + conv2d->GetGuid(), + readableData, + offset); // Input layer - Conv2d layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - input->GetGuid(), - conv2d->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + input->GetGuid(), + conv2d->GetGuid(), + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::CONNECTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::CONNECTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Conv2d workload // Conv2d workload entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // BackendId entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), backendId.Get(), readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); // Entity - BackendId relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // BackendId label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::BACKENDID_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::BACKENDID_GUID, + readableData, + offset); // Conv2d layer - Conv2d workload relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - conv2d->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + conv2d->GetGuid(), + EmptyOptional(), + readableData, + offset); // Activation layer // Activation layer entity - VerifyTimelineEntityBinaryPacket(activation->GetGuid(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(activation->GetGuid(), readableData, offset); // Name entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), "activation", readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "activation", readableData, offset); // Entity - Name relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - activation->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + activation->GetGuid(), + EmptyOptional(), + readableData, + offset); // Name label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - activation->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + activation->GetGuid(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Network - Activation layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - optNetGuid, - activation->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + optNetGuid, + activation->GetGuid(), + readableData, + offset); // Conv2d layer - Activation layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - conv2d->GetGuid(), - activation->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + conv2d->GetGuid(), + activation->GetGuid(), + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::CONNECTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::CONNECTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Activation workload // Activation workload entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // BackendId entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), backendId.Get(), readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); // Entity - BackendId relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // BackendId label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::BACKENDID_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::BACKENDID_GUID, + readableData, + offset); // Activation layer - Activation workload relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - activation->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + activation->GetGuid(), + EmptyOptional(), + readableData, + offset); // Output layer // Output layer entity - VerifyTimelineEntityBinaryPacket(output->GetGuid(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(output->GetGuid(), readableData, offset); // Name entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), "output", readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), "output", readableData, offset); // Entity - Name relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - output->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + output->GetGuid(), + EmptyOptional(), + readableData, + offset); // Name label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - output->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + output->GetGuid(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Network - Output layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - optNetGuid, - output->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + optNetGuid, + output->GetGuid(), + readableData, + offset); // Activation layer - Output layer relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - activation->GetGuid(), - output->GetGuid(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + activation->GetGuid(), + output->GetGuid(), + readableData, + offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::CONNECTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::CONNECTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); bufferManager.MarkRead(readableBuffer); @@ -823,13 +761,13 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) std::vector outputData(outputInfo.GetNumElements()); InputTensors inputTensors - { - {0, ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data())} - }; + { + { 0, ConstTensor(runtime->GetInputTensorInfo(netId, 0), inputData.data()) } + }; OutputTensors outputTensors - { - {0, Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data())} - }; + { + { 0, Tensor(runtime->GetOutputTensorInfo(netId, 0), outputData.data()) } + }; // Does the inference. runtime->EnqueueWorkload(netId, inputTensors, outputTensors); @@ -848,501 +786,510 @@ void VerifyPostOptimisationStructureTestImpl(armnn::BackendId backendId) // Validate input workload data size = inputReadableBuffer->GetSize(); - BOOST_CHECK(size == 252); + BOOST_CHECK(size == 204); readableData = inputReadableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); offset = 0; + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 196); + // Input workload // Input workload entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // BackendId entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), backendId.Get(), readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); // Entity - BackendId relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // BackendId label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::BACKENDID_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::BACKENDID_GUID, + readableData, + offset); // Input layer - Input workload relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - input->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + input->GetGuid(), + EmptyOptional(), + readableData, + offset); bufferManager.MarkRead(inputReadableBuffer); // Validate output workload data size = outputReadableBuffer->GetSize(); - BOOST_CHECK(size == 252); + BOOST_CHECK(size == 204); readableData = outputReadableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); offset = 0; + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 196); + // Output workload // Output workload entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // BackendId entity - VerifyTimelineLabelBinaryPacket(EmptyOptional(), backendId.Get(), readableData, offset); + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), backendId.Get(), readableData, offset); // Entity - BackendId relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // BackendId label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::BACKENDID_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::BACKENDID_GUID, + readableData, + offset); // Output layer - Output workload relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - output->GetGuid(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + output->GetGuid(), + EmptyOptional(), + readableData, + offset); bufferManager.MarkRead(outputReadableBuffer); // Validate inference data size = inferenceReadableBuffer->GetSize(); - BOOST_CHECK(size == 2020); + BOOST_CHECK(size == 1596); readableData = inferenceReadableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); offset = 0; + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 1588); + // Inference timeline trace // Inference entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::INFERENCE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::INFERENCE_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Network - Inference relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - optNetGuid, - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + optNetGuid, + EmptyOptional(), + readableData, + offset); // Start Inference life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Inference - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // Execution // Input workload execution // Input workload execution entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Inference - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Workload - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Start Input workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Input workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // End of Input workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Input workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); // Conv2d workload execution // Conv2d workload execution entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Inference - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Workload - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Start Conv2d workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Conv2d workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // End of Conv2d workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Conv2d workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); // Activation workload execution // Activation workload execution entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Inference - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Workload - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Start Activation workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Activation workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // End of Activation workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Activation workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); // Output workload execution // Output workload execution entity - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); // Entity - Type relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, + readableData, + offset); // Type label relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Inference - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Workload - Workload execution relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Start Output workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Output workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // End of Normalize workload execution life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Output workload execution - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); // End of Inference life // Event packet - timeline, threadId, eventGuid VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); // Inference - event relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); // Event - event class relationship - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); bufferManager.MarkRead(inferenceReadableBuffer); } diff --git a/src/profiling/test/ProfilingTestUtils.hpp b/src/profiling/test/ProfilingTestUtils.hpp index 7fb5d62591..175c9cc167 100644 --- a/src/profiling/test/ProfilingTestUtils.hpp +++ b/src/profiling/test/ProfilingTestUtils.hpp @@ -18,26 +18,30 @@ using namespace armnn::profiling; inline unsigned int OffsetToNextWord(unsigned int numberOfBytes); -void VerifyTimelineLabelBinaryPacket(Optional guid, - const std::string& label, - const unsigned char* readableData, - unsigned int& offset); - -void VerifyTimelineEventClassBinaryPacket(ProfilingGuid guid, +void VerifyTimelineHeaderBinary(const unsigned char* readableData, + unsigned int& offset, + uint32_t packetDataLength); + +void VerifyTimelineLabelBinaryPacketData(Optional guid, + const std::string& label, + const unsigned char* readableData, + unsigned int& offset); + +void VerifyTimelineEventClassBinaryPacketData(ProfilingGuid guid, + const unsigned char* readableData, + unsigned int& offset); + +void VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType relationshipType, + Optional relationshipGuid, + Optional headGuid, + Optional tailGuid, + const unsigned char* readableData, + unsigned int& offset); + +void VerifyTimelineEntityBinaryPacketData(Optional guid, const unsigned char* readableData, unsigned int& offset); -void VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, - Optional relationshipGuid, - Optional headGuid, - Optional tailGuid, - const unsigned char* readableData, - unsigned int& offset); - -void VerifyTimelineEntityBinaryPacket(Optional guid, - const unsigned char* readableData, - unsigned int& offset); - void VerifyTimelineEventBinaryPacket(Optional timestamp, Optional threadId, Optional eventGuid, diff --git a/src/profiling/test/SendTimelinePacketTests.cpp b/src/profiling/test/SendTimelinePacketTests.cpp index af15c57117..2e64c75b90 100644 --- a/src/profiling/test/SendTimelinePacketTests.cpp +++ b/src/profiling/test/SendTimelinePacketTests.cpp @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest) BOOST_CHECK(swTraceMessage.m_ArgNames[2] == "eventGuid"); } -BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest) +BOOST_AUTO_TEST_CASE(SendTimelineEntityWithEventClassPacketTest) { MockBufferManager bufferManager(40); TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager); @@ -159,23 +159,26 @@ BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest) unsigned int offset = 0; // Reading TimelineEntityClassBinaryPacket - uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); - uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; + uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); + uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F; + uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F; + uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007; uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(entityBinaryPacketFamily == 1); - BOOST_CHECK(entityBinaryPacketClass == 0); - BOOST_CHECK(entityBinaryPacketType == 1); + BOOST_CHECK(entityBinaryPacketFamily == 1); + BOOST_CHECK(entityBinaryPacketClass == 0); + BOOST_CHECK(entityBinaryPacketType == 1); BOOST_CHECK(entityBinaryPacketStreamId == 0); offset += uint32_t_size; - uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); + + uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); + uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001; uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; + BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0); - BOOST_CHECK(entityBinaryPacketDataLength == 12); + BOOST_CHECK(entityBinaryPacketDataLength == 24); // Check the decl_id offset += uint32_t_size; @@ -191,25 +194,7 @@ BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest) // Reading TimelineEventClassBinaryPacket offset += uint64_t_size; - uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset); - uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F; - uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F; - uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007; - uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007; - - BOOST_CHECK(eventClassBinaryPacketFamily == 1); - BOOST_CHECK(eventClassBinaryPacketClass == 0); - BOOST_CHECK(eventClassBinaryPacketType == 1); - BOOST_CHECK(eventClassBinaryPacketStreamId == 0); - offset += uint32_t_size; - uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset); - uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001; - uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0); - BOOST_CHECK(eventClassBinaryPacketDataLength == 12); - - offset += uint32_t_size; uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset); BOOST_CHECK(eventClassDeclId == uint32_t(2)); @@ -221,7 +206,7 @@ BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest) bufferManager.MarkRead(packetBuffer); } -BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1) +BOOST_AUTO_TEST_CASE(SendEventClassAfterTimelineEntityPacketTest) { unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); diff --git a/src/profiling/test/TimelinePacketTests.cpp b/src/profiling/test/TimelinePacketTests.cpp index 824f055a41..1d5d45176c 100644 --- a/src/profiling/test/TimelinePacketTests.cpp +++ b/src/profiling/test/TimelinePacketTests.cpp @@ -12,7 +12,7 @@ using namespace armnn::profiling; BOOST_AUTO_TEST_SUITE(TimelinePacketTests) -BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest1) +BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestNoBuffer) { const uint64_t profilingGuid = 123456u; const std::string label = "some label"; @@ -26,7 +26,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest1) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest2) +BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionZeroValue) { std::vector buffer(512, 0); @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest2) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest3) +BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestBufferExhaustionFixedValue) { std::vector buffer(10, 0); @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest3) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest4) +BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestInvalidLabel) { std::vector buffer(512, 0); @@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest4) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest5) +BOOST_AUTO_TEST_CASE(TimelineLabelPacketTestSingleConstructionOfData) { std::vector buffer(512, 0); @@ -87,32 +87,13 @@ BOOST_AUTO_TEST_CASE(TimelineLabelPacketTest5) boost::numeric_cast(buffer.size()), numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 36); + BOOST_CHECK(numberOfBytesWritten == 28); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 28); - - // Check decl_Id - offset += uint32_t_size; uint32_t decl_Id = ReadUint32(buffer.data(), offset); BOOST_CHECK(decl_Id == uint32_t(0)); @@ -142,13 +123,13 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketNullBufferTest) const uint64_t headGuid = 234567u; const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - nullptr, - 512u, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + nullptr, + 512u, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } @@ -162,13 +143,13 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketZeroBufferSizeTest) const uint64_t headGuid = 234567u; const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - 0, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + 0, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } @@ -183,13 +164,13 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketSmallBufferSizeTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = - WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } @@ -203,19 +184,19 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketInvalidRelationTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; - BOOST_CHECK_THROW(WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten), - armnn::InvalidArgumentException); + BOOST_CHECK_THROW(WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten), + armnn::InvalidArgumentException); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTest) +BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTestDataConstruction) { std::vector buffer(512, 0); @@ -225,40 +206,22 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = - WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 40); + BOOST_CHECK(numberOfBytesWritten == 32); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 32); - // Check the decl_id - offset += uint32_t_size; uint32_t readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 3); @@ -283,7 +246,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketTest) BOOST_CHECK(readTailGuid == tailGuid); } -BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTest) +BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTestDataConstruction) { std::vector buffer(512, 0); @@ -293,40 +256,20 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = - WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 40); + BOOST_CHECK(numberOfBytesWritten == 32); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 32); - - // Check the decl_id - offset += uint32_t_size; uint32_t readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 3); @@ -352,7 +295,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketExecutionLinkTest) } -BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTest) +BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTestDataConstruction) { std::vector buffer(512, 0); @@ -362,40 +305,20 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = - WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 40); + BOOST_CHECK(numberOfBytesWritten == 32); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); - // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 32); - - // Check the decl_id - offset += uint32_t_size; uint32_t readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 3); @@ -421,7 +344,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketDataLinkTest) } -BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTest) +BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTestDataConstruction) { std::vector buffer(512, 0); @@ -431,40 +354,21 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTest) const uint64_t tailGuid = 345678u; unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = - WriteTimelineRelationshipBinaryPacket(relationshipType, - relationshipGuid, - headGuid, - tailGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + WriteTimelineRelationshipBinary(relationshipType, + relationshipGuid, + headGuid, + tailGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 40); + BOOST_CHECK(numberOfBytesWritten == 32); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 32); - - // Check the decl_id - offset += uint32_t_size; uint32_t readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 3); @@ -489,7 +393,7 @@ BOOST_AUTO_TEST_CASE(TimelineRelationshipPacketLabelLinkTest) BOOST_CHECK(readTailGuid == tailGuid); } -BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest1) +BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestNoBuffer) { unsigned int numberOfBytesWritten = 789u; TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(nullptr, @@ -499,7 +403,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest1) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest2) +BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestBufferExhausted) { std::vector buffer(512, 0); @@ -511,7 +415,7 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest2) BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest3) +BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTestFullConstruction) { std::vector buffer(512, 0); unsigned int numberOfBytesWritten = 789u; @@ -636,82 +540,63 @@ BOOST_AUTO_TEST_CASE(TimelineMessageDirectoryPacketTest3) swTraceDeclNameLength - 1) == 0); // The length of the label } -BOOST_AUTO_TEST_CASE(TimelineEntityPacketTest1) +BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestNoBuffer) { const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEntityBinaryPacket(profilingGuid, - nullptr, - 512u, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, + nullptr, + 512u, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEntityPacketTest2) +BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithZeroBufferSize) { std::vector buffer(512, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEntityBinaryPacket(profilingGuid, - buffer.data(), - 0, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, + buffer.data(), + 0, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEntityPacketTest3) +BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestBufferExhaustedWithFixedBufferSize) { std::vector buffer(10, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEntityBinaryPacket(profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEntityPacketTest4) +BOOST_AUTO_TEST_CASE(TimelineEntityPacketTestFullConstructionOfData) { std::vector buffer(512, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEntityBinaryPacket(profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEntityBinary(profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 20); + BOOST_CHECK(numberOfBytesWritten == 12); unsigned int uint32_t_size = sizeof(uint32_t); - // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 12); - // Check decl_Id - offset += uint32_t_size; uint32_t decl_Id = ReadUint32(buffer.data(), offset); BOOST_CHECK(decl_Id == uint32_t(1)); @@ -721,82 +606,63 @@ BOOST_AUTO_TEST_CASE(TimelineEntityPacketTest4) BOOST_CHECK(readProfilingGuid == profilingGuid); } -BOOST_AUTO_TEST_CASE(TimelineEventClassTest1) +BOOST_AUTO_TEST_CASE(TimelineEventClassTestNoBuffer) { const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventClassBinaryPacket(profilingGuid, - nullptr, - 512u, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, + nullptr, + 512u, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventClassTest2) +BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionZeroValue) { std::vector buffer(512, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventClassBinaryPacket(profilingGuid, - buffer.data(), - 0, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, + buffer.data(), + 0, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventClassTest3) +BOOST_AUTO_TEST_CASE(TimelineEventClassTestBufferExhaustionFixedValue) { std::vector buffer(10, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventClassBinaryPacket(profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventClassTest4) +BOOST_AUTO_TEST_CASE(TimelineEventClassTestFullConstructionOfData) { std::vector buffer(512, 0); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventClassBinaryPacket(profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventClassBinary(profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 20); + BOOST_CHECK(numberOfBytesWritten == 12); unsigned int uint32_t_size = sizeof(uint32_t); - // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 12); - // Check the decl_id - offset += uint32_t_size; uint32_t declId = ReadUint32(buffer.data(), offset); BOOST_CHECK(declId == uint32_t(2)); @@ -806,23 +672,23 @@ BOOST_AUTO_TEST_CASE(TimelineEventClassTest4) BOOST_CHECK(readProfilingGuid == profilingGuid); } -BOOST_AUTO_TEST_CASE(TimelineEventPacketTest1) +BOOST_AUTO_TEST_CASE(TimelineEventPacketTestNoBuffer) { const uint64_t timestamp = 456789u; const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, - threadId, - profilingGuid, - nullptr, - 512u, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, + threadId, + profilingGuid, + nullptr, + 512u, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventPacketTest2) +BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionZeroValue) { std::vector buffer(512, 0); @@ -830,17 +696,17 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest2) const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, - threadId, - profilingGuid, - buffer.data(), - 0, - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, + threadId, + profilingGuid, + buffer.data(), + 0, + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventPacketTest3) +BOOST_AUTO_TEST_CASE(TimelineEventPacketTestBufferExhaustionFixedValue) { std::vector buffer(10, 0); @@ -848,17 +714,17 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest3) const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, - threadId, - profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, + threadId, + profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion); BOOST_CHECK(numberOfBytesWritten == 0); } -BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) +BOOST_AUTO_TEST_CASE(TimelineEventPacketTestFullConstructionOfData) { std::vector buffer(512, 0); @@ -866,40 +732,21 @@ BOOST_AUTO_TEST_CASE(TimelineEventPacketTest4) const std::thread::id threadId = std::this_thread::get_id(); const uint64_t profilingGuid = 123456u; unsigned int numberOfBytesWritten = 789u; - TimelinePacketStatus result = WriteTimelineEventBinaryPacket(timestamp, - threadId, - profilingGuid, - buffer.data(), - boost::numeric_cast(buffer.size()), - numberOfBytesWritten); + TimelinePacketStatus result = WriteTimelineEventBinary(timestamp, + threadId, + profilingGuid, + buffer.data(), + boost::numeric_cast(buffer.size()), + numberOfBytesWritten); BOOST_CHECK(result == TimelinePacketStatus::Ok); - BOOST_CHECK(numberOfBytesWritten == 36); + BOOST_CHECK(numberOfBytesWritten == 28); unsigned int uint32_t_size = sizeof(uint32_t); unsigned int uint64_t_size = sizeof(uint64_t); unsigned int threadId_size = sizeof(std::thread::id); - // Check the packet header unsigned int offset = 0; - uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset); - uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F; - uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F; - uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007; - uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007; - BOOST_CHECK(packetFamily == 1); - BOOST_CHECK(packetClass == 0); - BOOST_CHECK(packetType == 1); - BOOST_CHECK(streamId == 0); - - offset += uint32_t_size; - uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset); - uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001; - uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF; - BOOST_CHECK(sequenceNumbered == 0); - BOOST_CHECK(dataLength == 28); - // Check the decl_id - offset += uint32_t_size; uint32_t readDeclId = ReadUint32(buffer.data(), offset); BOOST_CHECK(readDeclId == 4); diff --git a/src/profiling/test/TimelineUtilityMethodsTests.cpp b/src/profiling/test/TimelineUtilityMethodsTests.cpp index efceff2859..fed31c3def 100644 --- a/src/profiling/test/TimelineUtilityMethodsTests.cpp +++ b/src/profiling/test/TimelineUtilityMethodsTests.cpp @@ -42,31 +42,34 @@ BOOST_AUTO_TEST_CASE(CreateTypedLabelTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_CHECK(size == 116); + BOOST_CHECK(size == 100); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); // Utils unsigned int offset = 0; - // First packet sent: TimelineLabelBinaryPacket - VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityName, readableData, offset); - - // Second packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - entityGuid, - EmptyOptional(), - readableData, - offset); - - // Third packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - labelTypeGuid, - readableData, - offset); + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 92); + + // First dataset sent: TimelineLabelBinaryPacket + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset); + + // Second dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + entityGuid, + EmptyOptional(), + readableData, + offset); + + // Third dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + labelTypeGuid, + readableData, + offset); // Mark the buffer as read mockBufferManager.MarkRead(readableBuffer); @@ -87,81 +90,86 @@ BOOST_AUTO_TEST_CASE(SendWellKnownLabelsAndEventClassesTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_TEST(size == 388); + BOOST_TEST(size == 300); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); // Utils unsigned int offset = 0; + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 292); + // First "well-known" label: NAME - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::NAME_GUID, - LabelsAndEventClasses::NAME_LABEL, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::NAME_GUID, + LabelsAndEventClasses::NAME_LABEL, + readableData, + offset); // Second "well-known" label: TYPE - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::TYPE_GUID, - LabelsAndEventClasses::TYPE_LABEL, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::TYPE_GUID, + LabelsAndEventClasses::TYPE_LABEL, + readableData, + offset); // Third "well-known" label: INDEX - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::INDEX_GUID, - LabelsAndEventClasses::INDEX_LABEL, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::INDEX_GUID, + LabelsAndEventClasses::INDEX_LABEL, + readableData, + offset); // Forth "well-known" label: BACKENDID - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::BACKENDID_GUID, - LabelsAndEventClasses::BACKENDID_LABEL, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::BACKENDID_GUID, + LabelsAndEventClasses::BACKENDID_LABEL, + readableData, + offset); // Well-known types // Layer - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::LAYER_GUID, - LabelsAndEventClasses::LAYER, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::LAYER_GUID, + LabelsAndEventClasses::LAYER, + readableData, + offset); // Workload - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::WORKLOAD_GUID, - LabelsAndEventClasses::WORKLOAD, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::WORKLOAD_GUID, + LabelsAndEventClasses::WORKLOAD, + readableData, + offset); // Network - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::NETWORK_GUID, - LabelsAndEventClasses::NETWORK, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::NETWORK_GUID, + LabelsAndEventClasses::NETWORK, + readableData, + offset); // Connection - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::CONNECTION_GUID, - LabelsAndEventClasses::CONNECTION, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::CONNECTION_GUID, + LabelsAndEventClasses::CONNECTION, + readableData, + offset); + // Inference - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::INFERENCE_GUID, - LabelsAndEventClasses::INFERENCE, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::INFERENCE_GUID, + LabelsAndEventClasses::INFERENCE, + readableData, + offset); + // Workload Execution - VerifyTimelineLabelBinaryPacket(LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, - LabelsAndEventClasses::WORKLOAD_EXECUTION, - readableData, - offset); + VerifyTimelineLabelBinaryPacketData(LabelsAndEventClasses::WORKLOAD_EXECUTION_GUID, + LabelsAndEventClasses::WORKLOAD_EXECUTION, + readableData, + offset); // First "well-known" event class: START OF LIFE - VerifyTimelineEventClassBinaryPacket(LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineEventClassBinaryPacketData(LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, + readableData, + offset); // Second "well-known" event class: END OF LIFE - VerifyTimelineEventClassBinaryPacket(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, - readableData, - offset); + VerifyTimelineEventClassBinaryPacketData(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, + readableData, + offset); // Mark the buffer as read mockBufferManager.MarkRead(readableBuffer); @@ -202,61 +210,64 @@ BOOST_AUTO_TEST_CASE(CreateNamedTypedChildEntityTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_CHECK(size == 292); + BOOST_CHECK(size == 236); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); // Utils unsigned int offset = 0; - // First packet sent: TimelineEntityBinaryPacket - VerifyTimelineEntityBinaryPacket(EmptyOptional(), readableData, offset); - - // Second packet sent: TimelineLabelBinaryPacket - VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityName, readableData, offset); - - // Third packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); - - // Fourth packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); - - // Fifth packet sent: TimelineLabelBinaryPacket - VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityType, readableData, offset); - - // Sixth packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); - - // Seventh packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); - - // Eighth packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::RetentionLink, - EmptyOptional(), - parentEntityGuid, - EmptyOptional(), - readableData, - offset); + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 228); + + // First dataset sent: TimelineEntityBinaryPacket + VerifyTimelineEntityBinaryPacketData(EmptyOptional(), readableData, offset); + + // Second dataset sent: TimelineLabelBinaryPacket + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset); + + // Third dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); + + // Fourth dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); + + // Fifth dataset sent: TimelineLabelBinaryPacket + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityType, readableData, offset); + + // Sixth dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); + + // Seventh dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); + + // Eighth dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::RetentionLink, + EmptyOptional(), + parentEntityGuid, + EmptyOptional(), + readableData, + offset); // Mark the buffer as read mockBufferManager.MarkRead(readableBuffer); @@ -336,55 +347,58 @@ BOOST_AUTO_TEST_CASE(CreateNameTypeEntityTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_CHECK(size == 244); + BOOST_CHECK(size == 196); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); // Utils unsigned int offset = 0; - // First packet sent: TimelineEntityBinaryPacket - VerifyTimelineEntityBinaryPacket(guid, readableData, offset); + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 188); + + // First dataset sent: TimelineEntityBinaryPacket + VerifyTimelineEntityBinaryPacketData(guid, readableData, offset); // Packets for Name Entity - // First packet sent: TimelineLabelBinaryPacket - VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityName, readableData, offset); - - // Second packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); - - // Third packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::NAME_GUID, - readableData, - offset); + // First dataset sent: TimelineLabelBinaryPacket + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityName, readableData, offset); + + // Second dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); + + // Third dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::NAME_GUID, + readableData, + offset); // Packets for Type Entity - // First packet sent: TimelineLabelBinaryPacket - VerifyTimelineLabelBinaryPacket(EmptyOptional(), entityType, readableData, offset); - - // Second packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - EmptyOptional(), - readableData, - offset); - - // Third packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::LabelLink, - EmptyOptional(), - EmptyOptional(), - LabelsAndEventClasses::TYPE_GUID, - readableData, - offset); + // First dataset sent: TimelineLabelBinaryPacket + VerifyTimelineLabelBinaryPacketData(EmptyOptional(), entityType, readableData, offset); + + // Second dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + EmptyOptional(), + readableData, + offset); + + // Third dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::LabelLink, + EmptyOptional(), + EmptyOptional(), + LabelsAndEventClasses::TYPE_GUID, + readableData, + offset); // Mark the buffer as read mockBufferManager.MarkRead(readableBuffer); @@ -411,31 +425,34 @@ BOOST_AUTO_TEST_CASE(RecordEventTest) auto readableBuffer = mockBufferManager.GetReadableBuffer(); BOOST_CHECK(readableBuffer != nullptr); unsigned int size = readableBuffer->GetSize(); - BOOST_CHECK(size == 116); + BOOST_CHECK(size == 100); const unsigned char* readableData = readableBuffer->GetReadableData(); BOOST_CHECK(readableData != nullptr); // Utils unsigned int offset = 0; - // First packet sent: TimelineEntityBinaryPacket + // Verify Header + VerifyTimelineHeaderBinary(readableData, offset, 92); + + // First dataset sent: TimelineEntityBinaryPacket VerifyTimelineEventBinaryPacket(EmptyOptional(), EmptyOptional(), EmptyOptional(), readableData, offset); - // Second packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::ExecutionLink, - EmptyOptional(), - entityGuid, - EmptyOptional(), - readableData, - offset); - - // Third packet sent: TimelineRelationshipBinaryPacket - VerifyTimelineRelationshipBinaryPacket(ProfilingRelationshipType::DataLink, - EmptyOptional(), - eventGuid, - eventClassGuid, - readableData, - offset); + // Second dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::ExecutionLink, + EmptyOptional(), + entityGuid, + EmptyOptional(), + readableData, + offset); + + // Third dataset sent: TimelineRelationshipBinaryPacket + VerifyTimelineRelationshipBinaryPacketData(ProfilingRelationshipType::DataLink, + EmptyOptional(), + eventGuid, + eventClassGuid, + readableData, + offset); // Mark the buffer as read mockBufferManager.MarkRead(readableBuffer); -- cgit v1.2.1