ArmNN  NotReleased
TimelinePacketTests.cpp File Reference
#include <ProfilingUtils.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/numeric/conversion/cast.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (TimelineLabelPacketTest1)
 
 BOOST_AUTO_TEST_CASE (TimelineLabelPacketTest2)
 
 BOOST_AUTO_TEST_CASE (TimelineLabelPacketTest3)
 
 BOOST_AUTO_TEST_CASE (TimelineLabelPacketTest4)
 
 BOOST_AUTO_TEST_CASE (TimelineLabelPacketTest5)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketNullBufferTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketZeroBufferSizeTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketSmallBufferSizeTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketInvalidRelationTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketExecutionLinkTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketDataLinkTest)
 
 BOOST_AUTO_TEST_CASE (TimelineRelationshipPacketLabelLinkTest)
 
 BOOST_AUTO_TEST_CASE (TimelineMessageDirectoryPacketTest1)
 
 BOOST_AUTO_TEST_CASE (TimelineMessageDirectoryPacketTest2)
 
 BOOST_AUTO_TEST_CASE (TimelineMessageDirectoryPacketTest3)
 
 BOOST_AUTO_TEST_CASE (TimelineEntityPacketTest1)
 
 BOOST_AUTO_TEST_CASE (TimelineEntityPacketTest2)
 
 BOOST_AUTO_TEST_CASE (TimelineEntityPacketTest3)
 
 BOOST_AUTO_TEST_CASE (TimelineEntityPacketTest4)
 
 BOOST_AUTO_TEST_CASE (TimelineEventClassTest1)
 
 BOOST_AUTO_TEST_CASE (TimelineEventClassTest2)
 
 BOOST_AUTO_TEST_CASE (TimelineEventClassTest3)
 
 BOOST_AUTO_TEST_CASE (TimelineEventClassTest4)
 
 BOOST_AUTO_TEST_CASE (TimelineEventPacketTest1)
 
 BOOST_AUTO_TEST_CASE (TimelineEventPacketTest2)
 
 BOOST_AUTO_TEST_CASE (TimelineEventPacketTest3)
 
 BOOST_AUTO_TEST_CASE (TimelineEventPacketTest4)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/28]

BOOST_AUTO_TEST_CASE ( TimelineLabelPacketTest1  )

Definition at line 15 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineLabelBinaryPacket().

16 {
17  const uint64_t profilingGuid = 123456u;
18  const std::string label = "some label";
19  unsigned int numberOfBytesWritten = 789u;
21  label,
22  nullptr,
23  512u,
24  numberOfBytesWritten);
25  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
26  BOOST_CHECK(numberOfBytesWritten == 0);
27 }
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [2/28]

BOOST_AUTO_TEST_CASE ( TimelineLabelPacketTest2  )

Definition at line 29 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineLabelBinaryPacket().

30 {
31  std::vector<unsigned char> buffer(512, 0);
32 
33  const uint64_t profilingGuid = 123456u;
34  const std::string label = "some label";
35  unsigned int numberOfBytesWritten = 789u;
37  label,
38  buffer.data(),
39  0,
40  numberOfBytesWritten);
41  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
42  BOOST_CHECK(numberOfBytesWritten == 0);
43 }
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [3/28]

BOOST_AUTO_TEST_CASE ( TimelineLabelPacketTest3  )

Definition at line 45 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineLabelBinaryPacket().

46 {
47  std::vector<unsigned char> buffer(10, 0);
48 
49  const uint64_t profilingGuid = 123456u;
50  const std::string label = "some label";
51  unsigned int numberOfBytesWritten = 789u;
53  label,
54  buffer.data(),
55  boost::numeric_cast<unsigned int>(buffer.size()),
56  numberOfBytesWritten);
57  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
58  BOOST_CHECK(numberOfBytesWritten == 0);
59 }
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [4/28]

BOOST_AUTO_TEST_CASE ( TimelineLabelPacketTest4  )

Definition at line 61 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Error, and armnn::profiling::WriteTimelineLabelBinaryPacket().

62 {
63  std::vector<unsigned char> buffer(512, 0);
64 
65  const uint64_t profilingGuid = 123456u;
66  const std::string label = "s0m€ l@b€l";
67  unsigned int numberOfBytesWritten = 789u;
69  label,
70  buffer.data(),
71  boost::numeric_cast<unsigned int>(buffer.size()),
72  numberOfBytesWritten);
73  BOOST_CHECK(result == TimelinePacketStatus::Error);
74  BOOST_CHECK(numberOfBytesWritten == 0);
75 }
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [5/28]

BOOST_AUTO_TEST_CASE ( TimelineLabelPacketTest5  )

