Sadik Armagan | 7bbdf9d | 2019-10-24 10:26:05 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "IBufferManager.hpp" |
| 9 | #include "ISendTimelinePacket.hpp" |
| 10 | #include "ProfilingUtils.hpp" |
| 11 | |
| 12 | #include <memory> |
| 13 | |
| 14 | namespace armnn |
| 15 | { |
| 16 | |
| 17 | namespace profiling |
| 18 | { |
| 19 | |
| 20 | class SendTimelinePacket : public ISendTimelinePacket |
| 21 | { |
| 22 | public: |
| 23 | SendTimelinePacket(IBufferManager& bufferManager) |
| 24 | : m_BufferManager(bufferManager) |
| 25 | , m_WriteBuffer(nullptr) |
| 26 | , m_Offset(0u) |
| 27 | , m_BufferSize(0u) |
| 28 | {} |
| 29 | |
| 30 | /// Commits the current buffer and reset the member variables |
| 31 | void Commit() override; |
| 32 | |
| 33 | /// Create and write a TimelineEntityBinaryPacket from the parameters to the buffer. |
| 34 | void SendTimelineEntityBinaryPacket(uint64_t profilingGuid) override; |
| 35 | |
| 36 | /// Create and write a TimelineEventBinaryPacket from the parameters to the buffer. |
| 37 | void SendTimelineEventBinaryPacket(uint64_t timestamp, uint32_t threadId, uint64_t profilingGuid) override; |
| 38 | |
| 39 | /// Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer. |
| 40 | void SendTimelineEventClassBinaryPacket(uint64_t profilingGuid) override; |
| 41 | |
| 42 | /// Create and write a TimelineLabelBinaryPacket from the parameters to the buffer. |
| 43 | void SendTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string& label) override; |
| 44 | |
| 45 | /// Create and write a TimelineMessageDirectoryPackage in the buffer |
| 46 | void SendTimelineMessageDirectoryPackage() override; |
| 47 | |
| 48 | /// Create and write a TimelineRelationshipBinaryPacket from the parameters to the buffer. |
| 49 | virtual void SendTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, |
| 50 | uint64_t relationshipGuid, |
| 51 | uint64_t headGuid, |
| 52 | uint64_t tailGuid) override; |
| 53 | private: |
| 54 | /// Reserves maximum packet size from buffer |
| 55 | void ReserveBuffer(); |
| 56 | |
| 57 | IBufferManager& m_BufferManager; |
Matteo Martincigh | 2ffcc41 | 2019-11-05 11:47:40 +0000 | [diff] [blame^] | 58 | IPacketBufferPtr m_WriteBuffer; |
Sadik Armagan | 7bbdf9d | 2019-10-24 10:26:05 +0100 | [diff] [blame] | 59 | unsigned int m_Offset; |
| 60 | unsigned int m_BufferSize; |
| 61 | }; |
| 62 | |
| 63 | } // namespace profiling |
| 64 | |
| 65 | } // namespace armnn |