blob: 57d8dd1ace5659fd80376aff4ccdc3a5bb10a571 [file] [log] [blame]
Francis Murtagh1f7db452019-08-14 09:49:34 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "../CommandHandlerKey.hpp"
Francis Murtagh11f99b42019-08-16 11:28:52 +01007#include "../CommandHandlerFunctor.hpp"
Francis Murtagh94d79152019-08-16 17:45:07 +01008#include "../CommandHandlerRegistry.hpp"
Nikhil Rajd88e47c2019-08-19 10:04:23 +01009#include "../EncodeVersion.hpp"
Francis Murtagh68f78d82019-09-04 16:42:29 +010010#include "../Holder.hpp"
Nikhil Rajbc626052019-08-15 15:49:45 +010011#include "../Packet.hpp"
Aron Virginas-Tare898db92019-08-22 12:56:34 +010012#include "../PacketVersionResolver.hpp"
Nikhil Raj3ecc5102019-09-03 15:55:33 +010013#include "../ProfilingStateMachine.hpp"
Aron Virginas-Tare898db92019-08-22 12:56:34 +010014
Keith Davis02356de2019-08-26 18:28:17 +010015#include "../ProfilingService.hpp"
16
Aron Virginas-Tare898db92019-08-22 12:56:34 +010017#include <boost/test/unit_test.hpp>
Francis Murtagh1f7db452019-08-14 09:49:34 +010018
Nikhil Rajbc626052019-08-15 15:49:45 +010019#include <cstdint>
20#include <cstring>
Aron Virginas-Tare898db92019-08-22 12:56:34 +010021#include <limits>
Francis Murtagh11f99b42019-08-16 11:28:52 +010022#include <map>
Aron Virginas-Tare898db92019-08-22 12:56:34 +010023#include <random>
Nikhil Raj3ecc5102019-09-03 15:55:33 +010024#include <thread>
Francis Murtagh1f7db452019-08-14 09:49:34 +010025
26BOOST_AUTO_TEST_SUITE(ExternalProfiling)
27
Aron Virginas-Tare898db92019-08-22 12:56:34 +010028using namespace armnn::profiling;
29
Francis Murtagh1f7db452019-08-14 09:49:34 +010030BOOST_AUTO_TEST_CASE(CheckCommandHandlerKeyComparisons)
31{
32 CommandHandlerKey testKey0(1, 1);
33 CommandHandlerKey testKey1(1, 1);
34 CommandHandlerKey testKey2(1, 1);
35 CommandHandlerKey testKey3(0, 0);
36 CommandHandlerKey testKey4(2, 2);
37 CommandHandlerKey testKey5(0, 2);
38
39 BOOST_CHECK(testKey1<testKey4);
40 BOOST_CHECK(testKey1>testKey3);
41 BOOST_CHECK(testKey1<=testKey4);
42 BOOST_CHECK(testKey1>=testKey3);
43 BOOST_CHECK(testKey1<=testKey2);
44 BOOST_CHECK(testKey1>=testKey2);
45 BOOST_CHECK(testKey1==testKey2);
46 BOOST_CHECK(testKey1==testKey1);
47
48 BOOST_CHECK(!(testKey1==testKey5));
49 BOOST_CHECK(!(testKey1!=testKey1));
50 BOOST_CHECK(testKey1!=testKey5);
51
52 BOOST_CHECK(testKey1==testKey2 && testKey2==testKey1);
53 BOOST_CHECK(testKey0==testKey1 && testKey1==testKey2 && testKey0==testKey2);
54
55 BOOST_CHECK(testKey1.GetPacketId()==1);
56 BOOST_CHECK(testKey1.GetVersion()==1);
57
58 std::vector<CommandHandlerKey> vect =
Aron Virginas-Tare898db92019-08-22 12:56:34 +010059 {
60 CommandHandlerKey(0,1), CommandHandlerKey(2,0), CommandHandlerKey(1,0),
61 CommandHandlerKey(2,1), CommandHandlerKey(1,1), CommandHandlerKey(0,1),
62 CommandHandlerKey(2,0), CommandHandlerKey(0,0)
63 };
Francis Murtagh1f7db452019-08-14 09:49:34 +010064
65 std::sort(vect.begin(), vect.end());
66
67 std::vector<CommandHandlerKey> expectedVect =
Aron Virginas-Tare898db92019-08-22 12:56:34 +010068 {
69 CommandHandlerKey(0,0), CommandHandlerKey(0,1), CommandHandlerKey(0,1),
70 CommandHandlerKey(1,0), CommandHandlerKey(1,1), CommandHandlerKey(2,0),
71 CommandHandlerKey(2,0), CommandHandlerKey(2,1)
72 };
Francis Murtagh1f7db452019-08-14 09:49:34 +010073
74 BOOST_CHECK(vect == expectedVect);
75}
76
Nikhil Rajd88e47c2019-08-19 10:04:23 +010077BOOST_AUTO_TEST_CASE(CheckEncodeVersion)
78{
Aron Virginas-Tare898db92019-08-22 12:56:34 +010079 Version version1(12);
Nikhil Rajd88e47c2019-08-19 10:04:23 +010080
81 BOOST_CHECK(version1.GetMajor() == 0);
82 BOOST_CHECK(version1.GetMinor() == 0);
83 BOOST_CHECK(version1.GetPatch() == 12);
84
Aron Virginas-Tare898db92019-08-22 12:56:34 +010085 Version version2(4108);
Nikhil Rajd88e47c2019-08-19 10:04:23 +010086
87 BOOST_CHECK(version2.GetMajor() == 0);
88 BOOST_CHECK(version2.GetMinor() == 1);
89 BOOST_CHECK(version2.GetPatch() == 12);
90
Aron Virginas-Tare898db92019-08-22 12:56:34 +010091 Version version3(4198412);
Nikhil Rajd88e47c2019-08-19 10:04:23 +010092
93 BOOST_CHECK(version3.GetMajor() == 1);
94 BOOST_CHECK(version3.GetMinor() == 1);
95 BOOST_CHECK(version3.GetPatch() == 12);
96
Aron Virginas-Tare898db92019-08-22 12:56:34 +010097 Version version4(0);
Nikhil Rajd88e47c2019-08-19 10:04:23 +010098
99 BOOST_CHECK(version4.GetMajor() == 0);
100 BOOST_CHECK(version4.GetMinor() == 0);
101 BOOST_CHECK(version4.GetPatch() == 0);
102
Aron Virginas-Tare898db92019-08-22 12:56:34 +0100103 Version version5(1, 0, 0);
Nikhil Rajd88e47c2019-08-19 10:04:23 +0100104 BOOST_CHECK(version5.GetEncodedValue() == 4194304);
105}
106
Nikhil Rajbc626052019-08-15 15:49:45 +0100107BOOST_AUTO_TEST_CASE(CheckPacketClass)
108{
109 const char* data = "test";
110 unsigned int length = static_cast<unsigned int>(std::strlen(data));
111
112 Packet packetTest1(472580096,length,data);
113 BOOST_CHECK_THROW(Packet packetTest2(472580096,0,""), armnn::Exception);
114
115 Packet packetTest3(472580096,0, nullptr);
116
117 BOOST_CHECK(packetTest1.GetLength() == length);
118 BOOST_CHECK(packetTest1.GetData() == data);
119
120 BOOST_CHECK(packetTest1.GetPacketFamily() == 7);
121 BOOST_CHECK(packetTest1.GetPacketId() == 43);
122 BOOST_CHECK(packetTest1.GetPacketType() == 3);
123 BOOST_CHECK(packetTest1.GetPacketClass() == 5);
124}
125
Francis Murtagh94d79152019-08-16 17:45:07 +0100126// Create Derived Classes
127class TestFunctorA : public CommandHandlerFunctor
128{
129public:
130 using CommandHandlerFunctor::CommandHandlerFunctor;
131
132 int GetCount() { return m_Count; }
133
134 void operator()(const Packet& packet) override
135 {
136 m_Count++;
137 }
138
139private:
140 int m_Count = 0;
141};
142
143class TestFunctorB : public TestFunctorA
144{
145 using TestFunctorA::TestFunctorA;
146};
147
148class TestFunctorC : public TestFunctorA
149{
150 using TestFunctorA::TestFunctorA;
151};
152
Francis Murtagh11f99b42019-08-16 11:28:52 +0100153BOOST_AUTO_TEST_CASE(CheckCommandHandlerFunctor)
154{
Francis Murtagh11f99b42019-08-16 11:28:52 +0100155 // Hard code the version as it will be the same during a single profiling session
156 uint32_t version = 1;
157
158 TestFunctorA testFunctorA(461, version);
159 TestFunctorB testFunctorB(963, version);
160 TestFunctorC testFunctorC(983, version);
161
162 CommandHandlerKey keyA(testFunctorA.GetPacketId(), testFunctorA.GetVersion());
163 CommandHandlerKey keyB(testFunctorB.GetPacketId(), testFunctorB.GetVersion());
164 CommandHandlerKey keyC(testFunctorC.GetPacketId(), testFunctorC.GetVersion());
165
166 // Create the unwrapped map to simulate the Command Handler Registry
167 std::map<CommandHandlerKey, CommandHandlerFunctor*> registry;
168
169 registry.insert(std::make_pair(keyB, &testFunctorB));
170 registry.insert(std::make_pair(keyA, &testFunctorA));
171 registry.insert(std::make_pair(keyC, &testFunctorC));
172
173 // Check the order of the map is correct
174 auto it = registry.begin();
175 BOOST_CHECK(it->first==keyA);
176 it++;
177 BOOST_CHECK(it->first==keyB);
178 it++;
179 BOOST_CHECK(it->first==keyC);
180
181 Packet packetA(500000000, 0, nullptr);
182 Packet packetB(600000000, 0, nullptr);
183 Packet packetC(400000000, 0, nullptr);
184
185 // Check the correct operator of derived class is called
186 registry.at(CommandHandlerKey(packetA.GetPacketId(), version))->operator()(packetA);
187 BOOST_CHECK(testFunctorA.GetCount() == 1);
188 BOOST_CHECK(testFunctorB.GetCount() == 0);
189 BOOST_CHECK(testFunctorC.GetCount() == 0);
190
191 registry.at(CommandHandlerKey(packetB.GetPacketId(), version))->operator()(packetB);
192 BOOST_CHECK(testFunctorA.GetCount() == 1);
193 BOOST_CHECK(testFunctorB.GetCount() == 1);
194 BOOST_CHECK(testFunctorC.GetCount() == 0);
195
196 registry.at(CommandHandlerKey(packetC.GetPacketId(), version))->operator()(packetC);
197 BOOST_CHECK(testFunctorA.GetCount() == 1);
198 BOOST_CHECK(testFunctorB.GetCount() == 1);
199 BOOST_CHECK(testFunctorC.GetCount() == 1);
200}
201
Francis Murtagh94d79152019-08-16 17:45:07 +0100202BOOST_AUTO_TEST_CASE(CheckCommandHandlerRegistry)
203{
204 // Hard code the version as it will be the same during a single profiling session
205 uint32_t version = 1;
206
207 TestFunctorA testFunctorA(461, version);
208 TestFunctorB testFunctorB(963, version);
209 TestFunctorC testFunctorC(983, version);
210
211 // Create the Command Handler Registry
212 CommandHandlerRegistry registry;
213
214 // Register multiple different derived classes
215 registry.RegisterFunctor(&testFunctorA, testFunctorA.GetPacketId(), testFunctorA.GetVersion());
216 registry.RegisterFunctor(&testFunctorB, testFunctorB.GetPacketId(), testFunctorB.GetVersion());
217 registry.RegisterFunctor(&testFunctorC, testFunctorC.GetPacketId(), testFunctorC.GetVersion());
218
219 Packet packetA(500000000, 0, nullptr);
220 Packet packetB(600000000, 0, nullptr);
221 Packet packetC(400000000, 0, nullptr);
222
223 // Check the correct operator of derived class is called
224 registry.GetFunctor(packetA.GetPacketId(), version)->operator()(packetA);
225 BOOST_CHECK(testFunctorA.GetCount() == 1);
226 BOOST_CHECK(testFunctorB.GetCount() == 0);
227 BOOST_CHECK(testFunctorC.GetCount() == 0);
228
229 registry.GetFunctor(packetB.GetPacketId(), version)->operator()(packetB);
230 BOOST_CHECK(testFunctorA.GetCount() == 1);
231 BOOST_CHECK(testFunctorB.GetCount() == 1);
232 BOOST_CHECK(testFunctorC.GetCount() == 0);
233
234 registry.GetFunctor(packetC.GetPacketId(), version)->operator()(packetC);
235 BOOST_CHECK(testFunctorA.GetCount() == 1);
236 BOOST_CHECK(testFunctorB.GetCount() == 1);
237 BOOST_CHECK(testFunctorC.GetCount() == 1);
238
239 // Re-register an existing key with a new function
240 registry.RegisterFunctor(&testFunctorC, testFunctorA.GetPacketId(), version);
241 registry.GetFunctor(packetA.GetPacketId(), version)->operator()(packetC);
242 BOOST_CHECK(testFunctorA.GetCount() == 1);
243 BOOST_CHECK(testFunctorB.GetCount() == 1);
244 BOOST_CHECK(testFunctorC.GetCount() == 2);
245
246 // Check that non-existent key returns nullptr for its functor
247 BOOST_CHECK_THROW(registry.GetFunctor(0, 0), armnn::Exception);
248}
249
Aron Virginas-Tare898db92019-08-22 12:56:34 +0100250BOOST_AUTO_TEST_CASE(CheckPacketVersionResolver)
251{
252 // Set up random number generator for generating packetId values
253 std::random_device device;
254 std::mt19937 generator(device());
255 std::uniform_int_distribution<uint32_t> distribution(std::numeric_limits<uint32_t>::min(),
256 std::numeric_limits<uint32_t>::max());
257
258 // NOTE: Expected version is always 1.0.0, regardless of packetId
259 const Version expectedVersion(1, 0, 0);
260
261 PacketVersionResolver packetVersionResolver;
262
263 constexpr unsigned int numTests = 10u;
264
265 for (unsigned int i = 0u; i < numTests; ++i)
266 {
267 const uint32_t packetId = distribution(generator);
268 Version resolvedVersion = packetVersionResolver.ResolvePacketVersion(packetId);
269
270 BOOST_TEST(resolvedVersion == expectedVersion);
271 }
272}
Nikhil Raj3ecc5102019-09-03 15:55:33 +0100273void ProfilingCurrentStateThreadImpl(ProfilingStateMachine& states)
274{
275 ProfilingState newState = ProfilingState::NotConnected;
276 states.GetCurrentState();
277 states.TransitionToState(newState);
278}
279
280BOOST_AUTO_TEST_CASE(CheckProfilingStateMachine)
281{
282 ProfilingStateMachine profilingState1(ProfilingState::Uninitialised);
283 profilingState1.TransitionToState(ProfilingState::Uninitialised);
284 BOOST_CHECK(profilingState1.GetCurrentState() == ProfilingState::Uninitialised);
285
286 ProfilingStateMachine profilingState2(ProfilingState::Uninitialised);
287 profilingState2.TransitionToState(ProfilingState::NotConnected);
288 BOOST_CHECK(profilingState2.GetCurrentState() == ProfilingState::NotConnected);
289
290 ProfilingStateMachine profilingState3(ProfilingState::NotConnected);
291 profilingState3.TransitionToState(ProfilingState::NotConnected);
292 BOOST_CHECK(profilingState3.GetCurrentState() == ProfilingState::NotConnected);
293
294 ProfilingStateMachine profilingState4(ProfilingState::NotConnected);
295 profilingState4.TransitionToState(ProfilingState::WaitingForAck);
296 BOOST_CHECK(profilingState4.GetCurrentState() == ProfilingState::WaitingForAck);
297
298 ProfilingStateMachine profilingState5(ProfilingState::WaitingForAck);
299 profilingState5.TransitionToState(ProfilingState::WaitingForAck);
300 BOOST_CHECK(profilingState5.GetCurrentState() == ProfilingState::WaitingForAck);
301
302 ProfilingStateMachine profilingState6(ProfilingState::WaitingForAck);
303 profilingState6.TransitionToState(ProfilingState::Active);
304 BOOST_CHECK(profilingState6.GetCurrentState() == ProfilingState::Active);
305
306 ProfilingStateMachine profilingState7(ProfilingState::Active);
307 profilingState7.TransitionToState(ProfilingState::NotConnected);
308 BOOST_CHECK(profilingState7.GetCurrentState() == ProfilingState::NotConnected);
309
310 ProfilingStateMachine profilingState8(ProfilingState::Active);
311 profilingState8.TransitionToState(ProfilingState::Active);
312 BOOST_CHECK(profilingState8.GetCurrentState() == ProfilingState::Active);
313
314 ProfilingStateMachine profilingState9(ProfilingState::Uninitialised);
315 BOOST_CHECK_THROW(profilingState9.TransitionToState(ProfilingState::WaitingForAck),
316 armnn::Exception);
317
318 ProfilingStateMachine profilingState10(ProfilingState::Uninitialised);
319 BOOST_CHECK_THROW(profilingState10.TransitionToState(ProfilingState::Active),
320 armnn::Exception);
321
322 ProfilingStateMachine profilingState11(ProfilingState::NotConnected);
323 BOOST_CHECK_THROW(profilingState11.TransitionToState(ProfilingState::Uninitialised),
324 armnn::Exception);
325
326 ProfilingStateMachine profilingState12(ProfilingState::NotConnected);
327 BOOST_CHECK_THROW(profilingState12.TransitionToState(ProfilingState::Active),
328 armnn::Exception);
329
330 ProfilingStateMachine profilingState13(ProfilingState::WaitingForAck);
331 BOOST_CHECK_THROW(profilingState13.TransitionToState(ProfilingState::Uninitialised),
332 armnn::Exception);
333
334 ProfilingStateMachine profilingState14(ProfilingState::WaitingForAck);
335 BOOST_CHECK_THROW(profilingState14.TransitionToState(ProfilingState::NotConnected),
336 armnn::Exception);
337
338 ProfilingStateMachine profilingState15(ProfilingState::Active);
339 BOOST_CHECK_THROW(profilingState15.TransitionToState(ProfilingState::Uninitialised),
340 armnn::Exception);
341
342 ProfilingStateMachine profilingState16(armnn::profiling::ProfilingState::Active);
343 BOOST_CHECK_THROW(profilingState16.TransitionToState(ProfilingState::WaitingForAck),
344 armnn::Exception);
345
346 ProfilingStateMachine profilingState17(ProfilingState::Uninitialised);
347
348 std::thread thread1 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
349 std::thread thread2 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
350 std::thread thread3 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
351 std::thread thread4 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
352 std::thread thread5 (ProfilingCurrentStateThreadImpl,std::ref(profilingState17));
353
354 thread1.join();
355 thread2.join();
356 thread3.join();
357 thread4.join();
358 thread5.join();
359
360 BOOST_TEST((profilingState17.GetCurrentState() == ProfilingState::NotConnected));
361}
Aron Virginas-Tare898db92019-08-22 12:56:34 +0100362
Francis Murtagh68f78d82019-09-04 16:42:29 +0100363void CaptureDataWriteThreadImpl(Holder &holder, uint32_t capturePeriod, std::vector<uint16_t>& counterIds)
364{
365 holder.SetCaptureData(capturePeriod, counterIds);
366}
367
368void CaptureDataReadThreadImpl(Holder &holder, CaptureData& captureData)
369{
370 captureData = holder.GetCaptureData();
371}
372
373BOOST_AUTO_TEST_CASE(CheckCaptureDataHolder)
374{
375 std::vector<uint16_t> counterIds1 = {};
376 uint32_t capturePeriod1(1);
377 std::vector<uint16_t> counterIds2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
378 uint32_t capturePeriod2(2);
379 std::vector<uint16_t> counterIds3 = {4, 5, 5, 6};
380 uint32_t capturePeriod3(3);
381
382 // Check CaptureData functions
383 CaptureData capture;
384 BOOST_CHECK(capture.GetCapturePeriod() == 0);
385 BOOST_CHECK((capture.GetCounterIds()).empty());
386 capture.SetCapturePeriod(capturePeriod2);
387 capture.SetCounterIds(counterIds2);
388 BOOST_CHECK(capture.GetCapturePeriod() == capturePeriod2);
389 BOOST_CHECK(capture.GetCounterIds() == counterIds2);
390
391 Holder holder;
392 BOOST_CHECK((holder.GetCaptureData()).GetCapturePeriod() == 0);
393 BOOST_CHECK(((holder.GetCaptureData()).GetCounterIds()).empty());
394
395 // Check Holder functions
396 std::thread thread1(CaptureDataWriteThreadImpl, std::ref(holder), capturePeriod3, std::ref(counterIds3));
397 thread1.join();
398
399 BOOST_CHECK((holder.GetCaptureData()).GetCapturePeriod() == capturePeriod3);
400 BOOST_CHECK((holder.GetCaptureData()).GetCounterIds() == counterIds3);
401
402 CaptureData captureData;
403 std::thread thread2(CaptureDataReadThreadImpl, std::ref(holder), std::ref(captureData));
404 thread2.join();
405 BOOST_CHECK(captureData.GetCounterIds() == counterIds3);
406
407 std::thread thread3(CaptureDataWriteThreadImpl, std::ref(holder), capturePeriod2, std::ref(counterIds1));
Francis Murtagh06965692019-09-05 16:29:01 +0100408 std::thread thread4(CaptureDataWriteThreadImpl, std::ref(holder), capturePeriod1, std::ref(counterIds2));
Francis Murtagh68f78d82019-09-04 16:42:29 +0100409 thread3.join();
410 thread4.join();
Francis Murtagh06965692019-09-05 16:29:01 +0100411
412 std::thread thread5(CaptureDataReadThreadImpl, std::ref(holder), std::ref(captureData));
Francis Murtagh68f78d82019-09-04 16:42:29 +0100413 thread5.join();
414
415 // Check CaptureData was written/read correctly from multiple threads
416 std::vector<uint16_t> captureIds = captureData.GetCounterIds();
417 uint32_t capturePeriod = captureData.GetCapturePeriod();
418 if (captureIds == counterIds1)
419 {
420 BOOST_CHECK(capturePeriod == capturePeriod2);
421 }
422 else if (captureIds == counterIds2)
423 {
424 BOOST_CHECK(capturePeriod == capturePeriod1);
425 }
426 else
427 {
428 BOOST_ERROR("Error in CaptureData read/write.");
429 }
430
431 std::vector<uint16_t> readIds = holder.GetCaptureData().GetCounterIds();
432 BOOST_CHECK(readIds == counterIds1 || readIds == counterIds2);
433
434 // Check assignment operator
435 CaptureData assignableCaptureData;
436 assignableCaptureData.SetCapturePeriod(capturePeriod3);
437 assignableCaptureData.SetCounterIds(counterIds3);
438
439 CaptureData secondCaptureData;
440 secondCaptureData.SetCapturePeriod(capturePeriod2);
441 secondCaptureData.SetCounterIds(counterIds2);
442
443 BOOST_CHECK(secondCaptureData.GetCapturePeriod() == 2);
444 BOOST_CHECK(secondCaptureData.GetCounterIds() == counterIds2);
445
446 secondCaptureData = assignableCaptureData;
447 BOOST_CHECK(secondCaptureData.GetCapturePeriod() == 3);
448 BOOST_CHECK(secondCaptureData.GetCounterIds() == counterIds3);
449
450 // Check copy constructor
451 CaptureData copyConstructedCaptureData(assignableCaptureData);
452
453 BOOST_CHECK(copyConstructedCaptureData.GetCapturePeriod() == 3);
454 BOOST_CHECK(copyConstructedCaptureData.GetCounterIds() == counterIds3);
Keith Davis02356de2019-08-26 18:28:17 +0100455}
Francis Murtagh68f78d82019-09-04 16:42:29 +0100456
Keith Davis02356de2019-08-26 18:28:17 +0100457BOOST_AUTO_TEST_CASE(CheckProfilingServiceDisabled)
458{
459 armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
460 ProfilingService service(options);
461 BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
462 service.Run();
463 BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
464}
465
466
467BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabled)
468{
469 armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
470 options.m_EnableProfiling = true;
471 ProfilingService service(options);
472 BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected);
473 service.Run();
474 BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck);
475}
476
477
478BOOST_AUTO_TEST_CASE(CheckProfilingServiceEnabledRuntime)
479{
480 armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
481 ProfilingService service(options);
482 BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
483 service.Run();
484 BOOST_CHECK(service.GetCurrentState() == ProfilingState::Uninitialised);
485 service.m_Options.m_EnableProfiling = true;
486 service.Run();
487 BOOST_CHECK(service.GetCurrentState() == ProfilingState::NotConnected);
488 service.Run();
489 BOOST_CHECK(service.GetCurrentState() == ProfilingState::WaitingForAck);
Francis Murtagh68f78d82019-09-04 16:42:29 +0100490}
491
Francis Murtagh1f7db452019-08-14 09:49:34 +0100492BOOST_AUTO_TEST_SUITE_END()