blob: b9e0e45c0ac5fff3147220edf59261bf9d938138 [file] [log] [blame]
David Monahanc1536d62020-02-12 15:52:35 +00001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Finn Williams032bc742020-02-12 11:02:34 +00006#include "CounterDirectory.hpp"
7#include "CounterIdMap.hpp"
8#include "Holder.hpp"
David Monahanc1536d62020-02-12 15:52:35 +00009#include "MockBackend.hpp"
10#include "MockBackendId.hpp"
Finn Williams032bc742020-02-12 11:02:34 +000011#include "PeriodicCounterCapture.hpp"
12#include "PeriodicCounterSelectionCommandHandler.hpp"
13#include "ProfilingStateMachine.hpp"
14#include "ProfilingUtils.hpp"
15#include "RequestCounterDirectoryCommandHandler.hpp"
David Monahanc1536d62020-02-12 15:52:35 +000016
Jan Eilers8eb25602020-03-09 12:13:48 +000017#include <armnn/utility/IgnoreUnused.hpp>
David Monahanc1536d62020-02-12 15:52:35 +000018#include <armnn/BackendId.hpp>
Finn Williams032bc742020-02-12 11:02:34 +000019#include <armnn/Logging.hpp>
Colm Donelanfcb802b2020-02-13 20:47:08 +000020#include <armnn/profiling/ISendTimelinePacket.hpp>
Finn Williams032bc742020-02-12 11:02:34 +000021
22#include <boost/algorithm/string.hpp>
23#include <boost/numeric/conversion/cast.hpp>
David Monahanc1536d62020-02-12 15:52:35 +000024#include <boost/test/unit_test.hpp>
25#include <vector>
26
Finn Williams032bc742020-02-12 11:02:34 +000027#include <cstdint>
28#include <limits>
29#include <backends/BackendProfiling.hpp>
30
31using namespace armnn::profiling;
32
33class ReadCounterVals : public IReadCounterValues
34{
35 virtual bool IsCounterRegistered(uint16_t counterUid) const override
36 {
37 return (counterUid > 4 && counterUid < 11);
38 }
39 virtual uint16_t GetCounterCount() const override
40 {
41 return 1;
42 }
43 virtual uint32_t GetCounterValue(uint16_t counterUid) const override
44 {
45 return counterUid;
46 }
47};
48
49class MockBackendSendCounterPacket : public ISendCounterPacket
50{
51public:
52 using IndexValuePairsVector = std::vector<CounterValue>;
53
54 /// Create and write a StreamMetaDataPacket in the buffer
55 virtual void SendStreamMetaDataPacket() {}
56
57 /// Create and write a CounterDirectoryPacket from the parameters to the buffer.
58 virtual void SendCounterDirectoryPacket(const ICounterDirectory& counterDirectory)
59 {
Jan Eilers8eb25602020-03-09 12:13:48 +000060 armnn::IgnoreUnused(counterDirectory);
Finn Williams032bc742020-02-12 11:02:34 +000061 }
62
63 /// Create and write a PeriodicCounterCapturePacket from the parameters to the buffer.
64 virtual void SendPeriodicCounterCapturePacket(uint64_t timestamp, const IndexValuePairsVector& values)
65 {
66 m_timestamps.emplace_back(Timestamp{timestamp, values});
67 }
68
69 /// Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
70 virtual void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod,
71 const std::vector<uint16_t>& selectedCounterIds)
72 {
Jan Eilers8eb25602020-03-09 12:13:48 +000073 armnn::IgnoreUnused(capturePeriod);
74 armnn::IgnoreUnused(selectedCounterIds);
Finn Williams032bc742020-02-12 11:02:34 +000075 }
76
77 std::vector<Timestamp> GetTimestamps()
78 {
79 return m_timestamps;
80 }
81
82 void ClearTimestamps()
83 {
84 m_timestamps.clear();
85 }
86
87private:
88 std::vector<Timestamp> m_timestamps;
89};
90
91Packet PacketWriter(uint32_t period, std::vector<uint16_t> countervalues)
92{
93 const uint32_t packetId = 0x40000;
94 uint32_t offset = 0;
95 uint32_t dataLength = static_cast<uint32_t>(4 + countervalues.size() * 2);
96 std::unique_ptr<unsigned char[]> uniqueData = std::make_unique<unsigned char[]>(dataLength);
97 unsigned char* data1 = reinterpret_cast<unsigned char*>(uniqueData.get());
98
99 WriteUint32(data1, offset, period);
100 offset += 4;
101 for (auto countervalue : countervalues)
102 {
103 WriteUint16(data1, offset, countervalue);
104 offset += 2;
105 }
106
107 return {packetId, dataLength, uniqueData};
108}
109
David Monahanc1536d62020-02-12 15:52:35 +0000110BOOST_AUTO_TEST_SUITE(BackendProfilingTestSuite)
111
112BOOST_AUTO_TEST_CASE(BackendProfilingCounterRegisterMockBackendTest)
113{
114 // Reset the profiling service to the uninitialized state
115 armnn::IRuntime::CreationOptions options;
116 options.m_ProfilingOptions.m_EnableProfiling = true;
117 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
118 profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true);
119
120 armnn::MockBackendInitialiser initialiser;
121 // Create a runtime
122 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
123
124 // Check if the MockBackends 3 dummy counters {0, 1, 2-5 (four cores)} are registered
125 armnn::BackendId mockId = armnn::MockBackendId();
126 const armnn::profiling::ICounterMappings& counterMap = profilingService.GetCounterMappings();
127 BOOST_CHECK(counterMap.GetGlobalId(0, mockId) == 5);
128 BOOST_CHECK(counterMap.GetGlobalId(1, mockId) == 6);
129 BOOST_CHECK(counterMap.GetGlobalId(2, mockId) == 7);
130 BOOST_CHECK(counterMap.GetGlobalId(3, mockId) == 8);
131 BOOST_CHECK(counterMap.GetGlobalId(4, mockId) == 9);
132 BOOST_CHECK(counterMap.GetGlobalId(5, mockId) == 10);
133 options.m_ProfilingOptions.m_EnableProfiling = false;
134 profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
135}
136
Finn Williams032bc742020-02-12 11:02:34 +0000137BOOST_AUTO_TEST_CASE(TestBackendCounters)
138{
139 Holder holder;
140 PacketVersionResolver packetVersionResolver;
141 ProfilingStateMachine stateMachine;
142 ReadCounterVals readCounterVals;
143 CounterIdMap counterIdMap;
144 MockBackendSendCounterPacket sendCounterPacket;
145
146 const armnn::BackendId cpuAccId(armnn::Compute::CpuAcc);
147 const armnn::BackendId gpuAccId(armnn::Compute::GpuAcc);
148
149 armnn::IRuntime::CreationOptions options;
150 options.m_ProfilingOptions.m_EnableProfiling = true;
151
152 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
153
154 std::unique_ptr<armnn::profiling::IBackendProfiling> cpuBackendProfilingPtr =
155 std::make_unique<BackendProfiling>(options, profilingService, cpuAccId);
156 std::unique_ptr<armnn::profiling::IBackendProfiling> gpuBackendProfilingPtr =
157 std::make_unique<BackendProfiling>(options, profilingService, gpuAccId);
158
159 std::shared_ptr<armnn::profiling::IBackendProfilingContext> cpuProfilingContextPtr =
160 std::make_shared<armnn::MockBackendProfilingContext>(cpuBackendProfilingPtr);
161 std::shared_ptr<armnn::profiling::IBackendProfilingContext> gpuProfilingContextPtr =
162 std::make_shared<armnn::MockBackendProfilingContext>(gpuBackendProfilingPtr);
163
164 std::unordered_map<armnn::BackendId,
165 std::shared_ptr<armnn::profiling::IBackendProfilingContext>> backendProfilingContexts;
166
167 backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr;
168 backendProfilingContexts[gpuAccId] = gpuProfilingContextPtr;
169
170 uint16_t globalId = 5;
171
172 counterIdMap.RegisterMapping(globalId++, 0, cpuAccId);
173 counterIdMap.RegisterMapping(globalId++, 1, cpuAccId);
174 counterIdMap.RegisterMapping(globalId++, 2, cpuAccId);
175
176 counterIdMap.RegisterMapping(globalId++, 0, gpuAccId);
177 counterIdMap.RegisterMapping(globalId++, 1, gpuAccId);
178 counterIdMap.RegisterMapping(globalId++, 2, gpuAccId);
179
180 backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr;
181 backendProfilingContexts[gpuAccId] = gpuProfilingContextPtr;
182
183 PeriodicCounterCapture periodicCounterCapture(holder, sendCounterPacket, readCounterVals,
184 counterIdMap, backendProfilingContexts);
185
186 uint16_t maxArmnnCounterId = 4;
187
188 PeriodicCounterSelectionCommandHandler periodicCounterSelectionCommandHandler(0,
189 4,
190 packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
191 backendProfilingContexts,
192 counterIdMap,
193 holder,
194 maxArmnnCounterId,
195 periodicCounterCapture,
196 readCounterVals,
197 sendCounterPacket,
198 stateMachine);
199
200 stateMachine.TransitionToState(ProfilingState::NotConnected);
201 stateMachine.TransitionToState(ProfilingState::WaitingForAck);
202 stateMachine.TransitionToState(ProfilingState::Active);
203
204 uint32_t period = 12345u;
205
206 std::vector<uint16_t> cpuCounters{5, 6, 7};
207 std::vector<uint16_t> gpuCounters{8, 9, 10};
208
209 // Request only gpu counters
210 periodicCounterSelectionCommandHandler(PacketWriter(period, gpuCounters));
211 periodicCounterCapture.Stop();
212
213 std::set<armnn::BackendId> activeIds = holder.GetCaptureData().GetActiveBackends();
214 BOOST_CHECK(activeIds.size() == 1);
215 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
216
217 std::vector<Timestamp> recievedTimestamp = sendCounterPacket.GetTimestamps();
218
219 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
220 BOOST_CHECK(recievedTimestamp.size() == 1);
221 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == gpuCounters.size());
222 for (unsigned long i=0; i< gpuCounters.size(); ++i)
223 {
224 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == gpuCounters[i]);
225 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
226 }
227 sendCounterPacket.ClearTimestamps();
228
229 // Request only cpu counters
230 periodicCounterSelectionCommandHandler(PacketWriter(period, cpuCounters));
231 periodicCounterCapture.Stop();
232
233 activeIds = holder.GetCaptureData().GetActiveBackends();
234 BOOST_CHECK(activeIds.size() == 1);
235 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
236
237 recievedTimestamp = sendCounterPacket.GetTimestamps();
238
239 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
240 BOOST_CHECK(recievedTimestamp.size() == 1);
241 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size());
242 for (unsigned long i=0; i< cpuCounters.size(); ++i)
243 {
244 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]);
245 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
246 }
247 sendCounterPacket.ClearTimestamps();
248
249 // Request combination of cpu & gpu counters with new period
250 period = 12222u;
251 periodicCounterSelectionCommandHandler(PacketWriter(period, {cpuCounters[0], gpuCounters[2],
252 gpuCounters[1], cpuCounters[1], gpuCounters[0]}));
253 periodicCounterCapture.Stop();
254
255 activeIds = holder.GetCaptureData().GetActiveBackends();
256 BOOST_CHECK(activeIds.size() == 2);
257 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
258 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
259
260 recievedTimestamp = sendCounterPacket.GetTimestamps();
261
262 BOOST_CHECK(recievedTimestamp[0].timestamp == period);
263 BOOST_CHECK(recievedTimestamp[1].timestamp == period);
264
265 BOOST_CHECK(recievedTimestamp.size() == 2);
266 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2);
267 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size());
268
269 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]);
270 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u);
271 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[1]);
272 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 2u);
273
274 for (unsigned long i=0; i< gpuCounters.size(); ++i)
275 {
276 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]);
277 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u);
278 }
279
280 sendCounterPacket.ClearTimestamps();
281
282 // Request all counters
283 std::vector<uint16_t> counterValues;
284 counterValues.insert(counterValues.begin(), cpuCounters.begin(), cpuCounters.end());
285 counterValues.insert(counterValues.begin(), gpuCounters.begin(), gpuCounters.end());
286
287 periodicCounterSelectionCommandHandler(PacketWriter(period, counterValues));
288 periodicCounterCapture.Stop();
289
290 activeIds = holder.GetCaptureData().GetActiveBackends();
291 BOOST_CHECK(activeIds.size() == 2);
292 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
293 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
294
295 recievedTimestamp = sendCounterPacket.GetTimestamps();
296
297 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == cpuCounters.size());
298 for (unsigned long i=0; i< cpuCounters.size(); ++i)
299 {
300 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterId == cpuCounters[i]);
301 BOOST_CHECK(recievedTimestamp[0].counterValues[i].counterValue == i + 1u);
302 }
303
304 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == gpuCounters.size());
305 for (unsigned long i=0; i< gpuCounters.size(); ++i)
306 {
307 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterId == gpuCounters[i]);
308 BOOST_CHECK(recievedTimestamp[1].counterValues[i].counterValue == i + 1u);
309 }
310 sendCounterPacket.ClearTimestamps();
311
312 // Request random counters with duplicates and invalid counters
313 counterValues = {0, 0, 200, cpuCounters[2], gpuCounters[0],3 ,30, cpuCounters[0],cpuCounters[2], gpuCounters[1], 3,
314 90, 0, 30, gpuCounters[0], gpuCounters[0]};
315
316 periodicCounterSelectionCommandHandler(PacketWriter(period, counterValues));
317 periodicCounterCapture.Stop();
318
319 activeIds = holder.GetCaptureData().GetActiveBackends();
320 BOOST_CHECK(activeIds.size() == 2);
321 BOOST_CHECK(activeIds.find(cpuAccId) != activeIds.end());
322 BOOST_CHECK(activeIds.find(gpuAccId) != activeIds.end());
323
324 recievedTimestamp = sendCounterPacket.GetTimestamps();
325
326 BOOST_CHECK(recievedTimestamp.size() == 2);
327
328 BOOST_CHECK(recievedTimestamp[0].counterValues.size() == 2);
329
330 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterId == cpuCounters[0]);
331 BOOST_CHECK(recievedTimestamp[0].counterValues[0].counterValue == 1u);
332 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterId == cpuCounters[2]);
333 BOOST_CHECK(recievedTimestamp[0].counterValues[1].counterValue == 3u);
334
335 BOOST_CHECK(recievedTimestamp[1].counterValues.size() == 2);
336
337 BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterId == gpuCounters[0]);
338 BOOST_CHECK(recievedTimestamp[1].counterValues[0].counterValue == 1u);
339 BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterId == gpuCounters[1]);
340 BOOST_CHECK(recievedTimestamp[1].counterValues[1].counterValue == 2u);
341
342 sendCounterPacket.ClearTimestamps();
343
344 // Request no counters
345 periodicCounterSelectionCommandHandler(PacketWriter(period, {}));
346 periodicCounterCapture.Stop();
347
348 activeIds = holder.GetCaptureData().GetActiveBackends();
349 BOOST_CHECK(activeIds.size() == 0);
350
351 recievedTimestamp = sendCounterPacket.GetTimestamps();
352 BOOST_CHECK(recievedTimestamp.size() == 0);
353
354 sendCounterPacket.ClearTimestamps();
355
356 // Request period of zero
357 periodicCounterSelectionCommandHandler(PacketWriter(0, counterValues));
358 periodicCounterCapture.Stop();
359
360 activeIds = holder.GetCaptureData().GetActiveBackends();
361 BOOST_CHECK(activeIds.size() == 0);
362
363 recievedTimestamp = sendCounterPacket.GetTimestamps();
364 BOOST_CHECK(recievedTimestamp.size() == 0);
365}
366
367BOOST_AUTO_TEST_CASE(TestBackendCounterLogging)
368{
369 std::stringstream ss;
370
371 struct StreamRedirector
372 {
373 public:
374 StreamRedirector(std::ostream &stream, std::streambuf *newStreamBuffer)
375 : m_Stream(stream), m_BackupBuffer(m_Stream.rdbuf(newStreamBuffer))
376 {}
377
378 ~StreamRedirector()
379 { m_Stream.rdbuf(m_BackupBuffer); }
380
381 private:
382 std::ostream &m_Stream;
383 std::streambuf *m_BackupBuffer;
384 };
385
386 Holder holder;
387 PacketVersionResolver packetVersionResolver;
388 ProfilingStateMachine stateMachine;
389 ReadCounterVals readCounterVals;
390 StreamRedirector redirect(std::cout, ss.rdbuf());
391 CounterIdMap counterIdMap;
392 MockBackendSendCounterPacket sendCounterPacket;
393
394 const armnn::BackendId cpuAccId(armnn::Compute::CpuAcc);
395 const armnn::BackendId gpuAccId(armnn::Compute::GpuAcc);
396
397 armnn::IRuntime::CreationOptions options;
398 options.m_ProfilingOptions.m_EnableProfiling = true;
399
400 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
401
402 std::unique_ptr<armnn::profiling::IBackendProfiling> cpuBackendProfilingPtr =
403 std::make_unique<BackendProfiling>(options, profilingService, cpuAccId);
404
405 std::shared_ptr<armnn::profiling::IBackendProfilingContext> cpuProfilingContextPtr =
406 std::make_shared<armnn::MockBackendProfilingContext>(cpuBackendProfilingPtr);
407
408 std::unordered_map<armnn::BackendId,
409 std::shared_ptr<armnn::profiling::IBackendProfilingContext>> backendProfilingContexts;
410
411 uint16_t globalId = 5;
412 counterIdMap.RegisterMapping(globalId, 0, cpuAccId);
413 backendProfilingContexts[cpuAccId] = cpuProfilingContextPtr;
414
415 PeriodicCounterCapture periodicCounterCapture(holder, sendCounterPacket, readCounterVals,
416 counterIdMap, backendProfilingContexts);
417
418 uint16_t maxArmnnCounterId = 4;
419
420 PeriodicCounterSelectionCommandHandler periodicCounterSelectionCommandHandler(0,
421 4,
422 packetVersionResolver.ResolvePacketVersion(0, 4).GetEncodedValue(),
423 backendProfilingContexts,
424 counterIdMap,
425 holder,
426 maxArmnnCounterId,
427 periodicCounterCapture,
428 readCounterVals,
429 sendCounterPacket,
430 stateMachine);
431
432 stateMachine.TransitionToState(ProfilingState::NotConnected);
433 stateMachine.TransitionToState(ProfilingState::WaitingForAck);
434 stateMachine.TransitionToState(ProfilingState::Active);
435
436 uint32_t period = 15939u;
437
438 armnn::SetAllLoggingSinks(true, false, false);
439 SetLogFilter(armnn::LogSeverity::Warning);
440 periodicCounterSelectionCommandHandler(PacketWriter(period, {5}));
441 periodicCounterCapture.Stop();
442 SetLogFilter(armnn::LogSeverity::Fatal);
443
444 BOOST_CHECK(boost::contains(ss.str(), "ActivateCounters example test error"));
445}
446
Colm Donelanfcb802b2020-02-13 20:47:08 +0000447BOOST_AUTO_TEST_CASE(BackendProfilingContextGetSendTimelinePacket)
448{
449 // Reset the profiling service to the uninitialized state
450 armnn::IRuntime::CreationOptions options;
451 options.m_ProfilingOptions.m_EnableProfiling = true;
452 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
453 profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true);
454
455 armnn::MockBackendInitialiser initialiser;
456 // Create a runtime. During this the mock backend will be registered and context returned.
457 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
458 armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance();
459 armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext();
460 // Check that there is a valid context set.
461 BOOST_CHECK(mockBackEndProfilingContext);
462 armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface =
463 mockBackEndProfilingContext->GetBackendProfiling();
464 BOOST_CHECK(backendProfilingIface);
465
466 // Now for the meat of the test. We're just going to send a random packet and make sure there
467 // are no exceptions or errors. The sending of packets is already tested in SendTimelinePacketTests.
468 std::unique_ptr<armnn::profiling::ISendTimelinePacket> timelinePacket =
469 backendProfilingIface->GetSendTimelinePacket();
470 // Send TimelineEntityClassBinaryPacket
471 const uint64_t entityBinaryPacketProfilingGuid = 123456u;
472 timelinePacket->SendTimelineEntityBinaryPacket(entityBinaryPacketProfilingGuid);
473 timelinePacket->Commit();
474
475 // Reset the profiling servie after the test.
476 options.m_ProfilingOptions.m_EnableProfiling = false;
477 profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
478}
479
480BOOST_AUTO_TEST_CASE(GetProfilingGuidGenerator)
481{
482 // Reset the profiling service to the uninitialized state
483 armnn::IRuntime::CreationOptions options;
484 options.m_ProfilingOptions.m_EnableProfiling = true;
485 armnn::profiling::ProfilingService& profilingService = armnn::profiling::ProfilingService::Instance();
486 profilingService.ConfigureProfilingService(options.m_ProfilingOptions, true);
487
488 armnn::MockBackendInitialiser initialiser;
489 // Create a runtime. During this the mock backend will be registered and context returned.
490 armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
491 armnn::MockBackendProfilingService mockProfilingService = armnn::MockBackendProfilingService::Instance();
492 armnn::MockBackendProfilingContext *mockBackEndProfilingContext = mockProfilingService.GetContext();
493 // Check that there is a valid context set.
494 BOOST_CHECK(mockBackEndProfilingContext);
495 armnn::IBackendInternal::IBackendProfilingPtr& backendProfilingIface =
496 mockBackEndProfilingContext->GetBackendProfiling();
497 BOOST_CHECK(backendProfilingIface);
498
499 // Get the Guid generator and check the getting two Guid's results in the second being greater than the first.
500 armnn::profiling::IProfilingGuidGenerator& guidGenerator = backendProfilingIface->GetProfilingGuidGenerator();
501 BOOST_CHECK(backendProfilingIface);
502 const armnn::profiling::ProfilingDynamicGuid& firstGuid = guidGenerator.NextGuid();
503 BOOST_CHECK(firstGuid);
504 const armnn::profiling::ProfilingDynamicGuid& secondGuid = guidGenerator.NextGuid();
505 BOOST_CHECK(secondGuid > firstGuid);
506
507 // Reset the profiling servie after the test.
508 options.m_ProfilingOptions.m_EnableProfiling = false;
509 profilingService.ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
510}
511
512BOOST_AUTO_TEST_SUITE_END()