Definition at line 77 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineLabelBinaryPacket().

78 {
79  std::vector<unsigned char> buffer(512, 0);
80 
81  const uint64_t profilingGuid = 123456u;
82  const std::string label = "some label";
83  unsigned int numberOfBytesWritten = 789u;
85  label,
86  buffer.data(),
87  boost::numeric_cast<unsigned int>(buffer.size()),
88  numberOfBytesWritten);
89  BOOST_CHECK(result == TimelinePacketStatus::Ok);
90  BOOST_CHECK(numberOfBytesWritten == 36);
91 
92  unsigned int uint32_t_size = sizeof(uint32_t);
93  unsigned int uint64_t_size = sizeof(uint64_t);
94 
95  // Check the packet header
96  unsigned int offset = 0;
97  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
98  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
99  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
100  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
101  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
102  BOOST_CHECK(packetFamily == 1);
103  BOOST_CHECK(packetClass == 0);
104  BOOST_CHECK(packetType == 1);
105  BOOST_CHECK(streamId == 0);
106 
107  offset += uint32_t_size;
108  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
109  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
110  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
111  BOOST_CHECK(sequenceNumbered == 0);
112  BOOST_CHECK(dataLength == 28);
113 
114  // Check decl_Id
115  offset += uint32_t_size;
116  uint32_t decl_Id = ReadUint32(buffer.data(), offset);
117  BOOST_CHECK(decl_Id == uint32_t(0));
118 
119  // Check the profiling GUID
120  offset += uint32_t_size;
121  uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
122  BOOST_CHECK(readProfilingGuid == profilingGuid);
123 
124  // Check the SWTrace label
125  offset += uint64_t_size;
126  uint32_t swTraceLabelLength = ReadUint32(buffer.data(), offset);
127  BOOST_CHECK(swTraceLabelLength == 11); // Label length including the null-terminator
128 
129  offset += uint32_t_size;
130  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
131  label.data(), // The original label
132  swTraceLabelLength - 1) == 0); // The length of the label
133 
134  offset += swTraceLabelLength * uint32_t_size;
135  BOOST_CHECK(buffer[offset] == '\0'); // The null-terminator at the end of the SWTrace label
136 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineLabelBinaryPacket(uint64_t profilingGuid, const std::string &label, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [6/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketNullBufferTest  )

Definition at line 138 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, armnn::profiling::DataLink, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

139 {
141  const uint64_t relationshipGuid = 123456u;
142  const uint64_t headGuid = 234567u;
143  const uint64_t tailGuid = 345678u;
144  unsigned int numberOfBytesWritten = 789u;
146  relationshipGuid,
147  headGuid,
148  tailGuid,
149  nullptr,
150  512u,
151  numberOfBytesWritten);
152  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
153  BOOST_CHECK(numberOfBytesWritten == 0);
154 }
Head execution start depends on Tail execution completion.
Definition: TimelineModel.h:21
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [7/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketZeroBufferSizeTest  )

Definition at line 156 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, armnn::profiling::DataLink, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

157 {
158  std::vector<unsigned char> buffer(512, 0);
159 
161  const uint64_t relationshipGuid = 123456u;
162  const uint64_t headGuid = 234567u;
163  const uint64_t tailGuid = 345678u;
164  unsigned int numberOfBytesWritten = 789u;
166  relationshipGuid,
167  headGuid,
168  tailGuid,
169  buffer.data(),
170  0,
171  numberOfBytesWritten);
172  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
173  BOOST_CHECK(numberOfBytesWritten == 0);
174 }
Head execution start depends on Tail execution completion.
Definition: TimelineModel.h:21
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [8/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketSmallBufferSizeTest  )

Definition at line 176 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, armnn::profiling::DataLink, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

177 {
178  std::vector<unsigned char> buffer(10, 0);
179 
181  const uint64_t relationshipGuid = 123456u;
182  const uint64_t headGuid = 234567u;
183  const uint64_t tailGuid = 345678u;
184  unsigned int numberOfBytesWritten = 789u;
185  TimelinePacketStatus result =
186  WriteTimelineRelationshipBinaryPacket(relationshipType,
187  relationshipGuid,
188  headGuid,
189  tailGuid,
190  buffer.data(),
191  boost::numeric_cast<unsigned int>(buffer.size()),
192  numberOfBytesWritten);
193  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
194  BOOST_CHECK(numberOfBytesWritten == 0);
195 }
Head execution start depends on Tail execution completion.
Definition: TimelineModel.h:21
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [9/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketInvalidRelationTest  )

Definition at line 197 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

