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/SendTimelinePacket.hpp | 52 +++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'src/profiling/SendTimelinePacket.hpp') diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp index 737a1aa9a7..b3b4aa1f3d 100644 --- a/src/profiling/SendTimelinePacket.hpp +++ b/src/profiling/SendTimelinePacket.hpp @@ -25,8 +25,8 @@ public: SendTimelinePacket(IBufferManager& bufferManager) : m_BufferManager(bufferManager) , m_WriteBuffer(nullptr) - , m_Offset(0u) - , m_BufferSize(0u) + , m_Offset(8u) + , m_RemainingBufferSize(0u) {} /// Commits the current buffer and reset the member variables @@ -59,13 +59,20 @@ private: template void ForwardWriteBinaryFunction(Func& func, Params&& ... params); - IBufferManager& m_BufferManager; + IBufferManager& m_BufferManager; IPacketBufferPtr m_WriteBuffer; - unsigned int m_Offset; - unsigned int m_BufferSize; + unsigned int m_Offset; + unsigned int m_RemainingBufferSize; + + const unsigned int m_uint32_t_size = sizeof(uint32_t); + + std::pair m_PacketHeader; + uint32_t m_PacketDataLength; + + bool m_DirectoryPackage = false; }; -template +template void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... params) { try @@ -73,30 +80,31 @@ void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... par ReserveBuffer(); BOOST_ASSERT(m_WriteBuffer); unsigned int numberOfBytesWritten = 0; - while (true) + // Header will be prepended to the buffer on Commit() + while ( true ) { TimelinePacketStatus result = func(std::forward(params)..., &m_WriteBuffer->GetWritableData()[m_Offset], - m_BufferSize, + m_RemainingBufferSize, numberOfBytesWritten); - switch (result) + switch ( result ) { - case TimelinePacketStatus::BufferExhaustion: - Commit(); - ReserveBuffer(); - continue; - - case TimelinePacketStatus::Error: - throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION()); - - default: - m_Offset += numberOfBytesWritten; - m_BufferSize -= numberOfBytesWritten; - return; + case TimelinePacketStatus::BufferExhaustion: + Commit(); + ReserveBuffer(); + continue; + + case TimelinePacketStatus::Error: + throw RuntimeException("Error processing while sending TimelineBinaryPacket", + CHECK_LOCATION()); + + default:m_Offset += numberOfBytesWritten; + m_RemainingBufferSize -= numberOfBytesWritten; + return; } } } - catch (...) + catch ( ... ) { throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION()); } -- cgit v1.2.1