blob: 2f9892f31496cb7bd3cad57f901efcd0933c25b5 [file] [log] [blame]
Sadik Armagan7bbdf9d2019-10-24 10:26:05 +01001//
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
14namespace armnn
15{
16
17namespace profiling
18{
19
20class SendTimelinePacket : public ISendTimelinePacket
21{
22public:
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;
53private:
54 /// Reserves maximum packet size from buffer
55 void ReserveBuffer();
56
57 IBufferManager& m_BufferManager;
Matteo Martincigh2ffcc412019-11-05 11:47:40 +000058 IPacketBufferPtr m_WriteBuffer;
Sadik Armagan7bbdf9d2019-10-24 10:26:05 +010059 unsigned int m_Offset;
60 unsigned int m_BufferSize;
61};
62
63} // namespace profiling
64
65} // namespace armnn