198 {
199  std::vector<unsigned char> buffer(512, 0);
200  ProfilingRelationshipType relationshipType = static_cast<ProfilingRelationshipType>(5);
201  const uint64_t relationshipGuid = 123456u;
202  const uint64_t headGuid = 234567u;
203  const uint64_t tailGuid = 345678u;
204  unsigned int numberOfBytesWritten = 789u;
205 
206  BOOST_CHECK_THROW(WriteTimelineRelationshipBinaryPacket(relationshipType,
207  relationshipGuid,
208  headGuid,
209  tailGuid,
210  buffer.data(),
211  boost::numeric_cast<unsigned int>(buffer.size()),
212  numberOfBytesWritten),
214 
215  BOOST_CHECK(numberOfBytesWritten == 0);
216 }
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [10/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketTest  )

Definition at line 218 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::RetentionLink, armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

219 {
220  std::vector<unsigned char> buffer(512, 0);
221 
223  const uint64_t relationshipGuid = 123456u;
224  const uint64_t headGuid = 234567u;
225  const uint64_t tailGuid = 345678u;
226  unsigned int numberOfBytesWritten = 789u;
227  TimelinePacketStatus result =
228  WriteTimelineRelationshipBinaryPacket(relationshipType,
229  relationshipGuid,
230  headGuid,
231  tailGuid,
232  buffer.data(),
233  boost::numeric_cast<unsigned int>(buffer.size()),
234  numberOfBytesWritten);
235  BOOST_CHECK(result == TimelinePacketStatus::Ok);
236  BOOST_CHECK(numberOfBytesWritten == 40);
237 
238  unsigned int uint32_t_size = sizeof(uint32_t);
239  unsigned int uint64_t_size = sizeof(uint64_t);
240 
241  // Check the packet header
242  unsigned int offset = 0;
243  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
244  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
245  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
246  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
247  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
248  BOOST_CHECK(packetFamily == 1);
249  BOOST_CHECK(packetClass == 0);
250  BOOST_CHECK(packetType == 1);
251  BOOST_CHECK(streamId == 0);
252 
253  offset += uint32_t_size;
254  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
255  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
256  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
257  BOOST_CHECK(sequenceNumbered == 0);
258  BOOST_CHECK(dataLength == 32);
259 
260  // Check the decl_id
261  offset += uint32_t_size;
262  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
263  BOOST_CHECK(readDeclId == 3);
264 
265  // Check the relationship type
266  offset += uint32_t_size;
267  uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
268  BOOST_CHECK(readRelationshipType == 0);
269 
270  // Check the relationship GUID
271  offset += uint32_t_size;
272  uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
273  BOOST_CHECK(readRelationshipGuid == relationshipGuid);
274 
275  // Check the head GUID
276  offset += uint64_t_size;
277  uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
278  BOOST_CHECK(readHeadGuid == headGuid);
279 
280  // Check the tail GUID
281  offset += uint64_t_size;
282  uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
283  BOOST_CHECK(readTailGuid == tailGuid);
284 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [11/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketExecutionLinkTest  )

Definition at line 286 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::ExecutionLink, armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

287 {
288  std::vector<unsigned char> buffer(512, 0);
289 
291  const uint64_t relationshipGuid = 123456u;
292  const uint64_t headGuid = 234567u;
293  const uint64_t tailGuid = 345678u;
294  unsigned int numberOfBytesWritten = 789u;
295  TimelinePacketStatus result =
296  WriteTimelineRelationshipBinaryPacket(relationshipType,
297  relationshipGuid,
298  headGuid,
299  tailGuid,
300  buffer.data(),
301  boost::numeric_cast<unsigned int>(buffer.size()),
302  numberOfBytesWritten);
303  BOOST_CHECK(result == TimelinePacketStatus::Ok);
304  BOOST_CHECK(numberOfBytesWritten == 40);
305 
306  unsigned int uint32_t_size = sizeof(uint32_t);
307  unsigned int uint64_t_size = sizeof(uint64_t);
308 
309  // Check the packet header
310  unsigned int offset = 0;
311  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
312  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
313  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
314  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
315  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
316  BOOST_CHECK(packetFamily == 1);
317  BOOST_CHECK(packetClass == 0);
318  BOOST_CHECK(packetType == 1);
319  BOOST_CHECK(streamId == 0);
320 
321  offset += uint32_t_size;
322  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
323  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
324  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
325  BOOST_CHECK(sequenceNumbered == 0);
326  BOOST_CHECK(dataLength == 32);
327 
328  // Check the decl_id
329  offset += uint32_t_size;
330  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
331  BOOST_CHECK(readDeclId == 3);
332 
333  // Check the relationship type
334  offset += uint32_t_size;
335  uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
336  BOOST_CHECK(readRelationshipType == 1);
337 
338  // Check the relationship GUID
339  offset += uint32_t_size;
340  uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
341  BOOST_CHECK(readRelationshipGuid == relationshipGuid);
342 
343  // Check the head GUID
344  offset += uint64_t_size;
345  uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
346  BOOST_CHECK(readHeadGuid == headGuid);
347 
348  // Check the tail GUID
349  offset += uint64_t_size;
350  uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
351  BOOST_CHECK(readTailGuid == tailGuid);
352 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
Head retains(parents) Tail.
Definition: TimelineModel.h:20
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [12/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketDataLinkTest  )

Definition at line 355 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::DataLink, armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

356 {
357  std::vector<unsigned char> buffer(512, 0);
358 
360  const uint64_t relationshipGuid = 123456u;
361  const uint64_t headGuid = 234567u;
362  const uint64_t tailGuid = 345678u;
363  unsigned int numberOfBytesWritten = 789u;
364  TimelinePacketStatus result =
365  WriteTimelineRelationshipBinaryPacket(relationshipType,
366  relationshipGuid,
367  headGuid,
368  tailGuid,
369  buffer.data(),
370  boost::numeric_cast<unsigned int>(buffer.size()),
371  numberOfBytesWritten);
372  BOOST_CHECK(result == TimelinePacketStatus::Ok);
373  BOOST_CHECK(numberOfBytesWritten == 40);
374 
375  unsigned int uint32_t_size = sizeof(uint32_t);
376  unsigned int uint64_t_size = sizeof(uint64_t);
377 
378  // Check the packet header
379  unsigned int offset = 0;
380  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
381  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
382  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
383  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
384  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
385  BOOST_CHECK(packetFamily == 1);
386  BOOST_CHECK(packetClass == 0);
387  BOOST_CHECK(packetType == 1);
388  BOOST_CHECK(streamId == 0);
389 
390  offset += uint32_t_size;
391  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
392  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
393  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
394  BOOST_CHECK(sequenceNumbered == 0);
395  BOOST_CHECK(dataLength == 32);
396 
397  // Check the decl_id
398  offset += uint32_t_size;
399  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
400  BOOST_CHECK(readDeclId == 3);
401 
402  // Check the relationship type
403  offset += uint32_t_size;
404  uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
405  BOOST_CHECK(readRelationshipType == 2);
406 
407  // Check the relationship GUID
408  offset += uint32_t_size;
409  uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
410  BOOST_CHECK(readRelationshipGuid == relationshipGuid);
411 
412  // Check the head GUID
413  offset += uint64_t_size;
414  uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
415  BOOST_CHECK(readHeadGuid == headGuid);
416 
417  // Check the tail GUID
418  offset += uint64_t_size;
419  uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
420  BOOST_CHECK(readTailGuid == tailGuid);
421 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
Head execution start depends on Tail execution completion.
Definition: TimelineModel.h:21
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [13/28]

BOOST_AUTO_TEST_CASE ( TimelineRelationshipPacketLabelLinkTest  )

Definition at line 424 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::LabelLink, armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineRelationshipBinaryPacket().

425 {
426  std::vector<unsigned char> buffer(512, 0);
427 
429  const uint64_t relationshipGuid = 123456u;
430  const uint64_t headGuid = 234567u;
431  const uint64_t tailGuid = 345678u;
432  unsigned int numberOfBytesWritten = 789u;
433  TimelinePacketStatus result =
434  WriteTimelineRelationshipBinaryPacket(relationshipType,
435  relationshipGuid,
436  headGuid,
437  tailGuid,
438  buffer.data(),
439  boost::numeric_cast<unsigned int>(buffer.size()),
440  numberOfBytesWritten);
441  BOOST_CHECK(result == TimelinePacketStatus::Ok);
442  BOOST_CHECK(numberOfBytesWritten == 40);
443 
444  unsigned int uint32_t_size = sizeof(uint32_t);
445  unsigned int uint64_t_size = sizeof(uint64_t);
446 
447  // Check the packet header
448  unsigned int offset = 0;
449  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
450  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
451  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
452  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
453  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
454  BOOST_CHECK(packetFamily == 1);
455  BOOST_CHECK(packetClass == 0);
456  BOOST_CHECK(packetType == 1);
457  BOOST_CHECK(streamId == 0);
458 
459  offset += uint32_t_size;
460  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
461  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
462  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
463  BOOST_CHECK(sequenceNumbered == 0);
464  BOOST_CHECK(dataLength == 32);
465 
466  // Check the decl_id
467  offset += uint32_t_size;
468  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
469  BOOST_CHECK(readDeclId == 3);
470 
471  // Check the relationship type
472  offset += uint32_t_size;
473  uint32_t readRelationshipType = ReadUint32(buffer.data(), offset);
474  BOOST_CHECK(readRelationshipType == 3);
475 
476  // Check the relationship GUID
477  offset += uint32_t_size;
478  uint64_t readRelationshipGuid = ReadUint64(buffer.data(), offset);
479  BOOST_CHECK(readRelationshipGuid == relationshipGuid);
480 
481  // Check the head GUID
482  offset += uint64_t_size;
483  uint64_t readHeadGuid = ReadUint64(buffer.data(), offset);
484  BOOST_CHECK(readHeadGuid == headGuid);
485 
486  // Check the tail GUID
487  offset += uint64_t_size;
488  uint64_t readTailGuid = ReadUint64(buffer.data(), offset);
489  BOOST_CHECK(readTailGuid == tailGuid);
490 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineRelationshipBinaryPacket(ProfilingRelationshipType relationshipType, uint64_t relationshipGuid, uint64_t headGuid, uint64_t tailGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
Head uses data of Tail.
Definition: TimelineModel.h:22

◆ BOOST_AUTO_TEST_CASE() [14/28]

BOOST_AUTO_TEST_CASE ( TimelineMessageDirectoryPacketTest1  )

Definition at line 492 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineMessageDirectoryPackage().

493 {
494  unsigned int numberOfBytesWritten = 789u;
496  512u,
497  numberOfBytesWritten);
498  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
499  BOOST_CHECK(numberOfBytesWritten == 0);
500 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [15/28]

BOOST_AUTO_TEST_CASE ( TimelineMessageDirectoryPacketTest2  )

Definition at line 502 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineMessageDirectoryPackage().

503 {
504  std::vector<unsigned char> buffer(512, 0);
505 
506  unsigned int numberOfBytesWritten = 789u;
508  0,
509  numberOfBytesWritten);
510  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
511  BOOST_CHECK(numberOfBytesWritten == 0);
512 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [16/28]

BOOST_AUTO_TEST_CASE ( TimelineMessageDirectoryPacketTest3  )

Definition at line 514 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint8(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineMessageDirectoryPackage().

515 {
516  std::vector<unsigned char> buffer(512, 0);
517  unsigned int numberOfBytesWritten = 789u;
519  boost::numeric_cast<unsigned int>(buffer.size()),
520  numberOfBytesWritten);
521  BOOST_CHECK(result == TimelinePacketStatus::Ok);
522 
523  BOOST_CHECK(numberOfBytesWritten == 427);
524 
525  unsigned int uint8_t_size = sizeof(uint8_t);
526  unsigned int uint32_t_size = sizeof(uint32_t);
527  unsigned int uint64_t_size = sizeof(uint64_t);
528  unsigned int threadId_size = sizeof(std::thread::id);
529 
530  // Check the packet header
531  unsigned int offset = 0;
532  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
533  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
534  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
535  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
536  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
537  BOOST_CHECK(packetFamily == 1);
538  BOOST_CHECK(packetClass == 0);
539  BOOST_CHECK(packetType == 0);
540  BOOST_CHECK(streamId == 0);
541 
542  offset += uint32_t_size;
543  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
544  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
545  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
546  BOOST_CHECK(sequenceNumbered == 0);
547  BOOST_CHECK(dataLength == 419);
548 
549  // Check the stream header
550  offset += uint32_t_size;
551  uint8_t readStreamVersion = ReadUint8(buffer.data(), offset);
552  BOOST_CHECK(readStreamVersion == 4);
553  offset += uint8_t_size;
554  uint8_t readPointerBytes = ReadUint8(buffer.data(), offset);
555  BOOST_CHECK(readPointerBytes == uint64_t_size);
556  offset += uint8_t_size;
557  uint8_t readThreadIdBytes = ReadUint8(buffer.data(), offset);
558  BOOST_CHECK(readThreadIdBytes == threadId_size);
559 
560  // Check the number of declarations
561  offset += uint8_t_size;
562  uint32_t declCount = ReadUint32(buffer.data(), offset);
563  BOOST_CHECK(declCount == 5);
564 
565  // Check the decl_id
566  offset += uint32_t_size;
567  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
568  BOOST_CHECK(readDeclId == 0);
569 
570  // SWTrace "namestring" format
571  // length of the string (first 4 bytes) + string + null terminator
572 
573  // Check the decl_name
574  offset += uint32_t_size;
575  uint32_t swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
576  BOOST_CHECK(swTraceDeclNameLength == 13); // decl_name length including the null-terminator
577 
578  std::string label = "declareLabel";
579  offset += uint32_t_size;
580  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
581  label.data(), // The original label
582  swTraceDeclNameLength - 1) == 0); // The length of the label
583 
584  // Check the ui_name
585  std::vector<uint32_t> swTraceString;
586  StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
587  offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
588  uint32_t swTraceUINameLength = ReadUint32(buffer.data(), offset);
589  BOOST_CHECK(swTraceUINameLength == 14); // ui_name length including the null-terminator
590 
591  label = "declare label";
592  offset += uint32_t_size;
593  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
594  label.data(), // The original label
595  swTraceUINameLength - 1) == 0); // The length of the label
596 
597  // Check arg_types
598  StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
599  offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
600  uint32_t swTraceArgTypesLength = ReadUint32(buffer.data(), offset);
601  BOOST_CHECK(swTraceArgTypesLength == 3); // arg_types length including the null-terminator
602 
603  label = "ps";
604  offset += uint32_t_size;
605  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
606  label.data(), // The original label
607  swTraceArgTypesLength - 1) == 0); // The length of the label
608 
609  // Check arg_names
610  StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
611  offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
612  uint32_t swTraceArgNamesLength = ReadUint32(buffer.data(), offset);
613  BOOST_CHECK(swTraceArgNamesLength == 11); // arg_names length including the null-terminator
614 
615  label = "guid,value";
616  offset += uint32_t_size;
617  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
618  label.data(), // The original label
619  swTraceArgNamesLength - 1) == 0); // The length of the label
620 
621  // Check second message decl_id
622  StringToSwTraceString<SwTraceCharPolicy>(label, swTraceString);
623  offset += (boost::numeric_cast<unsigned int>(swTraceString.size()) - 1) * uint32_t_size;
624  readDeclId = ReadUint32(buffer.data(), offset);
625  BOOST_CHECK(readDeclId == 1);
626 
627  // Check second decl_name
628  offset += uint32_t_size;
629  swTraceDeclNameLength = ReadUint32(buffer.data(), offset);
630  BOOST_CHECK(swTraceDeclNameLength == 14); // decl_name length including the null-terminator
631 
632  label = "declareEntity";
633  offset += uint32_t_size;
634  BOOST_CHECK(std::memcmp(buffer.data() + offset, // Offset to the label in the buffer
635  label.data(), // The original label
636  swTraceDeclNameLength - 1) == 0); // The length of the label
637 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint8_t ReadUint8(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineMessageDirectoryPackage(unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [17/28]

BOOST_AUTO_TEST_CASE ( TimelineEntityPacketTest1  )

Definition at line 639 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEntityBinaryPacket().

640 {
641  const uint64_t profilingGuid = 123456u;
642  unsigned int numberOfBytesWritten = 789u;
644  nullptr,
645  512u,
646  numberOfBytesWritten);
647  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
648  BOOST_CHECK(numberOfBytesWritten == 0);
649 }
TimelinePacketStatus WriteTimelineEntityBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [18/28]

BOOST_AUTO_TEST_CASE ( TimelineEntityPacketTest2  )

Definition at line 651 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEntityBinaryPacket().

652 {
653  std::vector<unsigned char> buffer(512, 0);
654 
655  const uint64_t profilingGuid = 123456u;
656  unsigned int numberOfBytesWritten = 789u;
658  buffer.data(),
659  0,
660  numberOfBytesWritten);
661  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
662  BOOST_CHECK(numberOfBytesWritten == 0);
663 }
TimelinePacketStatus WriteTimelineEntityBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [19/28]

