ArmNN
 21.02
SendTimelinePacket Class Reference

#include <SendTimelinePacket.hpp>

Inheritance diagram for SendTimelinePacket:
ISendTimelinePacket

Public Member Functions

 SendTimelinePacket (IBufferManager &bufferManager)
 
void Commit () override
 Commits the current buffer and reset the member variables. More...
 
void SendTimelineEntityBinaryPacket (uint64_t profilingGuid) override
 Create and write a TimelineEntityBinaryPacket from the parameters to the buffer. More...
 
void SendTimelineEventBinaryPacket (uint64_t timestamp, int threadId, uint64_t profilingGuid) override
 Create and write a TimelineEventBinaryPacket from the parameters to the buffer. More...
 
void SendTimelineEventClassBinaryPacket (uint64_t profilingGuid, uint64_t nameGuid) override
 Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer. More...
 
void SendTimelineLabelBinaryPacket (uint64_t profilingGuid, const std::string &label) override
 Create and write a TimelineLabelBinaryPacket from the parameters to the buffer. More...
 
void SendTimelineMessageDirectoryPackage () override
 Create and write a TimelineMessageDirectoryPackage in the buffer. More...
 
virtual void SendTimelineRelationshipBinaryPacket (ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, uint64_t attributeGuid) override
 Create and write a TimelineRelationshipBinaryPacket from the parameters to the buffer. More...
 
- Public Member Functions inherited from ISendTimelinePacket
virtual ~ISendTimelinePacket ()
 

Detailed Description

Definition at line 22 of file SendTimelinePacket.hpp.

Constructor & Destructor Documentation

◆ SendTimelinePacket()

Member Function Documentation

◆ Commit()

void Commit ( )
overridevirtual

Commits the current buffer and reset the member variables.

Implements ISendTimelinePacket.

Definition at line 14 of file SendTimelinePacket.cpp.

References armnn::profiling::BufferExhaustion, CHECK_LOCATION, IBufferManager::Commit(), armnn::profiling::CreateTimelinePacketHeader(), MAX_METADATA_PACKET_LENGTH, IBufferManager::Reserve(), and armnn::profiling::WriteUint32().

Referenced by SendTimelinePacket::SendTimelineMessageDirectoryPackage(), and SendTimelinePacket::SendTimelinePacket().

15 {
16  if (m_WriteBuffer == nullptr)
17  {
18  // Can't commit from a null buffer
19  return;
20  }
21 
22  if (!m_DirectoryPackage)
23  {
24  // Datalength should be Offset minus the two header words
25  m_PacketDataLength = m_Offset - m_uint32_t_size * 2;
26  // Reset offset to prepend header with full packet datalength
27  m_Offset = 0;
28 
29  // Add header before commit
30  m_PacketHeader = CreateTimelinePacketHeader(1,0,1,0,0,m_PacketDataLength);
31 
32  // Write the timeline binary packet header to the buffer
33  WriteUint32(m_WriteBuffer->GetWritableData(), m_Offset, m_PacketHeader.first);
34  m_Offset += m_uint32_t_size;
35  WriteUint32(m_WriteBuffer->GetWritableData(), m_Offset, m_PacketHeader.second);
36 
37  m_BufferManager.Commit(m_WriteBuffer, m_PacketDataLength + m_uint32_t_size * 2);
38 
39  }
40  else
41  {
42  m_DirectoryPackage = false;
43  m_BufferManager.Commit(m_WriteBuffer, m_Offset);
44  }
45 
46  // Commit the message
47  m_WriteBuffer.reset(nullptr);
48  // Reset offset to start after prepended header
49  m_Offset = 8;
50  m_RemainingBufferSize = 0;
51 }
void WriteUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset, uint32_t value)
std::pair< uint32_t, uint32_t > CreateTimelinePacketHeader(uint32_t packetFamily, uint32_t packetClass, uint32_t packetType, uint32_t streamId, uint32_t sequenceNumbered, uint32_t dataLength)
Creates a timeline packet header.
virtual void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true)=0

◆ SendTimelineEntityBinaryPacket()

void SendTimelineEntityBinaryPacket ( uint64_t  profilingGuid)
overridevirtual

Create and write a TimelineEntityBinaryPacket from the parameters to the buffer.

Implements ISendTimelinePacket.

Definition at line 85 of file SendTimelinePacket.cpp.

References armnn::profiling::WriteTimelineEntityBinary().

Referenced by SendTimelinePacket::SendTimelinePacket().

86 {
87  ForwardWriteBinaryFunction(WriteTimelineEntityBinary,
88  profilingGuid);
89 }
TimelinePacketStatus WriteTimelineEntityBinary(uint64_t profilingGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)

◆ SendTimelineEventBinaryPacket()

void SendTimelineEventBinaryPacket ( uint64_t  timestamp,
int  threadId,
uint64_t  profilingGuid 
)
overridevirtual

