ArmNN  NotReleased
SendTimelinePacketTests.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ProfilingMocks.hpp"
7 
8 #include <BufferManager.hpp>
9 #include <ProfilingService.hpp>
10 #include <ProfilingUtils.hpp>
11 #include <SendTimelinePacket.hpp>
13 
14 #include <boost/test/unit_test.hpp>
16 
17 #include <functional>
18 
19 using namespace armnn::profiling;
20 
21 BOOST_AUTO_TEST_SUITE(SendTimelinePacketTests)
22 
23 BOOST_AUTO_TEST_CASE(SendTimelineMessageDirectoryPackageTest)
24 {
25  MockBufferManager mockBuffer(512);
26  TimelinePacketWriterFactory timelinePacketWriterFactory(mockBuffer);
27  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
28 
29  sendTimelinePacket->SendTimelineMessageDirectoryPackage();
30 
31  // Get the readable buffer
32  auto packetBuffer = mockBuffer.GetReadableBuffer();
33 
34  unsigned int uint8_t_size = sizeof(uint8_t);
35  unsigned int uint32_t_size = sizeof(uint32_t);
36  unsigned int uint64_t_size = sizeof(uint64_t);
37  unsigned int threadId_size = sizeof(std::thread::id);
38 
39  // Check the packet header
40  unsigned int offset = 0;
41  uint32_t packetHeaderWord0 = ReadUint32(packetBuffer, offset);
42  uint32_t packetFamily = (packetHeaderWord0 >> 26) & 0x0000003F;
43  uint32_t packetClass = (packetHeaderWord0 >> 19) & 0x0000007F;
44  uint32_t packetType = (packetHeaderWord0 >> 16) & 0x00000007;
45  uint32_t streamId = (packetHeaderWord0 >> 0) & 0x00000007;
46 
47  BOOST_CHECK(packetFamily == 1);
48  BOOST_CHECK(packetClass == 0);
49  BOOST_CHECK(packetType == 0);
50  BOOST_CHECK(streamId == 0);
51 
52  offset += uint32_t_size;
53  uint32_t packetHeaderWord1 = ReadUint32(packetBuffer, offset);
54  uint32_t sequenceNumbered = (packetHeaderWord1 >> 24) & 0x00000001;
55  uint32_t dataLength = (packetHeaderWord1 >> 0) & 0x00FFFFFF;
56  BOOST_CHECK(sequenceNumbered == 0);
57  BOOST_CHECK(dataLength == 419);
58 
59  offset += uint32_t_size;
60  uint8_t readStreamVersion = ReadUint8(packetBuffer, offset);
61  BOOST_CHECK(readStreamVersion == 4);
62  offset += uint8_t_size;
63  uint8_t readPointerBytes = ReadUint8(packetBuffer, offset);
64  BOOST_CHECK(readPointerBytes == uint64_t_size);
65  offset += uint8_t_size;
66  uint8_t readThreadIdBytes = ReadUint8(packetBuffer, offset);
67  BOOST_CHECK(readThreadIdBytes == threadId_size);
68 
69  offset += uint8_t_size;
70  uint32_t DeclCount = ReadUint32(packetBuffer, offset);
71  BOOST_CHECK(DeclCount == 5);
72 
73  offset += uint32_t_size;
74  SwTraceMessage swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset);
75 
76  BOOST_CHECK(swTraceMessage.m_Id == 0);
77  BOOST_CHECK(swTraceMessage.m_Name == "declareLabel");
78  BOOST_CHECK(swTraceMessage.m_UiName == "declare label");
79  BOOST_CHECK(swTraceMessage.m_ArgTypes.size() == 2);
80  BOOST_CHECK(swTraceMessage.m_ArgTypes[0] == 'p');
81  BOOST_CHECK(swTraceMessage.m_ArgTypes[1] == 's');
82  BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 2);
83  BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
84  BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "value");
85 
86  swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset);
87 
88  BOOST_CHECK(swTraceMessage.m_Id == 1);
89  BOOST_CHECK(swTraceMessage.m_Name == "declareEntity");
90  BOOST_CHECK(swTraceMessage.m_UiName == "declare entity");
91  BOOST_CHECK(swTraceMessage.m_ArgTypes.size() == 1);
92  BOOST_CHECK(swTraceMessage.m_ArgTypes[0] == 'p');
93  BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 1);
94  BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
95 
96  swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset);
97 
98  BOOST_CHECK(swTraceMessage.m_Id == 2);
99  BOOST_CHECK(swTraceMessage.m_Name == "declareEventClass");
100  BOOST_CHECK(swTraceMessage.m_UiName == "declare event class");
101  BOOST_CHECK(swTraceMessage.m_ArgTypes.size() == 1);
102  BOOST_CHECK(swTraceMessage.m_ArgTypes[0] == 'p');
103  BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 1);
104  BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "guid");
105 
106  swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset);
107 
108  BOOST_CHECK(swTraceMessage.m_Id == 3);
109  BOOST_CHECK(swTraceMessage.m_Name == "declareRelationship");
110  BOOST_CHECK(swTraceMessage.m_UiName == "declare relationship");
111  BOOST_CHECK(swTraceMessage.m_ArgTypes.size() == 4);
112  BOOST_CHECK(swTraceMessage.m_ArgTypes[0] == 'I');
113  BOOST_CHECK(swTraceMessage.m_ArgTypes[1] == 'p');
114  BOOST_CHECK(swTraceMessage.m_ArgTypes[2] == 'p');
115  BOOST_CHECK(swTraceMessage.m_ArgTypes[3] == 'p');
116  BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 4);
117  BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "relationshipType");
118  BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "relationshipGuid");
119  BOOST_CHECK(swTraceMessage.m_ArgNames[2] == "headGuid");
120  BOOST_CHECK(swTraceMessage.m_ArgNames[3] == "tailGuid");
121 
122  swTraceMessage = ReadSwTraceMessage(packetBuffer->GetReadableData(), offset);
123 
124  BOOST_CHECK(swTraceMessage.m_Id == 4);
125  BOOST_CHECK(swTraceMessage.m_Name == "declareEvent");
126  BOOST_CHECK(swTraceMessage.m_UiName == "declare event");
127  BOOST_CHECK(swTraceMessage.m_ArgTypes.size() == 3);
128  BOOST_CHECK(swTraceMessage.m_ArgTypes[0] == '@');
129  BOOST_CHECK(swTraceMessage.m_ArgTypes[1] == 't');
130  BOOST_CHECK(swTraceMessage.m_ArgTypes[2] == 'p');
131  BOOST_CHECK(swTraceMessage.m_ArgNames.size() == 3);
132  BOOST_CHECK(swTraceMessage.m_ArgNames[0] == "timestamp");
133  BOOST_CHECK(swTraceMessage.m_ArgNames[1] == "threadId");
134  BOOST_CHECK(swTraceMessage.m_ArgNames[2] == "eventGuid");
135 }
136 
137 BOOST_AUTO_TEST_CASE(SendTimelineEntityPlusEventClassBinaryPacketTest)
138 {
139  MockBufferManager bufferManager(40);
140  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
141  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
142 
143  const uint64_t entityBinaryPacketProfilingGuid = 123456u;
144  sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
145 
146  const uint64_t eventClassBinaryPacketProfilingGuid = 789123u;
147  sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid);
148 
149  // Commit the messages
150  sendTimelinePacket->Commit();
151 
152  // Get the readable buffer
153  auto packetBuffer = bufferManager.GetReadableBuffer();
154 
155  unsigned int uint32_t_size = sizeof(uint32_t);
156  unsigned int uint64_t_size = sizeof(uint64_t);
157 
158  // Check the packet header
159  unsigned int offset = 0;
160 
161  // Reading TimelineEntityClassBinaryPacket
162  uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
163  uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
164  uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
165  uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
166  uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
167 
168  BOOST_CHECK(entityBinaryPacketFamily == 1);
169  BOOST_CHECK(entityBinaryPacketClass == 0);
170  BOOST_CHECK(entityBinaryPacketType == 1);
171  BOOST_CHECK(entityBinaryPacketStreamId == 0);
172 
173  offset += uint32_t_size;
174  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
175  uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
176  uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
177  BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
178  BOOST_CHECK(entityBinaryPacketDataLength == 12);
179 
180  // Check the decl_id
181  offset += uint32_t_size;
182  uint32_t entitytDecId = ReadUint32(packetBuffer, offset);
183 
184  BOOST_CHECK(entitytDecId == uint32_t(1));
185 
186  // Check the profiling GUID
187  offset += uint32_t_size;
188  uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset);
189 
190  BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid);
191 
192  // Reading TimelineEventClassBinaryPacket
193  offset += uint64_t_size;
194  uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
195  uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
196  uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
197  uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007;
198  uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007;
199 
200  BOOST_CHECK(eventClassBinaryPacketFamily == 1);
201  BOOST_CHECK(eventClassBinaryPacketClass == 0);
202  BOOST_CHECK(eventClassBinaryPacketType == 1);
203  BOOST_CHECK(eventClassBinaryPacketStreamId == 0);
204 
205  offset += uint32_t_size;
206  uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
207  uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001;
208  uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
209  BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0);
210  BOOST_CHECK(eventClassBinaryPacketDataLength == 12);
211 
212  offset += uint32_t_size;
213  uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset);
214  BOOST_CHECK(eventClassDeclId == uint32_t(2));
215 
216  // Check the profiling GUID
217  offset += uint32_t_size;
218  readProfilingGuid = ReadUint64(packetBuffer, offset);
219  BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid);
220 
221  bufferManager.MarkRead(packetBuffer);
222 }
223 
224 BOOST_AUTO_TEST_CASE(SendTimelinePacketTests1)
225 {
226  unsigned int uint32_t_size = sizeof(uint32_t);
227  unsigned int uint64_t_size = sizeof(uint64_t);
228  unsigned int threadId_size = sizeof(std::thread::id);
229 
230  MockBufferManager bufferManager(512);
231  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
232  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
233 
234  // Send TimelineEntityClassBinaryPacket
235  const uint64_t entityBinaryPacketProfilingGuid = 123456u;
236  sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
237 
238  // Commit the buffer
239  sendTimelinePacket->Commit();
240 
241  // Get the readable buffer
242  auto packetBuffer = bufferManager.GetReadableBuffer();
243 
244  // Check the packet header
245  unsigned int offset = 0;
246 
247  // Reading TimelineEntityClassBinaryPacket
248  uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
249  uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
250  uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
251  uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
252  uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
253 
254  BOOST_CHECK(entityBinaryPacketFamily == 1);
255  BOOST_CHECK(entityBinaryPacketClass == 0);
256  BOOST_CHECK(entityBinaryPacketType == 1);
257  BOOST_CHECK(entityBinaryPacketStreamId == 0);
258 
259  offset += uint32_t_size;
260  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
261  uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
262  uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
263  BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
264  BOOST_CHECK(entityBinaryPacketDataLength == 12);
265 
266  // Check the decl_id
267  offset += uint32_t_size;
268  uint32_t entitytDecId = ReadUint32(packetBuffer, offset);
269 
270  BOOST_CHECK(entitytDecId == uint32_t(1));
271 
272  // Check the profiling GUID
273  offset += uint32_t_size;
274  uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset);
275 
276  BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid);
277 
278  bufferManager.MarkRead(packetBuffer);
279 
280  // Send TimelineEventClassBinaryPacket
281  const uint64_t eventClassBinaryPacketProfilingGuid = 789123u;
282  sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid);
283 
284  // Commit the buffer
285  sendTimelinePacket->Commit();
286 
287  // Get the readable buffer
288  packetBuffer = bufferManager.GetReadableBuffer();
289 
290  // Check the packet header
291  offset = 0;
292 
293  // Reading TimelineEventClassBinaryPacket
294  uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
295  uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
296  uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
297  uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007;
298  uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007;
299 
300  BOOST_CHECK(eventClassBinaryPacketFamily == 1);
301  BOOST_CHECK(eventClassBinaryPacketClass == 0);
302  BOOST_CHECK(eventClassBinaryPacketType == 1);
303  BOOST_CHECK(eventClassBinaryPacketStreamId == 0);
304 
305  offset += uint32_t_size;
306  uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
307  uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001;
308  uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
309  BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0);
310  BOOST_CHECK(eventClassBinaryPacketDataLength == 12);
311 
312  offset += uint32_t_size;
313  uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset);
314  BOOST_CHECK(eventClassDeclId == uint32_t(2));
315 
316  // Check the profiling GUID
317  offset += uint32_t_size;
318  readProfilingGuid = ReadUint64(packetBuffer, offset);
319  BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid);
320 
321  bufferManager.MarkRead(packetBuffer);
322 
323  // Send TimelineEventBinaryPacket
324  const uint64_t timestamp = 456789u;
325  const std::thread::id threadId = std::this_thread::get_id();
326  const uint64_t eventProfilingGuid = 123456u;
327  sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid);
328 
329  // Commit the buffer
330  sendTimelinePacket->Commit();
331 
332  // Get the readable buffer
333  packetBuffer = bufferManager.GetReadableBuffer();
334 
335  // Check the packet header
336  offset = 0;
337 
338  // Reading TimelineEventBinaryPacket
339  uint32_t eventBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
340  uint32_t eventBinaryPacketFamily = (eventBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
341  uint32_t eventBinaryPacketClass = (eventBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
342  uint32_t eventBinaryPacketType = (eventBinaryPacketHeaderWord0 >> 16) & 0x00000007;
343  uint32_t eventBinaryPacketStreamId = (eventBinaryPacketHeaderWord0 >> 0) & 0x00000007;
344 
345  BOOST_CHECK(eventBinaryPacketFamily == 1);
346  BOOST_CHECK(eventBinaryPacketClass == 0);
347  BOOST_CHECK(eventBinaryPacketType == 1);
348  BOOST_CHECK(eventBinaryPacketStreamId == 0);
349 
350  offset += uint32_t_size;
351  uint32_t eventBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
352  uint32_t eventBinaryPacketSequenceNumbered = (eventBinaryPacketHeaderWord1 >> 24) & 0x00000001;
353  uint32_t eventBinaryPacketDataLength = (eventBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
354  BOOST_CHECK(eventBinaryPacketSequenceNumbered == 0);
355  BOOST_CHECK(eventBinaryPacketDataLength == 28);
356 
357  // Check the decl_id
358  offset += uint32_t_size;
359  uint32_t eventDeclId = ReadUint32(packetBuffer, offset);
360  BOOST_CHECK(eventDeclId == 4);
361 
362  // Check the timestamp
363  offset += uint32_t_size;
364  uint64_t eventTimestamp = ReadUint64(packetBuffer, offset);
365  BOOST_CHECK(eventTimestamp == timestamp);
366 
367  // Check the thread id
368  offset += uint64_t_size;
369  std::vector<uint8_t> readThreadId(threadId_size, 0);
370  ReadBytes(packetBuffer, offset, threadId_size, readThreadId.data());
371  BOOST_CHECK(readThreadId == threadId);
372 
373  // Check the profiling GUID
374  offset += threadId_size;
375  readProfilingGuid = ReadUint64(packetBuffer, offset);
376  BOOST_CHECK(readProfilingGuid == eventProfilingGuid);
377 }
378 
379 BOOST_AUTO_TEST_CASE(SendTimelinePacketTests2)
380 {
381  MockBufferManager bufferManager(40);
382  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
383  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
384 
385  BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineMessageDirectoryPackage(),
387 }
388 
389 BOOST_AUTO_TEST_CASE(SendTimelinePacketTests3)
390 {
391  MockBufferManager bufferManager(512);
392  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
393  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
394 
395  // Send TimelineEntityClassBinaryPacket
396  const uint64_t entityBinaryPacketProfilingGuid = 123456u;
397  sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
398 
399  // Commit the buffer
400  sendTimelinePacket->Commit();
401 
402  // Get the readable buffer
403  auto packetBuffer = bufferManager.GetReadableBuffer();
404 
405  // Send TimelineEventClassBinaryPacket
406  const uint64_t eventClassBinaryPacketProfilingGuid = 789123u;
407  BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid),
409 }
410 
411 BOOST_AUTO_TEST_CASE(GetGuidsFromProfilingService)
412 {
414  options.m_EnableProfiling = true;
416  profilingService.ResetExternalProfilingOptions(options, true);
417  ProfilingStaticGuid staticGuid = profilingService.GenerateStaticId("dummy");
418  std::hash<std::string> hasher;
419  uint64_t hash = static_cast<uint64_t>(hasher("dummy"));
420  ProfilingStaticGuid expectedStaticValue(hash | MIN_STATIC_GUID);
421  BOOST_CHECK(staticGuid == expectedStaticValue);
422  ProfilingDynamicGuid dynamicGuid = profilingService.NextGuid();
423  uint64_t dynamicGuidValue = static_cast<uint64_t>(dynamicGuid);
424  ++dynamicGuidValue;
425  ProfilingDynamicGuid expectedDynamicValue(dynamicGuidValue);
426  dynamicGuid = profilingService.NextGuid();
427  BOOST_CHECK(dynamicGuid == expectedDynamicValue);
428 }
429 
430 BOOST_AUTO_TEST_CASE(GetTimelinePackerWriterFromProfilingService)
431 {
433  options.m_EnableProfiling = true;
435  profilingService.ResetExternalProfilingOptions(options, true);
436 
437  std::unique_ptr<ISendTimelinePacket> writer = profilingService.GetSendTimelinePacket();
438  BOOST_CHECK(writer != nullptr);
439 }
440 
441 BOOST_AUTO_TEST_CASE(CheckStaticGuidsAndEvents)
442 {
446 
447  std::hash<std::string> hasher;
448 
449  uint64_t hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::NAME_LABEL));
450  ProfilingStaticGuid expectedNameGuid(hash | MIN_STATIC_GUID);
451  BOOST_CHECK(LabelsAndEventClasses::NAME_GUID == expectedNameGuid);
452 
453  hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::TYPE_LABEL));
454  ProfilingStaticGuid expectedTypeGuid(hash | MIN_STATIC_GUID);
455  BOOST_CHECK(LabelsAndEventClasses::TYPE_GUID == expectedTypeGuid);
456 
457  hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::INDEX_LABEL));
458  ProfilingStaticGuid expectedIndexGuid(hash | MIN_STATIC_GUID);
459  BOOST_CHECK(LabelsAndEventClasses::INDEX_GUID == expectedIndexGuid);
460 
461  hash = static_cast<uint64_t>(hasher("ARMNN_PROFILING_SOL"));
462  ProfilingStaticGuid expectedSol(hash | MIN_STATIC_GUID);
464 
465  hash = static_cast<uint64_t>(hasher("ARMNN_PROFILING_EOL"));
466  ProfilingStaticGuid expectedEol(hash | MIN_STATIC_GUID);
468 }
469 
static ARMNN_DLLEXPORT ProfilingStaticGuid INDEX_GUID
static ARMNN_DLLEXPORT std::string INDEX_LABEL
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_EOL_EVENT_CLASS
std::vector< std::string > m_ArgNames
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const
static ARMNN_DLLEXPORT std::string NAME_LABEL
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
void MarkRead(IPacketBufferPtr &packetBuffer) override
static ARMNN_DLLEXPORT ProfilingStaticGuid TYPE_GUID
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
static ProfilingService & Instance()
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_AUTO_TEST_SUITE_END()
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
IPacketBufferPtr GetReadableBuffer() override
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:291
static ARMNN_DLLEXPORT ProfilingStaticGuid ARMNN_PROFILING_SOL_EVENT_CLASS
uint8_t ReadUint8(const IPacketBufferPtr &packetBuffer, unsigned int offset)
static ARMNN_DLLEXPORT std::string TYPE_LABEL
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override
ProfilingService & profilingService
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
static ARMNN_DLLEXPORT ProfilingStaticGuid NAME_GUID
SwTraceMessage ReadSwTraceMessage(const unsigned char *packetBuffer, unsigned int &offset)