BOOST_AUTO_TEST_CASE ( TimelineEntityPacketTest3  )

Definition at line 665 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEntityBinaryPacket().

666 {
667  std::vector<unsigned char> buffer(10, 0);
668 
669  const uint64_t profilingGuid = 123456u;
670  unsigned int numberOfBytesWritten = 789u;
672  buffer.data(),
673  boost::numeric_cast<unsigned int>(buffer.size()),
674  numberOfBytesWritten);
675  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
676  BOOST_CHECK(numberOfBytesWritten == 0);
677 }
TimelinePacketStatus WriteTimelineEntityBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [20/28]

BOOST_AUTO_TEST_CASE ( TimelineEntityPacketTest4  )

Definition at line 679 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineEntityBinaryPacket().

680 {
681  std::vector<unsigned char> buffer(512, 0);
682 
683  const uint64_t profilingGuid = 123456u;
684  unsigned int numberOfBytesWritten = 789u;
686  buffer.data(),
687  boost::numeric_cast<unsigned int>(buffer.size()),
688  numberOfBytesWritten);
689  BOOST_CHECK(result == TimelinePacketStatus::Ok);
690  BOOST_CHECK(numberOfBytesWritten == 20);
691 
692  unsigned int uint32_t_size = sizeof(uint32_t);
693 
694  // Check the packet header
695  unsigned int offset = 0;
696  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
697  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
698  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
699  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
700  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
701  BOOST_CHECK(packetFamily == 1);
702  BOOST_CHECK(packetClass == 0);
703  BOOST_CHECK(packetType == 1);
704  BOOST_CHECK(streamId == 0);
705 
706  offset += uint32_t_size;
707  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
708  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
709  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
710  BOOST_CHECK(sequenceNumbered == 0);
711  BOOST_CHECK(dataLength == 12);
712 
713  // Check decl_Id
714  offset += uint32_t_size;
715  uint32_t decl_Id = ReadUint32(buffer.data(), offset);
716  BOOST_CHECK(decl_Id == uint32_t(1));
717 
718  // Check the profiling GUID
719  offset += uint32_t_size;
720  uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
721  BOOST_CHECK(readProfilingGuid == profilingGuid);
722 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineEntityBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [21/28]

BOOST_AUTO_TEST_CASE ( TimelineEventClassTest1  )

Definition at line 724 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventClassBinaryPacket().

725 {
726  const uint64_t profilingGuid = 123456u;
727  unsigned int numberOfBytesWritten = 789u;
729  nullptr,
730  512u,
731  numberOfBytesWritten);
732  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
733  BOOST_CHECK(numberOfBytesWritten == 0);
734 }
TimelinePacketStatus WriteTimelineEventClassBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [22/28]

BOOST_AUTO_TEST_CASE ( TimelineEventClassTest2  )

Definition at line 736 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventClassBinaryPacket().

737 {
738  std::vector<unsigned char> buffer(512, 0);
739 
740  const uint64_t profilingGuid = 123456u;
741  unsigned int numberOfBytesWritten = 789u;
743  buffer.data(),
744  0,
745  numberOfBytesWritten);
746  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
747  BOOST_CHECK(numberOfBytesWritten == 0);
748 }
TimelinePacketStatus WriteTimelineEventClassBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [23/28]

BOOST_AUTO_TEST_CASE ( TimelineEventClassTest3  )

Definition at line 750 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventClassBinaryPacket().

751 {
752  std::vector<unsigned char> buffer(10, 0);
753 
754  const uint64_t profilingGuid = 123456u;
755  unsigned int numberOfBytesWritten = 789u;
757  buffer.data(),
758  boost::numeric_cast<unsigned int>(buffer.size()),
759  numberOfBytesWritten);
760  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
761  BOOST_CHECK(numberOfBytesWritten == 0);
762 }
TimelinePacketStatus WriteTimelineEventClassBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [24/28]