Create and write a TimelineEventBinaryPacket from the parameters to the buffer.

Implements ISendTimelinePacket.

Definition at line 91 of file SendTimelinePacket.cpp.

References armnn::profiling::WriteTimelineEventBinary().

Referenced by SendTimelinePacket::SendTimelinePacket().

94 {
95  ForwardWriteBinaryFunction(WriteTimelineEventBinary,
96  timestamp,
97  threadId,
98  profilingGuid);
99 }
TimelinePacketStatus WriteTimelineEventBinary(uint64_t timestamp, int threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)

◆ SendTimelineEventClassBinaryPacket()

void SendTimelineEventClassBinaryPacket ( uint64_t  profilingGuid,
uint64_t  nameGuid 
)
overridevirtual

Create and write a TimelineEventClassBinaryPacket from the parameters to the buffer.

Implements ISendTimelinePacket.

Definition at line 101 of file SendTimelinePacket.cpp.

References armnn::profiling::WriteTimelineEventClassBinary().

Referenced by SendTimelinePacket::SendTimelinePacket().

102 {
103  ForwardWriteBinaryFunction(WriteTimelineEventClassBinary,
104  profilingGuid,
105  nameGuid);
106 }
TimelinePacketStatus WriteTimelineEventClassBinary(uint64_t profilingGuid, uint64_t nameGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)

◆ SendTimelineLabelBinaryPacket()

void SendTimelineLabelBinaryPacket ( uint64_t  profilingGuid,
const std::string &  label 
)
overridevirtual

Create and write a TimelineLabelBinaryPacket from the parameters to the buffer.

Implements ISendTimelinePacket.

Definition at line 108 of file SendTimelinePacket.cpp.

References armnn::profiling::WriteTimelineLabelBinaryPacket().

Referenced by SendTimelinePacket::SendTimelinePacket().

109 {
110  ForwardWriteBinaryFunction(WriteTimelineLabelBinaryPacket,
111  profilingGuid,
112  label);
113 }
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)

◆ SendTimelineMessageDirectoryPackage()

void SendTimelineMessageDirectoryPackage ( )
overridevirtual

Create and write a TimelineMessageDirectoryPackage in the buffer.

Implements ISendTimelinePacket.

Definition at line 129 of file SendTimelinePacket.cpp.

References CHECK_LOCATION, SendTimelinePacket::Commit(), armnn::profiling::Ok, and armnn::profiling::WriteTimelineMessageDirectoryPackage().

Referenced by ActivateTimelineReportingCommandHandler::operator()(), and SendTimelinePacket::SendTimelinePacket().

130 {
131  try
132  {
133  // Flag to Reserve & Commit() that a DirectoryPackage is being sent
134  m_DirectoryPackage = true;
135  // Reserve buffer if it hasn't already been reserved
136  ReserveBuffer();
137  // Write to buffer
138  unsigned int numberOfBytesWritten = 0;
139  // Offset is initialised to 8
140  m_Offset = 0;
141 
142  TimelinePacketStatus result = WriteTimelineMessageDirectoryPackage(&m_WriteBuffer->GetWritableData()[m_Offset],
143  m_RemainingBufferSize,
144  numberOfBytesWritten);
146  {
147  throw RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION());
148  }
149 
150  // Commit the message
151  m_Offset += numberOfBytesWritten;
152  m_RemainingBufferSize -= numberOfBytesWritten;
153  Commit();
154  }
155  catch (...)
156  {
157  throw RuntimeException("Error processing TimelineMessageDirectoryPackage", CHECK_LOCATION());
158  }
159 }
TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)
void Commit() override
Commits the current buffer and reset the member variables.
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197

◆ SendTimelineRelationshipBinaryPacket()

void SendTimelineRelationshipBinaryPacket ( ProfilingRelationshipType  relationshipType,
uint64_t  relationshipGuid,
uint64_t  headGuid,
uint64_t  tailGuid,
uint64_t  attributeGuid 
)
overridevirtual

Create and write a TimelineRelationshipBinaryPacket from the parameters to the buffer.

Implements ISendTimelinePacket.

Definition at line 115 of file SendTimelinePacket.cpp.

References armnn::profiling::WriteTimelineRelationshipBinary().

Referenced by SendTimelinePacket::SendTimelinePacket().

120 {
121  ForwardWriteBinaryFunction(WriteTimelineRelationshipBinary,
122  relationshipType,
123  relationshipGuid,
124  headGuid,
125  tailGuid,
126  attributeGuid);
127 }
TimelinePacketStatus WriteTimelineRelationshipBinary(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, uint64_t attributeGuid, unsigned char *buffer, unsigned int remainingBufferSize, unsigned int &numberOfBytesWritten)

The documentation for this class was generated from the following files: