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