BOOST_AUTO_TEST_CASE ( TimelineEventClassTest4  )

Definition at line 764 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineEventClassBinaryPacket().

765 {
766  std::vector<unsigned char> buffer(512, 0);
767 
768  const uint64_t profilingGuid = 123456u;
769  unsigned int numberOfBytesWritten = 789u;
771  buffer.data(),
772  boost::numeric_cast<unsigned int>(buffer.size()),
773  numberOfBytesWritten);
774  BOOST_CHECK(result == TimelinePacketStatus::Ok);
775  BOOST_CHECK(numberOfBytesWritten == 20);
776 
777  unsigned int uint32_t_size = sizeof(uint32_t);
778 
779  // Check the packet header
780  unsigned int offset = 0;
781  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
782  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
783  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
784  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
785  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
786  BOOST_CHECK(packetFamily == 1);
787  BOOST_CHECK(packetClass == 0);
788  BOOST_CHECK(packetType == 1);
789  BOOST_CHECK(streamId == 0);
790 
791  offset += uint32_t_size;
792  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
793  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
794  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
795  BOOST_CHECK(sequenceNumbered == 0);
796  BOOST_CHECK(dataLength == 12);
797 
798  // Check the decl_id
799  offset += uint32_t_size;
800  uint32_t declId = ReadUint32(buffer.data(), offset);
801  BOOST_CHECK(declId == uint32_t(2));
802 
803  // Check the profiling GUID
804  offset += uint32_t_size;
805  uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
806  BOOST_CHECK(readProfilingGuid == profilingGuid);
807 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineEventClassBinaryPacket(uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [25/28]

BOOST_AUTO_TEST_CASE ( TimelineEventPacketTest1  )

Definition at line 809 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventBinaryPacket().

810 {
811  const uint64_t timestamp = 456789u;
812  const std::thread::id threadId = std::this_thread::get_id();
813  const uint64_t profilingGuid = 123456u;
814  unsigned int numberOfBytesWritten = 789u;
816  threadId,
817  profilingGuid,
818  nullptr,
819  512u,
820  numberOfBytesWritten);
821  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
822  BOOST_CHECK(numberOfBytesWritten == 0);
823 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [26/28]

BOOST_AUTO_TEST_CASE ( TimelineEventPacketTest2  )

Definition at line 825 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventBinaryPacket().

826 {
827  std::vector<unsigned char> buffer(512, 0);
828 
829  const uint64_t timestamp = 456789u;
830  const std::thread::id threadId = std::this_thread::get_id();
831  const uint64_t profilingGuid = 123456u;
832  unsigned int numberOfBytesWritten = 789u;
834  threadId,
835  profilingGuid,
836  buffer.data(),
837  0,
838  numberOfBytesWritten);
839  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
840  BOOST_CHECK(numberOfBytesWritten == 0);
841 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [27/28]

BOOST_AUTO_TEST_CASE ( TimelineEventPacketTest3  )

Definition at line 843 of file TimelinePacketTests.cpp.

References BOOST_CHECK(), armnn::profiling::BufferExhaustion, and armnn::profiling::WriteTimelineEventBinaryPacket().

844 {
845  std::vector<unsigned char> buffer(10, 0);
846 
847  const uint64_t timestamp = 456789u;
848  const std::thread::id threadId = std::this_thread::get_id();
849  const uint64_t profilingGuid = 123456u;
850  unsigned int numberOfBytesWritten = 789u;
852  threadId,
853  profilingGuid,
854  buffer.data(),
855  boost::numeric_cast<unsigned int>(buffer.size()),
856  numberOfBytesWritten);
857  BOOST_CHECK(result == TimelinePacketStatus::BufferExhaustion);
858  BOOST_CHECK(numberOfBytesWritten == 0);
859 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)

