ArmNN
 20.02
SendTimelinePacketTests.cpp File Reference
#include "ProfilingMocks.hpp"
#include <BufferManager.hpp>
#include <ProfilingService.hpp>
#include <ProfilingUtils.hpp>
#include <SendTimelinePacket.hpp>
#include <TimelinePacketWriterFactory.hpp>
#include <boost/test/unit_test.hpp>
#include <LabelsAndEventClasses.hpp>
#include <functional>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (SendTimelineMessageDirectoryPackageTest)
 
 BOOST_AUTO_TEST_CASE (SendTimelineEntityWithEventClassPacketTest)
 
 BOOST_AUTO_TEST_CASE (SendEventClassAfterTimelineEntityPacketTest)
 
 BOOST_AUTO_TEST_CASE (SendTimelinePacketTests2)
 
 BOOST_AUTO_TEST_CASE (SendTimelinePacketTests3)
 
 BOOST_AUTO_TEST_CASE (GetGuidsFromProfilingService)
 
 BOOST_AUTO_TEST_CASE (GetTimelinePackerWriterFromProfilingService)
 
 BOOST_AUTO_TEST_CASE (CheckStaticGuidsAndEvents)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/8]

BOOST_AUTO_TEST_CASE ( SendTimelineMessageDirectoryPackageTest  )

Definition at line 23 of file SendTimelinePacketTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), TimelinePacketWriterFactory::GetSendTimelinePacket(), SwTraceMessage::m_ArgNames, SwTraceMessage::m_ArgTypes, SwTraceMessage::m_Id, SwTraceMessage::m_Name, SwTraceMessage::m_UiName, armnn::profiling::ReadSwTraceMessage(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint8(), and armnn::profiling::uint32_t_size.

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 }
uint8_t ReadUint8(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
SwTraceMessage ReadSwTraceMessage(const unsigned char *packetBuffer, unsigned int &offset)
std::vector< std::string > m_ArgNames
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [2/8]

BOOST_AUTO_TEST_CASE ( SendTimelineEntityWithEventClassPacketTest  )

Definition at line 137 of file SendTimelinePacketTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), TimelinePacketWriterFactory::GetSendTimelinePacket(), MockBufferManager::MarkRead(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), and armnn::profiling::uint32_t_size.

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 
175  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
176 
177  uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
178  uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
179 
180  BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
181  BOOST_CHECK(entityBinaryPacketDataLength == 24);
182 
183  // Check the decl_id
184  offset += uint32_t_size;
185  uint32_t entitytDecId = ReadUint32(packetBuffer, offset);
186 
187  BOOST_CHECK(entitytDecId == uint32_t(1));
188 
189  // Check the profiling GUID
190  offset += uint32_t_size;
191  uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset);
192 
193  BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid);
194 
195  // Reading TimelineEventClassBinaryPacket
196  offset += uint64_t_size;
197 
198  uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset);
199  BOOST_CHECK(eventClassDeclId == uint32_t(2));
200 
201  // Check the profiling GUID
202  offset += uint32_t_size;
203  readProfilingGuid = ReadUint64(packetBuffer, offset);
204  BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid);
205 
206  bufferManager.MarkRead(packetBuffer);
207 }
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [3/8]

BOOST_AUTO_TEST_CASE ( SendEventClassAfterTimelineEntityPacketTest  )

Definition at line 209 of file SendTimelinePacketTests.cpp.

References BOOST_CHECK(), MockBufferManager::GetReadableBuffer(), TimelinePacketWriterFactory::GetSendTimelinePacket(), MockBufferManager::MarkRead(), armnn::profiling::ReadBytes(), armnn::profiling::ReadUint32(), armnn::profiling::ReadUint64(), and armnn::profiling::uint32_t_size.

