diff options
author | Keith Davis <keith.davis@arm.com> | 2020-03-05 16:25:28 +0000 |
---|---|---|
committer | Keith Davis Arm <keith.davis@arm.com> | 2020-03-09 16:11:25 +0000 |
commit | 97da5e2e6c8aaaf4249af60e8305431315226f15 (patch) | |
tree | c36f01055cbf0f9577bca95f64ca6de42c923a77 /src/profiling/SendTimelinePacket.hpp | |
parent | 53d092d34c1e9924151d8d3a228c04620c1baf5c (diff) | |
download | armnn-97da5e2e6c8aaaf4249af60e8305431315226f15.tar.gz |
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 <keith.davis@arm.com>
Change-Id: I83bd4bb9e7393617bca97eba96a6e1388916e5b0
Diffstat (limited to 'src/profiling/SendTimelinePacket.hpp')
-rw-r--r-- | src/profiling/SendTimelinePacket.hpp | 52 |
1 files changed, 30 insertions, 22 deletions
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 <typename Func, typename ... Params> 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<uint32_t, uint32_t> m_PacketHeader; + uint32_t m_PacketDataLength; + + bool m_DirectoryPackage = false; }; -template <typename Func, typename ... Params> +template<typename Func, typename ... Params> 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>(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()); } |