◆ BOOST_AUTO_TEST_CASE() [28/28]

BOOST_AUTO_TEST_CASE ( TimelineEventPacketTest4  )

Definition at line 861 of file TimelinePacketTests.cpp.

References BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), armnn::profiling::Ok, armnn::profiling::ReadBytes(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), armnn::profiling::uint32_t_size, and armnn::profiling::WriteTimelineEventBinaryPacket().

862 {
863  std::vector<unsigned char> buffer(512, 0);
864 
865  const uint64_t timestamp = 456789u;
866  const std::thread::id threadId = std::this_thread::get_id();
867  const uint64_t profilingGuid = 123456u;
868  unsigned int numberOfBytesWritten = 789u;
870  threadId,
871  profilingGuid,
872  buffer.data(),
873  boost::numeric_cast<unsigned int>(buffer.size()),
874  numberOfBytesWritten);
875  BOOST_CHECK(result == TimelinePacketStatus::Ok);
876  BOOST_CHECK(numberOfBytesWritten == 36);
877 
878  unsigned int uint32_t_size = sizeof(uint32_t);
879  unsigned int uint64_t_size = sizeof(uint64_t);
880  unsigned int threadId_size = sizeof(std::thread::id);
881 
882  // Check the packet header
883  unsigned int offset = 0;
884  uint32_t packetHeaderWord0 = ReadUint32(buffer.data(), offset);
885  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
886  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
887  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
888  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
889  BOOST_CHECK(packetFamily == 1);
890  BOOST_CHECK(packetClass == 0);
891  BOOST_CHECK(packetType == 1);
892  BOOST_CHECK(streamId == 0);
893 
894  offset += uint32_t_size;
895  uint32_t packetHeaderWord1 = ReadUint32(buffer.data(), offset);
896  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
897  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
898  BOOST_CHECK(sequenceNumbered == 0);
899  BOOST_CHECK(dataLength == 28);
900 
901  // Check the decl_id
902  offset += uint32_t_size;
903  uint32_t readDeclId = ReadUint32(buffer.data(), offset);
904  BOOST_CHECK(readDeclId == 4);
905 
906  // Check the timestamp
907  offset += uint32_t_size;
908  uint64_t readTimestamp = ReadUint64(buffer.data(), offset);
909  BOOST_CHECK(readTimestamp == timestamp);
910 
911  // Check the thread id
912  offset += uint64_t_size;
913  std::vector<uint8_t> readThreadId(threadId_size, 0);
914  ReadBytes(buffer.data(), offset, threadId_size, readThreadId.data());
915  BOOST_CHECK(readThreadId == threadId);
916 
917  // Check the profiling GUID
918  offset += threadId_size;
919  uint64_t readProfilingGuid = ReadUint64(buffer.data(), offset);
920  BOOST_CHECK(readProfilingGuid == profilingGuid);
921 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
TimelinePacketStatus WriteTimelineEventBinaryPacket(uint64_t timestamp, std::thread::id threadId, uint64_t profilingGuid, unsigned char *buffer, unsigned int bufferSize, unsigned int &numberOfBytesWritten)
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])