210 {
211  unsigned int uint32_t_size = sizeof(uint32_t);
212  unsigned int uint64_t_size = sizeof(uint64_t);
213  unsigned int threadId_size = sizeof(std::thread::id);
214 
215  MockBufferManager bufferManager(512);
216  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
217  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
218 
219  // Send TimelineEntityClassBinaryPacket
220  const uint64_t entityBinaryPacketProfilingGuid = 123456u;
221  sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
222 
223  // Commit the buffer
224  sendTimelinePacket->Commit();
225 
226  // Get the readable buffer
227  auto packetBuffer = bufferManager.GetReadableBuffer();
228 
229  // Check the packet header
230  unsigned int offset = 0;
231 
232  // Reading TimelineEntityClassBinaryPacket
233  uint32_t entityBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
234  uint32_t entityBinaryPacketFamily = (entityBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
235  uint32_t entityBinaryPacketClass = (entityBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
236  uint32_t entityBinaryPacketType = (entityBinaryPacketHeaderWord0 >> 16) & 0x00000007;
237  uint32_t entityBinaryPacketStreamId = (entityBinaryPacketHeaderWord0 >> 0) & 0x00000007;
238 
239  BOOST_CHECK(entityBinaryPacketFamily == 1);
240  BOOST_CHECK(entityBinaryPacketClass == 0);
241  BOOST_CHECK(entityBinaryPacketType == 1);
242  BOOST_CHECK(entityBinaryPacketStreamId == 0);
243 
244  offset += uint32_t_size;
245  uint32_t entityBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
246  uint32_t entityBinaryPacketSequenceNumbered = (entityBinaryPacketHeaderWord1 >> 24) & 0x00000001;
247  uint32_t entityBinaryPacketDataLength = (entityBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
248  BOOST_CHECK(entityBinaryPacketSequenceNumbered == 0);
249  BOOST_CHECK(entityBinaryPacketDataLength == 12);
250 
251  // Check the decl_id
252  offset += uint32_t_size;
253  uint32_t entitytDecId = ReadUint32(packetBuffer, offset);
254 
255  BOOST_CHECK(entitytDecId == uint32_t(1));
256 
257  // Check the profiling GUID
258  offset += uint32_t_size;
259  uint64_t readProfilingGuid = ReadUint64(packetBuffer, offset);
260 
261  BOOST_CHECK(readProfilingGuid == entityBinaryPacketProfilingGuid);
262 
263  bufferManager.MarkRead(packetBuffer);
264 
265  // Send TimelineEventClassBinaryPacket
266  const uint64_t eventClassBinaryPacketProfilingGuid = 789123u;
267  sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid);
268 
269  // Commit the buffer
270  sendTimelinePacket->Commit();
271 
272  // Get the readable buffer
273  packetBuffer = bufferManager.GetReadableBuffer();
274 
275  // Check the packet header
276  offset = 0;
277 
278  // Reading TimelineEventClassBinaryPacket
279  uint32_t eventClassBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
280  uint32_t eventClassBinaryPacketFamily = (eventClassBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
281  uint32_t eventClassBinaryPacketClass = (eventClassBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
282  uint32_t eventClassBinaryPacketType = (eventClassBinaryPacketHeaderWord0 >> 16) & 0x00000007;
283  uint32_t eventClassBinaryPacketStreamId = (eventClassBinaryPacketHeaderWord0 >> 0) & 0x00000007;
284 
285  BOOST_CHECK(eventClassBinaryPacketFamily == 1);
286  BOOST_CHECK(eventClassBinaryPacketClass == 0);
287  BOOST_CHECK(eventClassBinaryPacketType == 1);
288  BOOST_CHECK(eventClassBinaryPacketStreamId == 0);
289 
290  offset += uint32_t_size;
291  uint32_t eventClassBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
292  uint32_t eventClassBinaryPacketSequenceNumbered = (eventClassBinaryPacketHeaderWord1 >> 24) & 0x00000001;
293  uint32_t eventClassBinaryPacketDataLength = (eventClassBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
294  BOOST_CHECK(eventClassBinaryPacketSequenceNumbered == 0);
295  BOOST_CHECK(eventClassBinaryPacketDataLength == 12);
296 
297  offset += uint32_t_size;
298  uint32_t eventClassDeclId = ReadUint32(packetBuffer, offset);
299  BOOST_CHECK(eventClassDeclId == uint32_t(2));
300 
301  // Check the profiling GUID
302  offset += uint32_t_size;
303  readProfilingGuid = ReadUint64(packetBuffer, offset);
304  BOOST_CHECK(readProfilingGuid == eventClassBinaryPacketProfilingGuid);
305 
306  bufferManager.MarkRead(packetBuffer);
307 
308  // Send TimelineEventBinaryPacket
309  const uint64_t timestamp = 456789u;
310  const std::thread::id threadId = std::this_thread::get_id();
311  const uint64_t eventProfilingGuid = 123456u;
312  sendTimelinePacket->SendTimelineEventBinaryPacket(timestamp, threadId, eventProfilingGuid);
313 
314  // Commit the buffer
315  sendTimelinePacket->Commit();
316 
317  // Get the readable buffer
318  packetBuffer = bufferManager.GetReadableBuffer();
319 
320  // Check the packet header
321  offset = 0;
322 
323  // Reading TimelineEventBinaryPacket
324  uint32_t eventBinaryPacketHeaderWord0 = ReadUint32(packetBuffer, offset);
325  uint32_t eventBinaryPacketFamily = (eventBinaryPacketHeaderWord0 >> 26) & 0x0000003F;
326  uint32_t eventBinaryPacketClass = (eventBinaryPacketHeaderWord0 >> 19) & 0x0000007F;
327  uint32_t eventBinaryPacketType = (eventBinaryPacketHeaderWord0 >> 16) & 0x00000007;
328  uint32_t eventBinaryPacketStreamId = (eventBinaryPacketHeaderWord0 >> 0) & 0x00000007;
329 
330  BOOST_CHECK(eventBinaryPacketFamily == 1);
331  BOOST_CHECK(eventBinaryPacketClass == 0);
332  BOOST_CHECK(eventBinaryPacketType == 1);
333  BOOST_CHECK(eventBinaryPacketStreamId == 0);
334 
335  offset += uint32_t_size;
336  uint32_t eventBinaryPacketHeaderWord1 = ReadUint32(packetBuffer, offset);
337  uint32_t eventBinaryPacketSequenceNumbered = (eventBinaryPacketHeaderWord1 >> 24) & 0x00000001;
338  uint32_t eventBinaryPacketDataLength = (eventBinaryPacketHeaderWord1 >> 0) & 0x00FFFFFF;
339  BOOST_CHECK(eventBinaryPacketSequenceNumbered == 0);
340  BOOST_CHECK(eventBinaryPacketDataLength == 28);
341 
342  // Check the decl_id
343  offset += uint32_t_size;
344  uint32_t eventDeclId = ReadUint32(packetBuffer, offset);
345  BOOST_CHECK(eventDeclId == 4);
346 
347  // Check the timestamp
348  offset += uint32_t_size;
349  uint64_t eventTimestamp = ReadUint64(packetBuffer, offset);
350  BOOST_CHECK(eventTimestamp == timestamp);
351 
352  // Check the thread id
353  offset += uint64_t_size;
354  std::vector<uint8_t> readThreadId(threadId_size, 0);
355  ReadBytes(packetBuffer, offset, threadId_size, readThreadId.data());
356  BOOST_CHECK(readThreadId == threadId);
357 
358  // Check the profiling GUID
359  offset += threadId_size;
360  readProfilingGuid = ReadUint64(packetBuffer, offset);
361  BOOST_CHECK(readProfilingGuid == eventProfilingGuid);
362 }
void ReadBytes(const IPacketBufferPtr &packetBuffer, unsigned int offset, unsigned int valueSize, uint8_t outValue[])
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)

◆ BOOST_AUTO_TEST_CASE() [4/8]

BOOST_AUTO_TEST_CASE ( SendTimelinePacketTests2  )

Definition at line 364 of file SendTimelinePacketTests.cpp.

References TimelinePacketWriterFactory::GetSendTimelinePacket().

365 {
366  MockBufferManager bufferManager(40);
367  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
368  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
369 
370  BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineMessageDirectoryPackage(),
372 }

◆ BOOST_AUTO_TEST_CASE() [5/8]

BOOST_AUTO_TEST_CASE ( SendTimelinePacketTests3  )

Definition at line 374 of file SendTimelinePacketTests.cpp.

References MockBufferManager::GetReadableBuffer(), and TimelinePacketWriterFactory::GetSendTimelinePacket().

375 {
376  MockBufferManager bufferManager(512);
377  TimelinePacketWriterFactory timelinePacketWriterFactory(bufferManager);
378  std::unique_ptr<ISendTimelinePacket> sendTimelinePacket = timelinePacketWriterFactory.GetSendTimelinePacket();
379 
380  // Send TimelineEntityClassBinaryPacket
381  const uint64_t entityBinaryPacketProfilingGuid = 123456u;
382  sendTimelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
383 
384  // Commit the buffer
385  sendTimelinePacket->Commit();
386 
387  // Get the readable buffer
388  auto packetBuffer = bufferManager.GetReadableBuffer();
389 
390  // Send TimelineEventClassBinaryPacket
391  const uint64_t eventClassBinaryPacketProfilingGuid = 789123u;
392  BOOST_CHECK_THROW(sendTimelinePacket->SendTimelineEventClassBinaryPacket(eventClassBinaryPacketProfilingGuid),
394 }

◆ BOOST_AUTO_TEST_CASE() [6/8]

BOOST_AUTO_TEST_CASE ( GetGuidsFromProfilingService  )

Definition at line 396 of file SendTimelinePacketTests.cpp.

References BOOST_CHECK(), ProfilingService::GenerateStaticId(), ProfilingService::Instance(), IRuntime::CreationOptions::ExternalProfilingOptions::m_EnableProfiling, ProfilingService::NextGuid(), options, profilingService, and ProfilingService::ResetExternalProfilingOptions().

397 {
399  options.m_EnableProfiling = true;
400  ProfilingService& profilingService = ProfilingService::Instance();
401  profilingService.ResetExternalProfilingOptions(options, true);
402  ProfilingStaticGuid staticGuid = profilingService.GenerateStaticId("dummy");
403  std::hash<std::string> hasher;
404  uint64_t hash = static_cast<uint64_t>(hasher("dummy"));
405  ProfilingStaticGuid expectedStaticValue(hash | MIN_STATIC_GUID);
406  BOOST_CHECK(staticGuid == expectedStaticValue);
407  ProfilingDynamicGuid dynamicGuid = profilingService.NextGuid();
408  uint64_t dynamicGuidValue = static_cast<uint64_t>(dynamicGuid);
409  ++dynamicGuidValue;
410  ProfilingDynamicGuid expectedDynamicValue(dynamicGuidValue);
411  dynamicGuid = profilingService.NextGuid();
412  BOOST_CHECK(dynamicGuid == expectedDynamicValue);
413 }
Strongly typed guids to distinguish between those generated at runtime, and those that are statically...
Definition: Types.hpp:294
ProfilingService & profilingService
ProfilingDynamicGuid NextGuid() override
Return the next random Guid in the sequence.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
ProfilingStaticGuid GenerateStaticId(const std::string &str) override
Create a ProfilingStaticGuid based on a hash of the string.

◆ BOOST_AUTO_TEST_CASE() [7/8]

BOOST_AUTO_TEST_CASE ( GetTimelinePackerWriterFromProfilingService  )

Definition at line 415 of file SendTimelinePacketTests.cpp.

References BOOST_CHECK(), ProfilingService::GetSendTimelinePacket(), ProfilingService::Instance(), IRuntime::CreationOptions::ExternalProfilingOptions::m_EnableProfiling, options, profilingService, and ProfilingService::ResetExternalProfilingOptions().

416 {
418  options.m_EnableProfiling = true;
419  ProfilingService& profilingService = ProfilingService::Instance();
420  profilingService.ResetExternalProfilingOptions(options, true);
421 
422  std::unique_ptr<ISendTimelinePacket> writer = profilingService.GetSendTimelinePacket();
423  BOOST_CHECK(writer != nullptr);
424 }
ProfilingService & profilingService
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
std::unique_ptr< ISendTimelinePacket > GetSendTimelinePacket() const override
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
armnn::Runtime::CreationOptions::ExternalProfilingOptions options

◆ BOOST_AUTO_TEST_CASE() [8/8]

BOOST_AUTO_TEST_CASE ( CheckStaticGuidsAndEvents  )

Definition at line 426 of file SendTimelinePacketTests.cpp.

References LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS, LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS, BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), LabelsAndEventClasses::INDEX_GUID, LabelsAndEventClasses::INDEX_LABEL, LabelsAndEventClasses::NAME_GUID, LabelsAndEventClasses::NAME_LABEL, LabelsAndEventClasses::TYPE_GUID, and LabelsAndEventClasses::TYPE_LABEL.

427 {
428  BOOST_CHECK("name" == LabelsAndEventClasses::NAME_LABEL);
429  BOOST_CHECK("type" == LabelsAndEventClasses::TYPE_LABEL);
430  BOOST_CHECK("index" == LabelsAndEventClasses::INDEX_LABEL);
431 
432  std::hash<std::string> hasher;
433 
434  uint64_t hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::NAME_LABEL));
435  ProfilingStaticGuid expectedNameGuid(hash | MIN_STATIC_GUID);
436  BOOST_CHECK(LabelsAndEventClasses::NAME_GUID == expectedNameGuid);
437 
438  hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::TYPE_LABEL));
439  ProfilingStaticGuid expectedTypeGuid(hash | MIN_STATIC_GUID);
440  BOOST_CHECK(LabelsAndEventClasses::TYPE_GUID == expectedTypeGuid);
441 
442  hash = static_cast<uint64_t>(hasher(LabelsAndEventClasses::INDEX_LABEL));
443  ProfilingStaticGuid expectedIndexGuid(hash | MIN_STATIC_GUID);
444  BOOST_CHECK(LabelsAndEventClasses::INDEX_GUID == expectedIndexGuid);
445 
446  hash = static_cast<uint64_t>(hasher("ARMNN_PROFILING_SOL"));
447  ProfilingStaticGuid expectedSol(hash | MIN_STATIC_GUID);
448  BOOST_CHECK(LabelsAndEventClasses::ARMNN_PROFILING_SOL_EVENT_CLASS == expectedSol);
449 
450  hash = static_cast<uint64_t>(hasher("ARMNN_PROFILING_EOL"));
451  ProfilingStaticGuid expectedEol(hash | MIN_STATIC_GUID);
452  BOOST_CHECK(LabelsAndEventClasses::ARMNN_PROFILING_EOL_EVENT_CLASS == expectedEol);
453 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)