13 #include <common/include/SocketConnectionException.hpp> 15 #include <CounterDirectory.hpp> 40 #include <boost/numeric/conversion/cast.hpp> 85 BOOST_CHECK(testKey1 == testKey2 && testKey2 == testKey1);
86 BOOST_CHECK(testKey0 == testKey1 && testKey1 == testKey2 && testKey0 == testKey2);
96 std::sort(vect.begin(), vect.end());
142 SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket);
146 sendCounterPacket, sendTimelinePacket,
147 profilingStateMachine);
150 commandHandlerRegistry.
RegisterFunctor(&connectionAcknowledgedCommandHandler);
155 CommandHandler commandHandler0(1,
true, commandHandlerRegistry, packetVersionResolver);
159 commandHandler0.
Start(testProfilingConnectionBase);
161 commandHandler0.
Start(testProfilingConnectionBase);
164 for (
int i = 0; i < 10; i++)
170 std::this_thread::sleep_for(std::chrono::milliseconds(2));
176 commandHandler0.
Stop();
183 CommandHandler commandHandler1(1,
true, commandHandlerRegistry, packetVersionResolver);
185 commandHandler1.
Start(testProfilingConnectionTimeOutError);
187 for (
int i = 0; i < 10; i++)
193 std::this_thread::sleep_for(std::chrono::milliseconds(2));
198 uint32_t timeout = 50;
199 uint32_t timeSlept = 0;
202 if (timeSlept >= timeout)
204 BOOST_FAIL(
"Timeout: The command handler loop did not stop after the timeout");
206 std::this_thread::sleep_for(std::chrono::milliseconds(1));
210 commandHandler1.
Stop();
216 commandHandler1.
Start(testProfilingConnectionBadAckPacket);
217 commandHandler1.
Stop();
224 commandHandler1.
Start(testProfilingConnectionTimeOutError);
227 for (
int i = 0; i < 10; i++)
233 std::this_thread::sleep_for(std::chrono::milliseconds(2));
235 commandHandler1.
Stop();
241 CommandHandler commandHandler2(1,
false, commandHandlerRegistry, packetVersionResolver);
243 commandHandler2.Start(testProfilingConnectionArmnnError);
246 for (
int i = 0; i < 10; i++)
252 std::this_thread::sleep_for(std::chrono::milliseconds(2));
256 commandHandler2.Stop();
286 BOOST_CHECK(version5.GetEncodedValue() == 4194304);
292 std::unique_ptr<unsigned char[]> packetData0 = std::make_unique<unsigned char[]>(length);
293 std::unique_ptr<unsigned char[]> packetData1 = std::make_unique<unsigned char[]>(0);
294 std::unique_ptr<unsigned char[]> nullPacketData;
296 Packet packetTest0(472580096, length, packetData0);
305 BOOST_CHECK_THROW(Packet packetTest1(472580096, 0, packetData1),
armnn::Exception);
306 BOOST_CHECK_NO_THROW(Packet packetTest2(472580096, 0, nullPacketData));
308 Packet packetTest3(472580096, 0, nullPacketData);
312 const unsigned char* packetTest0Data = packetTest0.GetData();
313 Packet packetTest4(std::move(packetTest0));
316 BOOST_CHECK(packetTest4.GetData() == packetTest0Data);
329 uint32_t version = 1;
340 std::map<CommandHandlerKey, CommandHandlerFunctor*> registry;
342 registry.insert(std::make_pair(keyB, &testFunctorB));
343 registry.insert(std::make_pair(keyA, &testFunctorA));
344 registry.insert(std::make_pair(keyC, &testFunctorC));
347 auto it = registry.begin();
354 std::unique_ptr<unsigned char[]> packetDataA;
355 std::unique_ptr<unsigned char[]> packetDataB;
356 std::unique_ptr<unsigned char[]> packetDataC;
358 Packet packetA(500000000, 0, packetDataA);
359 Packet packetB(600000000, 0, packetDataB);
360 Packet packetC(400000000, 0, packetDataC);
363 registry.at(
CommandHandlerKey(packetA.GetPacketFamily(), packetA.GetPacketId(), version))->operator()(packetA);
368 registry.at(
CommandHandlerKey(packetB.GetPacketFamily(), packetB.GetPacketId(), version))->operator()(packetB);
373 registry.at(
CommandHandlerKey(packetC.GetPacketFamily(), packetC.GetPacketId(), version))->operator()(packetC);
382 uint32_t version = 1;
396 std::unique_ptr<unsigned char[]> packetDataA;
397 std::unique_ptr<unsigned char[]> packetDataB;
398 std::unique_ptr<unsigned char[]> packetDataC;
400 Packet packetA(500000000, 0, packetDataA);
401 Packet packetB(600000000, 0, packetDataB);
402 Packet packetC(400000000, 0, packetDataC);
405 registry.
GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->
operator()(packetA);
410 registry.
GetFunctor(packetB.GetPacketFamily(), packetB.GetPacketId(), version)->
operator()(packetB);
415 registry.
GetFunctor(packetC.GetPacketFamily(), packetC.GetPacketId(), version)->
operator()(packetC);
422 registry.
GetFunctor(packetA.GetPacketFamily(), packetA.GetPacketId(), version)->
operator()(packetC);
434 std::random_device device;
435 std::mt19937 generator(device());
436 std::uniform_int_distribution<uint32_t> distribution(std::numeric_limits<uint32_t>::min(),
437 std::numeric_limits<uint32_t>::max());
440 const Version expectedVersion(1, 0, 0);
444 constexpr
unsigned int numTests = 10u;
446 for (
unsigned int i = 0u; i < numTests; ++i)
448 const uint32_t familyId = distribution(generator);
449 const uint32_t packetId = distribution(generator);
452 BOOST_TEST(resolvedVersion == expectedVersion);
551 std::map<uint32_t, std::vector<uint16_t>> periodIdMap;
552 std::vector<uint16_t> counterIds;
553 uint32_t numThreads = 10;
554 for (uint32_t i = 0; i < numThreads; ++i)
556 counterIds.emplace_back(i);
557 periodIdMap.insert(std::make_pair(i, counterIds));
581 BOOST_CHECK(captureData.GetCounterIds() == periodIdMap[2]);
583 std::map<uint32_t, CaptureData> captureDataIdMap;
584 for (uint32_t i = 0; i < numThreads; ++i)
587 captureDataIdMap.insert(std::make_pair(i, perThreadCaptureData));
590 std::vector<std::thread> threadsVect;
591 std::vector<std::thread> readThreadsVect;
592 for (uint32_t i = 0; i < numThreads; ++i)
594 threadsVect.emplace_back(
598 BOOST_CHECK(captureDataIdMap.at(i).GetCapturePeriod() == 0);
599 BOOST_CHECK(captureDataIdMap.at(i).GetCounterIds().empty());
600 readThreadsVect.emplace_back(
604 for (uint32_t i = 0; i < numThreads; ++i)
606 threadsVect[i].join();
607 readThreadsVect[i].join();
612 for (uint32_t i = 0; i < numThreads; ++i)
614 CaptureData perThreadCaptureData = captureDataIdMap.at(i);
622 std::vector<uint16_t> counterIds = { 42, 29, 13 };
634 secondCaptureData = captureData;
635 BOOST_CHECK(secondCaptureData.GetCapturePeriod() == 150);
636 BOOST_CHECK(secondCaptureData.GetCounterIds() == counterIds);
639 CaptureData copyConstructedCaptureData(captureData);
641 BOOST_CHECK(copyConstructedCaptureData.GetCapturePeriod() == 150);
642 BOOST_CHECK(copyConstructedCaptureData.GetCounterIds() == counterIds);
647 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
651 profilingService.
Update();
657 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
663 profilingService.
Update();
666 options.m_EnableProfiling =
true;
671 profilingService.
Update();
674 options.m_EnableProfiling =
false;
680 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
681 options.m_EnableProfiling =
true;
685 profilingService.
Update();
690 std::vector<std::thread> writers;
695 for (
int i = 0; i < 4; ++i)
698 writers.push_back(std::thread([&profilingService]()
700 for (
int i = 0; i < 250; ++i)
706 writers.push_back(std::thread([&profilingService]()
708 for (
int i = 0; i < 200; ++i)
714 writers.push_back(std::thread([&profilingService]()
716 for (
int i = 0; i < 200; ++i)
723 std::for_each(writers.begin(), writers.end(), mem_fn(&std::thread::join));
725 uint32_t absoluteCounterValue = 0;
731 BOOST_CHECK_NO_THROW(profilingService.
SetCounterValue(INFERENCES_RUN, 0));
737 uint32_t deltaCounterValue = 0;
739 std::thread reader([&profilingService](uint32_t& deltaCounterValue)
741 for (
int i = 0; i < 300; ++i)
745 }, std::ref(deltaCounterValue));
747 for (
int i = 0; i < 4; ++i)
750 writers.push_back(std::thread([&profilingService]()
752 for (
int i = 0; i < 250; ++i)
758 writers.push_back(std::thread([&profilingService]()
760 for (
int i = 0; i < 200; ++i)
766 writers.push_back(std::thread([&profilingService]()
768 for (
int i = 0; i < 200; ++i)
775 std::for_each(writers.begin(), writers.end(), mem_fn(&std::thread::join));
783 options.m_EnableProfiling =
false;
793 uint16_t nextUid = 0;
797 std::vector<uint16_t> counterUids;
801 std::vector<uint16_t> nextCounterUids;
806 std::vector<uint16_t> counterUidsMultiCore;
807 uint16_t thirdUid = 4;
808 uint16_t numberOfCores = 13;
809 BOOST_CHECK_NO_THROW(counterUidsMultiCore =
GetNextCounterUids(thirdUid, numberOfCores));
810 BOOST_CHECK(counterUidsMultiCore.size() == numberOfCores);
811 BOOST_CHECK(counterUidsMultiCore.front() >= nextCounterUids[0]);
812 for (
size_t i = 1; i < numberOfCores; i++)
814 BOOST_CHECK(counterUidsMultiCore[i] == counterUidsMultiCore[i - 1] + 1);
816 BOOST_CHECK(counterUidsMultiCore.back() == counterUidsMultiCore.front() + numberOfCores - 1);
828 const Category* noCategory =
nullptr;
834 BOOST_CHECK_THROW(noCategory = counterDirectory.
RegisterCategory(
"invalid category"),
840 const std::string categoryName =
"some_category";
842 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
855 const Category* notRegisteredCategory = counterDirectory.
GetCategory(
"not_registered_category");
860 const Category* anotherCategory =
nullptr;
861 BOOST_CHECK_THROW(anotherCategory = counterDirectory.
RegisterCategory(categoryName),
867 const std::string deviceName =
"some_device";
868 const Device* device =
nullptr;
869 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName));
877 const std::string categoryWoDeviceName =
"some_category_without_device";
878 const Category* categoryWoDevice =
nullptr;
879 BOOST_CHECK_NO_THROW(categoryWoDevice = counterDirectory.
RegisterCategory(categoryWoDeviceName));
886 const Category* categoryInvalidDeviceName =
nullptr;
887 BOOST_CHECK_THROW(categoryInvalidDeviceName =
894 const std::string categoryWValidDeviceName =
"some_category_with_valid_device";
895 const Category* categoryWValidDevice =
nullptr;
896 BOOST_CHECK_NO_THROW(categoryWValidDevice =
904 const std::string counterSetName =
"some_counter_set";
906 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
914 const std::string categoryWoCounterSetName =
"some_category_without_counter_set";
915 const Category* categoryWoCounterSet =
nullptr;
916 BOOST_CHECK_NO_THROW(categoryWoCounterSet =
923 const std::string categoryWValidCounterSetName =
"some_category_with_valid_counter_set";
924 const Category* categoryWValidCounterSet =
nullptr;
925 BOOST_CHECK_NO_THROW(categoryWValidCounterSet = counterDirectory.
RegisterCategory(categoryWValidCounterSetName));
932 const std::string categoryWValidDeviceAndValidCounterSetName =
"some_category_with_valid_device_and_counter_set";
933 const Category* categoryWValidDeviceAndValidCounterSet =
nullptr;
934 BOOST_CHECK_NO_THROW(categoryWValidDeviceAndValidCounterSet = counterDirectory.
RegisterCategory(
935 categoryWValidDeviceAndValidCounterSetName));
937 BOOST_CHECK(categoryWValidDeviceAndValidCounterSet);
938 BOOST_CHECK(categoryWValidDeviceAndValidCounterSet != category);
939 BOOST_CHECK(categoryWValidDeviceAndValidCounterSet->
m_Name == categoryWValidDeviceAndValidCounterSetName);
951 const Device* noDevice =
nullptr;
962 const std::string deviceName =
"some_device";
963 const Device* device =
nullptr;
964 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName));
982 const Device* deviceSameName =
nullptr;
988 const std::string deviceWCoresName =
"some_device_with_cores";
989 const Device* deviceWCores =
nullptr;
990 BOOST_CHECK_NO_THROW(deviceWCores = counterDirectory.
RegisterDevice(deviceWCoresName, 2));
1002 BOOST_CHECK(registeredDeviceWCores == deviceWCores);
1006 const std::string deviceWCoresWInvalidParentCategoryName =
"some_device_with_cores_with_invalid_parent_category";
1007 const Device* deviceWCoresWInvalidParentCategory =
nullptr;
1008 BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory =
1009 counterDirectory.
RegisterDevice(deviceWCoresWInvalidParentCategoryName, 3, std::string(
"")),
1015 const std::string deviceWCoresWInvalidParentCategoryName2 =
"some_device_with_cores_with_invalid_parent_category2";
1016 const Device* deviceWCoresWInvalidParentCategory2 =
nullptr;
1017 BOOST_CHECK_THROW(deviceWCoresWInvalidParentCategory2 = counterDirectory.
RegisterDevice(
1018 deviceWCoresWInvalidParentCategoryName2, 3, std::string(
"invalid_parent_category")),
1021 BOOST_CHECK(!deviceWCoresWInvalidParentCategory2);
1024 const std::string categoryName =
"some_category";
1025 const Category* category =
nullptr;
1026 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1033 const std::string deviceWCoresWValidParentCategoryName =
"some_device_with_cores_with_valid_parent_category";
1034 const Device* deviceWCoresWValidParentCategory =
nullptr;
1035 BOOST_CHECK_NO_THROW(deviceWCoresWValidParentCategory =
1036 counterDirectory.
RegisterDevice(deviceWCoresWValidParentCategoryName, 4, categoryName));
1039 BOOST_CHECK(deviceWCoresWValidParentCategory->
m_Name == deviceWCoresWValidParentCategoryName);
1061 BOOST_CHECK_THROW(noCounterSet = counterDirectory.
RegisterCounterSet(
"invalid name"),
1067 const std::string counterSetName =
"some_counter_set";
1069 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1087 const CounterSet* counterSetSameName =
nullptr;
1088 BOOST_CHECK_THROW(counterSetSameName = counterDirectory.
RegisterCounterSet(counterSetName),
1094 const std::string counterSetWCountName =
"some_counter_set_with_count";
1095 const CounterSet* counterSetWCount =
nullptr;
1096 BOOST_CHECK_NO_THROW(counterSetWCount = counterDirectory.
RegisterCounterSet(counterSetWCountName, 37));
1108 BOOST_CHECK(registeredCounterSetWCount == counterSetWCount);
1109 BOOST_CHECK(registeredCounterSetWCount != counterSet);
1112 const std::string counterSetWCountWInvalidParentCategoryName =
"some_counter_set_with_count_" 1113 "with_invalid_parent_category";
1114 const CounterSet* counterSetWCountWInvalidParentCategory =
nullptr;
1115 BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory = counterDirectory.
RegisterCounterSet(
1116 counterSetWCountWInvalidParentCategoryName, 42, std::string(
"")),
1119 BOOST_CHECK(!counterSetWCountWInvalidParentCategory);
1122 const std::string counterSetWCountWInvalidParentCategoryName2 =
"some_counter_set_with_count_" 1123 "with_invalid_parent_category2";
1124 const CounterSet* counterSetWCountWInvalidParentCategory2 =
nullptr;
1125 BOOST_CHECK_THROW(counterSetWCountWInvalidParentCategory2 = counterDirectory.
RegisterCounterSet(
1126 counterSetWCountWInvalidParentCategoryName2, 42, std::string(
"invalid_parent_category")),
1129 BOOST_CHECK(!counterSetWCountWInvalidParentCategory2);
1132 const std::string categoryName =
"some_category";
1133 const Category* category =
nullptr;
1134 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1141 const std::string counterSetWCountWValidParentCategoryName =
"some_counter_set_with_count_" 1142 "with_valid_parent_category";
1143 const CounterSet* counterSetWCountWValidParentCategory =
nullptr;
1144 BOOST_CHECK_NO_THROW(counterSetWCountWValidParentCategory = counterDirectory.
RegisterCounterSet(
1145 counterSetWCountWValidParentCategoryName, 42, categoryName));
1147 BOOST_CHECK(counterSetWCountWValidParentCategory);
1148 BOOST_CHECK(counterSetWCountWValidParentCategory->
m_Name == counterSetWCountWValidParentCategoryName);
1155 const std::string counterSetSameCategoryName =
"some_counter_set_with_invalid_parent_category";
1156 const std::string invalidCategoryName =
"";
1157 const CounterSet* counterSetSameCategory =
nullptr;
1158 BOOST_CHECK_THROW(counterSetSameCategory =
1159 counterDirectory.
RegisterCounterSet(counterSetSameCategoryName, 0, invalidCategoryName),
1174 const Counter* noCounter =
nullptr;
1175 BOOST_CHECK_THROW(noCounter =
1189 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1191 "invalid parent category",
1196 "valid description"),
1202 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1204 "valid_parent_category",
1210 "valid description"),
1216 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1218 "valid_parent_category",
1224 "valid description"),
1230 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1232 "valid_parent_category",
1238 "valid description"),
1245 noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1247 "valid_parent_category",
1252 "valid description"),
1258 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1260 "valid_parent_category",
1265 "valid description"),
1271 BOOST_CHECK_THROW(noCounter =
1274 "valid_parent_category",
1285 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1287 "valid_parent_category",
1293 "inv@lid description"),
1299 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1301 "valid_parent_category",
1306 "valid description",
1307 std::string(
"Mb/s2")),
1313 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1315 "invalid_parent_category",
1320 "valid description"),
1330 const std::string categoryName =
"some_category";
1331 const Category* category =
nullptr;
1332 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1339 const Counter* counter =
nullptr;
1340 BOOST_CHECK_NO_THROW(
1341 counter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1348 "valid description"));
1351 BOOST_CHECK(counter->m_MaxCounterUid == counter->m_Uid);
1356 BOOST_CHECK(counter->m_Description ==
"valid description");
1364 const Counter* counterSameName =
nullptr;
1365 BOOST_CHECK_THROW(counterSameName =
1373 "valid description",
1374 std::string(
"description")),
1380 const Counter* counterWUnits =
nullptr;
1381 BOOST_CHECK_NO_THROW(counterWUnits = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1388 "valid description",
1389 std::string(
"Mnnsq2")));
1406 const Counter* counterWoDevice =
nullptr;
1407 BOOST_CHECK_NO_THROW(counterWoDevice = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1414 "valid description",
1420 BOOST_CHECK(counterWoDevice->m_Uid > counter->m_Uid);
1421 BOOST_CHECK(counterWoDevice->m_MaxCounterUid == counterWoDevice->m_Uid);
1423 BOOST_CHECK(counterWoDevice->m_Interpolation == 1);
1424 BOOST_CHECK(counterWoDevice->m_Multiplier == 123.45f);
1425 BOOST_CHECK(counterWoDevice->m_Name ==
"valid name 3");
1426 BOOST_CHECK(counterWoDevice->m_Description ==
"valid description");
1429 BOOST_CHECK(counterWoDevice->m_CounterSetUid == 0);
1434 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1441 "valid description",
1450 const std::string deviceName =
"some_device";
1451 const Device* device =
nullptr;
1452 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName));
1460 const Counter* counterWDevice =
nullptr;
1461 BOOST_CHECK_NO_THROW(counterWDevice = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1468 std::string(
"valid description"),
1488 const Counter* counterWoCounterSet =
nullptr;
1489 BOOST_CHECK_NO_THROW(counterWoCounterSet = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1496 "valid description",
1503 BOOST_CHECK(counterWoCounterSet->m_Uid > counter->m_Uid);
1504 BOOST_CHECK(counterWoCounterSet->m_MaxCounterUid == counterWoCounterSet->m_Uid);
1506 BOOST_CHECK(counterWoCounterSet->m_Interpolation == 1);
1507 BOOST_CHECK(counterWoCounterSet->m_Multiplier == 123.45f);
1508 BOOST_CHECK(counterWoCounterSet->m_Name ==
"valid name 6");
1509 BOOST_CHECK(counterWoCounterSet->m_Description ==
"valid description");
1511 BOOST_CHECK(counterWoCounterSet->m_DeviceUid == 0);
1512 BOOST_CHECK(counterWoCounterSet->m_CounterSetUid == 0);
1517 BOOST_CHECK_THROW(noCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1525 std::string(
"valid description"),
1534 const Counter* counterWNumberOfCores =
nullptr;
1535 uint16_t numberOfCores = 15;
1536 BOOST_CHECK_NO_THROW(counterWNumberOfCores = counterDirectory.
RegisterCounter(
1537 armnn::profiling::BACKEND_ID, 50,
1538 categoryName, 0, 1, 123.45f,
"valid name 8",
"valid description",
1556 for (
size_t i = 0; i < numberOfCores; i++)
1559 counterWNumberOfCores->
m_Uid + i);
1563 const std::string multiCoreDeviceName =
"some_multi_core_device";
1564 const Device* multiCoreDevice =
nullptr;
1565 BOOST_CHECK_NO_THROW(multiCoreDevice = counterDirectory.
RegisterDevice(multiCoreDeviceName, 4));
1573 const Counter* counterWMultiCoreDevice =
nullptr;
1574 BOOST_CHECK_NO_THROW(counterWMultiCoreDevice = counterDirectory.
RegisterCounter(
1575 armnn::profiling::BACKEND_ID, 19, categoryName, 0, 1,
1576 123.45f,
"valid name 9",
"valid description",
1579 multiCoreDevice->
m_Uid,
1585 counterWMultiCoreDevice->
m_Uid + multiCoreDevice->
m_Cores - 1);
1595 for (
size_t i = 0; i < 4; i++)
1601 const std::string multiCoreDeviceNameWParentCategory =
"some_multi_core_device_with_parent_category";
1602 const Device* multiCoreDeviceWParentCategory =
nullptr;
1603 BOOST_CHECK_NO_THROW(multiCoreDeviceWParentCategory =
1604 counterDirectory.
RegisterDevice(multiCoreDeviceNameWParentCategory, 2, categoryName));
1607 BOOST_CHECK(multiCoreDeviceWParentCategory->
m_Name == multiCoreDeviceNameWParentCategory);
1613 const Counter* counterWMultiCoreDeviceWParentCategory =
nullptr;
1614 uint16_t numberOfCourse = multiCoreDeviceWParentCategory->
m_Cores;
1615 BOOST_CHECK_NO_THROW(counterWMultiCoreDeviceWParentCategory =
1623 "valid description",
1629 BOOST_CHECK(counterWMultiCoreDeviceWParentCategory);
1630 BOOST_CHECK(counterWMultiCoreDeviceWParentCategory->
m_Uid > counter->m_Uid);
1632 counterWMultiCoreDeviceWParentCategory->
m_Uid + multiCoreDeviceWParentCategory->
m_Cores - 1);
1640 for (
size_t i = 0; i < 2; i++)
1643 counterWMultiCoreDeviceWParentCategory->
m_Uid + i);
1647 const std::string counterSetName =
"some_counter_set";
1649 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1657 const Counter* counterWCounterSet =
nullptr;
1658 BOOST_CHECK_NO_THROW(counterWCounterSet = counterDirectory.
RegisterCounter(
1659 armnn::profiling::BACKEND_ID, 300,
1660 categoryName, 0, 1, 123.45f,
"valid name 11",
"valid description",
1664 counterSet->
m_Uid));
1681 const Counter* counterWDeviceWCounterSet =
nullptr;
1682 BOOST_CHECK_NO_THROW(counterWDeviceWCounterSet = counterDirectory.
RegisterCounter(
1683 armnn::profiling::BACKEND_ID, 23,
1684 categoryName, 0, 1, 123.45f,
"valid name 12",
"valid description",
1688 counterSet->
m_Uid));
1691 BOOST_CHECK(counterWDeviceWCounterSet->m_Uid > counter->m_Uid);
1692 BOOST_CHECK(counterWDeviceWCounterSet->m_MaxCounterUid == counterWDeviceWCounterSet->m_Uid);
1693 BOOST_CHECK(counterWDeviceWCounterSet->m_Class == 0);
1694 BOOST_CHECK(counterWDeviceWCounterSet->m_Interpolation == 1);
1695 BOOST_CHECK(counterWDeviceWCounterSet->m_Multiplier == 123.45f);
1696 BOOST_CHECK(counterWDeviceWCounterSet->m_Name ==
"valid name 12");
1697 BOOST_CHECK(counterWDeviceWCounterSet->m_Description ==
"valid description");
1698 BOOST_CHECK(counterWDeviceWCounterSet->m_Units ==
"");
1700 BOOST_CHECK(counterWDeviceWCounterSet->m_CounterSetUid == counterSet->
m_Uid);
1705 const std::string anotherCategoryName =
"some_other_category";
1706 const Category* anotherCategory =
nullptr;
1707 BOOST_CHECK_NO_THROW(anotherCategory = counterDirectory.
RegisterCategory(anotherCategoryName));
1715 const Counter* anotherCounter =
nullptr;
1716 BOOST_CHECK_NO_THROW(anotherCounter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID, 24,
1717 anotherCategoryName, 1, 0, .00043f,
1718 "valid name",
"valid description",
1722 counterSet->
m_Uid));
1725 BOOST_CHECK(anotherCounter->m_MaxCounterUid == anotherCounter->m_Uid);
1727 BOOST_CHECK(anotherCounter->m_Interpolation == 0);
1728 BOOST_CHECK(anotherCounter->m_Multiplier == .00043f);
1729 BOOST_CHECK(anotherCounter->m_Name ==
"valid name");
1730 BOOST_CHECK(anotherCounter->m_Description ==
"valid description");
1746 void Start()
override 1748 void Stop()
override 1754 bool IsCounterRegistered(uint16_t counterUid)
const override 1759 uint16_t GetCounterCount()
const override 1763 uint32_t GetAbsoluteCounterValue(uint16_t counterUid)
const override 1768 uint32_t GetDeltaCounterValue(uint16_t counterUid)
override 1774 const uint32_t familyId = 0;
1775 const uint32_t packetId = 0x40000;
1777 uint32_t version = 1;
1779 std::shared_ptr<armnn::profiling::IBackendProfilingContext>> backendProfilingContext;
1782 TestCaptureThread captureThread;
1783 TestReadCounterValues readCounterValues;
1786 SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket);
1788 uint32_t sizeOfUint32 =
numeric_cast<uint32_t>(
sizeof(uint32_t));
1789 uint32_t sizeOfUint16 =
numeric_cast<uint32_t>(
sizeof(uint16_t));
1793 uint32_t dataLength1 = 8;
1794 uint32_t offset = 0;
1796 std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
1797 unsigned char* data1 =
reinterpret_cast<unsigned char*
>(uniqueData1.get());
1800 offset += sizeOfUint32;
1802 offset += sizeOfUint16;
1805 Packet packetA(packetId, dataLength1, uniqueData1);
1808 counterIdMap, holder, 10000u, captureThread,
1809 readCounterValues, sendCounterPacket, profilingStateMachine);
1818 BOOST_CHECK_NO_THROW(commandHandler(packetA));
1823 BOOST_TEST(counterIdsA.size() == 2);
1824 BOOST_TEST(counterIdsA[0] == 4000);
1825 BOOST_TEST(counterIdsA[1] == 5000);
1831 uint32_t headerWord0 =
ReadUint32(readBuffer, offset);
1832 offset += sizeOfUint32;
1833 uint32_t headerWord1 =
ReadUint32(readBuffer, offset);
1834 offset += sizeOfUint32;
1835 uint32_t period =
ReadUint32(readBuffer, offset);
1837 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
1838 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
1839 BOOST_TEST(headerWord1 == 8);
1842 uint16_t counterId = 0;
1843 offset += sizeOfUint32;
1845 BOOST_TEST(counterId == 4000);
1846 offset += sizeOfUint16;
1848 BOOST_TEST(counterId == 5000);
1853 uint32_t period2 = 9000;
1854 uint32_t dataLength2 = 4;
1856 std::unique_ptr<unsigned char[]> uniqueData2 = std::make_unique<unsigned char[]>(dataLength2);
1858 WriteUint32(reinterpret_cast<unsigned char*>(uniqueData2.get()), 0, period2);
1860 Packet packetB(packetId, dataLength2, uniqueData2);
1862 commandHandler(packetB);
1868 BOOST_TEST(counterIdsB.size() == 0);
1874 headerWord0 =
ReadUint32(readBuffer, offset);
1875 offset += sizeOfUint32;
1876 headerWord1 =
ReadUint32(readBuffer, offset);
1877 offset += sizeOfUint32;
1880 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
1881 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
1882 BOOST_TEST(headerWord1 == 4);
1891 virtual void ReportStructure()
override 1893 m_ReportStructureCalled =
true;
1896 bool m_ReportStructureCalled =
false;
1902 TestNotifyBackends() : m_timelineReporting(
false) {}
1903 virtual void NotifyBackendsForTimelineReporting()
override 1905 m_TestNotifyBackendsCalled = m_timelineReporting.load();
1908 bool m_TestNotifyBackendsCalled =
false;
1909 std::atomic<bool> m_timelineReporting;
1917 TestReportStructure testReportStructure;
1918 TestNotifyBackends testNotifyBackends;
1926 testReportStructure,
1927 testNotifyBackends.m_timelineReporting,
1928 testNotifyBackends);
1932 const uint32_t packetFamily1 = 0;
1933 const uint32_t packetId1 = 6;
1937 Packet ActivateTimelineReportingPacket(packetHeader1);
1940 activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket),
armnn::Exception);
1944 activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket),
armnn::Exception);
1948 activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket),
armnn::Exception);
1951 activateTimelineReportingCommandHandler.operator()(ActivateTimelineReportingPacket);
1953 BOOST_CHECK(testReportStructure.m_ReportStructureCalled);
1954 BOOST_CHECK(testNotifyBackends.m_TestNotifyBackendsCalled);
1955 BOOST_CHECK(testNotifyBackends.m_timelineReporting.load());
1960 testNotifyBackends.m_timelineReporting,
1962 testNotifyBackends);
1964 const uint32_t packetFamily2 = 0;
1965 const uint32_t packetId2 = 7;
1969 Packet deactivateTimelineReportingPacket(packetHeader2);
1971 stateMachine.Reset();
1973 deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket),
armnn::Exception);
1977 deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket),
armnn::Exception);
1981 deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket),
armnn::Exception);
1984 deactivateTimelineReportingCommandHandler.operator()(deactivateTimelineReportingPacket);
1986 BOOST_CHECK(!testNotifyBackends.m_TestNotifyBackendsCalled);
1987 BOOST_CHECK(!testNotifyBackends.m_timelineReporting.load());
1992 using namespace armnn;
2016 const uint32_t packetFamilyId = 0;
2017 const uint32_t connectionPacketId = 0x10000;
2018 const uint32_t version = 1;
2020 uint32_t sizeOfUint32 =
numeric_cast<uint32_t>(
sizeof(uint32_t));
2021 uint32_t sizeOfUint16 =
numeric_cast<uint32_t>(
sizeof(uint16_t));
2024 uint32_t period1 = 10;
2025 uint32_t dataLength1 = 8;
2026 uint32_t offset = 0;
2028 std::unique_ptr<unsigned char[]> uniqueData1 = std::make_unique<unsigned char[]>(dataLength1);
2029 unsigned char* data1 =
reinterpret_cast<unsigned char*
>(uniqueData1.get());
2032 offset += sizeOfUint32;
2034 offset += sizeOfUint16;
2037 Packet packetA(connectionPacketId, dataLength1, uniqueData1);
2044 SendThread sendThread(profilingState, mockBuffer, sendCounterPacket);
2048 sendCounterPacket, sendTimelinePacket, profilingState);
2061 BOOST_CHECK_NO_THROW(commandHandler(packetA));
2065 BOOST_CHECK_NO_THROW(commandHandler(packetA));
2069 const uint32_t differentPacketId = 0x40000;
2070 Packet packetB(differentPacketId, dataLength1, uniqueData1);
2074 counterDirectory, sendCounterPacket,
2075 sendTimelinePacket, profilingState);
2091 catch (armnnProfiling::SocketConnectionException& ex)
2096 == std::string(
"SocketProfilingConnection: Cannot connect to stream socket: Connection refused"));
2103 for (
unsigned char c = 0; c < 128; c++)
2109 for (
unsigned char c = 255; c >= 128; c++)
2118 const unsigned char validChars[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
2119 for (
unsigned char i = 0; i <
sizeof(validChars) /
sizeof(validChars[0]) - 1; i++)
2125 for (
unsigned char c = 0; c < 48; c++)
2129 for (
unsigned char c = 58; c < 65; c++)
2133 for (
unsigned char c = 91; c < 95; c++)
2137 for (
unsigned char c = 96; c < 97; c++)
2141 for (
unsigned char c = 123; c < 128; c++)
2147 for (
unsigned char c = 255; c >= 128; c++)
2156 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
""));
2157 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"_"));
2158 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"0123"));
2159 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"valid_string"));
2160 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"VALID_string_456"));
2161 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
" "));
2162 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"valid string"));
2163 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"!$%"));
2164 BOOST_CHECK(IsValidSwTraceString<SwTraceCharPolicy>(
"valid|\\~string#123"));
2167 BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>(
"€£"));
2168 BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>(
"invalid‡string"));
2169 BOOST_CHECK(!IsValidSwTraceString<SwTraceCharPolicy>(
"12Ž34"));
2175 BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(
""));
2176 BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(
"_"));
2177 BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(
"0123"));
2178 BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(
"valid_string"));
2179 BOOST_CHECK(IsValidSwTraceString<SwTraceNameCharPolicy>(
"VALID_string_456"));
2182 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
" "));
2183 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"invalid string"));
2184 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"!$%"));
2185 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"invalid|\\~string#123"));
2186 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"€£"));
2187 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"invalid‡string"));
2188 BOOST_CHECK(!IsValidSwTraceString<SwTraceNameCharPolicy>(
"12Ž34"));
2191 template <
typename SwTracePolicy>
2195 BOOST_CHECK(StringToSwTraceString<SwTracePolicy>(testString, buffer));
2207 BOOST_CHECK(std::memcmp(testString.data(), buffer.data() + 1, testString.size()) == 0);
2210 size_t nullTerminatorIndex =
sizeof(uint32_t) + testString.size();
2211 BOOST_CHECK(reinterpret_cast<unsigned char*>(buffer.data())[nullTerminatorIndex] ==
'\0');
2216 std::vector<uint32_t> buffer;
2219 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"", buffer, 2);
2220 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"_", buffer, 2);
2221 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"0123", buffer, 3);
2222 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"valid_string", buffer, 5);
2223 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"VALID_string_456", buffer, 6);
2224 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
" ", buffer, 2);
2225 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"valid string", buffer, 5);
2226 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"!$%", buffer, 2);
2227 StringToSwTraceStringTestHelper<SwTraceCharPolicy>(
"valid|\\~string#123", buffer, 6);
2230 BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>(
"€£", buffer));
2232 BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>(
"invalid‡string", buffer));
2234 BOOST_CHECK(!StringToSwTraceString<SwTraceCharPolicy>(
"12Ž34", buffer));
2240 std::vector<uint32_t> buffer;
2243 StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>(
"", buffer, 2);
2244 StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>(
"_", buffer, 2);
2245 StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>(
"0123", buffer, 3);
2246 StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>(
"valid_string", buffer, 5);
2247 StringToSwTraceStringTestHelper<SwTraceNameCharPolicy>(
"VALID_string_456", buffer, 6);
2250 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
" ", buffer));
2252 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"invalid string", buffer));
2254 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"!$%", buffer));
2256 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"invalid|\\~string#123", buffer));
2258 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"€£", buffer));
2260 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"invalid‡string", buffer));
2262 BOOST_CHECK(!StringToSwTraceString<SwTraceNameCharPolicy>(
"12Ž34", buffer));
2271 CaptureReader(uint16_t counterSize)
2273 for (uint16_t i = 0; i < counterSize; ++i)
2277 m_CounterSize = counterSize;
2280 bool IsCounterRegistered(uint16_t counterUid)
const override 2286 uint16_t GetCounterCount()
const override 2288 return m_CounterSize;
2291 uint32_t GetAbsoluteCounterValue(uint16_t counterUid)
const override 2293 if (counterUid > m_CounterSize)
2295 BOOST_FAIL(
"Invalid counter Uid");
2297 return m_Data.at(counterUid).load();
2300 uint32_t GetDeltaCounterValue(uint16_t counterUid)
override 2302 if (counterUid > m_CounterSize)
2304 BOOST_FAIL(
"Invalid counter Uid");
2306 return m_Data.at(counterUid).load();
2309 void SetCounterValue(uint16_t counterUid, uint32_t value)
2311 if (counterUid > m_CounterSize)
2313 BOOST_FAIL(
"Invalid counter Uid");
2315 m_Data.at(counterUid).store(value);
2319 std::unordered_map<uint16_t, std::atomic<uint32_t>> m_Data;
2320 uint16_t m_CounterSize;
2326 std::shared_ptr<armnn::profiling::IBackendProfilingContext>> backendProfilingContext;
2329 std::vector<uint16_t> captureIds1 = { 0, 1 };
2330 std::vector<uint16_t> captureIds2;
2334 SendThread sendThread(profilingStateMachine, mockBuffer, sendCounterPacket);
2336 std::vector<uint16_t> counterIds;
2337 CaptureReader captureReader(2);
2339 unsigned int valueA = 10;
2340 unsigned int valueB = 15;
2341 unsigned int numSteps = 5;
2343 PeriodicCounterCapture periodicCounterCapture(std::ref(data), std::ref(sendCounterPacket), captureReader,
2344 counterIdMap, backendProfilingContext);
2346 for (
unsigned int i = 0; i < numSteps; ++i)
2349 captureReader.SetCounterValue(0, valueA * (i + 1));
2350 captureReader.SetCounterValue(1, valueB * (i + 1));
2352 periodicCounterCapture.
Start();
2353 periodicCounterCapture.
Stop();
2358 uint32_t headerWord0 =
ReadUint32(buffer, 0);
2359 uint32_t headerWord1 =
ReadUint32(buffer, 4);
2361 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
2362 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
2363 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
2364 BOOST_TEST(headerWord1 == 20);
2366 uint32_t offset = 16;
2367 uint16_t readIndex =
ReadUint16(buffer, offset);
2368 BOOST_TEST(0 == readIndex);
2371 uint32_t readValue =
ReadUint32(buffer, offset);
2372 BOOST_TEST((valueA * numSteps) == readValue);
2376 BOOST_TEST(1 == readIndex);
2380 BOOST_TEST((valueB * numSteps) == readValue);
2387 const uint32_t familyId = 0;
2388 const uint32_t packetId = 3;
2389 const uint32_t version = 1;
2394 SendThread sendThread(profilingStateMachine, mockBuffer1, sendCounterPacket);
2398 sendCounterPacket, sendTimelinePacket, profilingStateMachine);
2400 const uint32_t wrongPacketId = 47;
2401 const uint32_t wrongHeader = (wrongPacketId & 0x000003FF) << 16;
2403 Packet wrongPacket(wrongHeader);
2414 const uint32_t rightHeader = (packetId & 0x000003FF) << 16;
2416 Packet rightPacket(rightHeader);
2418 BOOST_CHECK_NO_THROW(commandHandler(rightPacket));
2422 uint32_t header1Word0 =
ReadUint32(readBuffer1, 0);
2423 uint32_t header1Word1 =
ReadUint32(readBuffer1, 4);
2426 BOOST_TEST(((header1Word0 >> 26) & 0x0000003F) == 0);
2427 BOOST_TEST(((header1Word0 >> 16) & 0x000003FF) == 2);
2428 BOOST_TEST(header1Word1 == 24);
2430 uint32_t bodyHeader1Word0 =
ReadUint32(readBuffer1, 8);
2431 uint16_t deviceRecordCount =
numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
2432 BOOST_TEST(deviceRecordCount == 0);
2436 uint32_t header2Word0 =
ReadUint32(readBuffer2, 0);
2437 uint32_t header2Word1 =
ReadUint32(readBuffer2, 4);
2440 BOOST_TEST(((header2Word0 >> 26) & 0x0000003F) == 1);
2441 BOOST_TEST(((header2Word0 >> 16) & 0x000003FF) == 0);
2442 BOOST_TEST(header2Word1 == 419);
2449 const uint32_t familyId = 0;
2450 const uint32_t packetId = 3;
2451 const uint32_t version = 1;
2456 SendThread sendThread(profilingStateMachine, mockBuffer1, sendCounterPacket);
2460 sendCounterPacket, sendTimelinePacket, profilingStateMachine);
2461 const uint32_t header = (packetId & 0x000003FF) << 16;
2462 const Packet packet(header);
2470 "categoryA", 0, 1, 2.0f,
"counterA",
"descA");
2472 "categoryA", 1, 1, 3.0f,
"counterB",
"descB");
2481 BOOST_CHECK_NO_THROW(commandHandler(packet));
2485 const uint32_t header1Word0 =
ReadUint32(readBuffer1, 0);
2486 const uint32_t header1Word1 =
ReadUint32(readBuffer1, 4);
2488 BOOST_TEST(((header1Word0 >> 26) & 0x0000003F) == 0);
2489 BOOST_TEST(((header1Word0 >> 16) & 0x000003FF) == 2);
2490 BOOST_TEST(header1Word1 == 236);
2492 const uint32_t bodyHeaderSizeBytes = bodyHeaderSize *
sizeof(uint32_t);
2494 const uint32_t bodyHeader1Word0 =
ReadUint32(readBuffer1, 8);
2495 const uint32_t bodyHeader1Word1 =
ReadUint32(readBuffer1, 12);
2496 const uint32_t bodyHeader1Word2 =
ReadUint32(readBuffer1, 16);
2497 const uint32_t bodyHeader1Word3 =
ReadUint32(readBuffer1, 20);
2498 const uint32_t bodyHeader1Word4 =
ReadUint32(readBuffer1, 24);
2499 const uint32_t bodyHeader1Word5 =
ReadUint32(readBuffer1, 28);
2500 const uint16_t deviceRecordCount =
numeric_cast<uint16_t>(bodyHeader1Word0 >> 16);
2501 const uint16_t counterSetRecordCount =
numeric_cast<uint16_t>(bodyHeader1Word2 >> 16);
2502 const uint16_t categoryRecordCount =
numeric_cast<uint16_t>(bodyHeader1Word4 >> 16);
2503 BOOST_TEST(deviceRecordCount == 1);
2504 BOOST_TEST(bodyHeader1Word1 == 0 + bodyHeaderSizeBytes);
2505 BOOST_TEST(counterSetRecordCount == 1);
2506 BOOST_TEST(bodyHeader1Word3 == 4 + bodyHeaderSizeBytes);
2507 BOOST_TEST(categoryRecordCount == 1);
2508 BOOST_TEST(bodyHeader1Word5 == 8 + bodyHeaderSizeBytes);
2510 const uint32_t deviceRecordOffset =
ReadUint32(readBuffer1, 32);
2511 BOOST_TEST(deviceRecordOffset == 12);
2513 const uint32_t counterSetRecordOffset =
ReadUint32(readBuffer1, 36);
2514 BOOST_TEST(counterSetRecordOffset == 28);
2516 const uint32_t categoryRecordOffset =
ReadUint32(readBuffer1, 40);
2517 BOOST_TEST(categoryRecordOffset == 48);
2521 const uint32_t header2Word0 =
ReadUint32(readBuffer2, 0);
2522 const uint32_t header2Word1 =
ReadUint32(readBuffer2, 4);
2525 BOOST_TEST(((header2Word0 >> 26) & 0x0000003F) == 1);
2526 BOOST_TEST(((header2Word0 >> 16) & 0x000003FF) == 0);
2527 BOOST_TEST(header2Word1 == 419);
2535 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2536 options.m_EnableProfiling =
true;
2545 profilingService.
Update();
2547 profilingService.
Update();
2554 mockProfilingConnection->
Clear();
2557 profilingService.
Update();
2571 uint32_t packetFamily = 0;
2572 uint32_t packetId = 1;
2573 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2576 Packet connectionAcknowledgedPacket(header);
2579 mockProfilingConnection->
WritePacket(std::move(connectionAcknowledgedPacket));
2588 options.m_EnableProfiling =
false;
2595 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2596 options.m_EnableProfiling =
true;
2605 profilingService.
Update();
2607 profilingService.
Update();
2609 profilingService.
Update();
2627 uint32_t packetFamily = 0;
2628 uint32_t packetId = 3;
2629 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2632 Packet requestCounterDirectoryPacket(header);
2635 mockProfilingConnection->
WritePacket(std::move(requestCounterDirectoryPacket));
2646 options.m_EnableProfiling =
false;
2653 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2654 options.m_EnableProfiling =
true;
2663 profilingService.
Update();
2665 profilingService.
Update();
2667 profilingService.
Update();
2678 mockProfilingConnection->
Clear();
2688 uint32_t packetFamily = 0;
2689 uint32_t packetId = 4;
2690 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2692 uint32_t capturePeriod = 123456;
2698 uint16_t counterUidA = counters.begin()->first;
2699 uint16_t counterUidB = 9999;
2701 uint32_t length = 8;
2703 auto data = std::make_unique<unsigned char[]>(length);
2709 Packet periodicCounterSelectionPacket(header, length, data);
2713 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
2724 options.m_EnableProfiling =
false;
2731 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2732 options.m_EnableProfiling =
true;
2741 profilingService.
Update();
2743 profilingService.
Update();
2745 profilingService.
Update();
2767 uint32_t packetFamily = 0;
2768 uint32_t packetId = 4;
2769 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2772 Packet periodicCounterSelectionPacket(header);
2775 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
2788 options.m_EnableProfiling =
false;
2795 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2796 options.m_EnableProfiling =
true;
2805 profilingService.
Update();
2807 profilingService.
Update();
2809 profilingService.
Update();
2831 uint32_t packetFamily = 0;
2832 uint32_t packetId = 4;
2833 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2835 uint32_t capturePeriod = 123456;
2841 uint16_t counterUid = counters.begin()->first;
2843 uint32_t length = 6;
2845 auto data = std::make_unique<unsigned char[]>(length);
2850 Packet periodicCounterSelectionPacket(header, length, data);
2854 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
2865 options.m_EnableProfiling =
false;
2872 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2873 options.m_EnableProfiling =
true;
2882 profilingService.
Update();
2884 profilingService.
Update();
2886 profilingService.
Update();
2908 uint32_t packetFamily = 0;
2909 uint32_t packetId = 4;
2910 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
2912 uint32_t capturePeriod = 123456;
2918 uint16_t counterUidA = counters.begin()->first;
2919 uint16_t counterUidB = (counters.begin()++)->first;
2921 uint32_t length = 8;
2923 auto data = std::make_unique<unsigned char[]>(length);
2929 Packet periodicCounterSelectionPacket(header, length, data);
2933 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
2944 options.m_EnableProfiling =
false;
2951 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
2952 options.m_EnableProfiling =
true;
2965 profilingService.
Update();
2971 profilingService.
Update();
2977 profilingService.
Update();
3002 options.m_EnableProfiling =
false;
3009 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3010 options.m_EnableProfiling =
true;
3019 profilingService.
Update();
3021 profilingService.
Update();
3023 profilingService.
Update();
3045 uint32_t packetFamily = 0;
3046 uint32_t packetId = 5;
3047 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
3050 Packet periodicCounterSelectionPacket(header);
3053 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
3057 std::this_thread::sleep_for(std::chrono::milliseconds(5));
3064 const auto StreamMetaDataSize =
static_cast<unsigned long>(
3069 options.m_EnableProfiling =
false;
3075 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3076 options.m_EnableProfiling =
true;
3083 options.m_EnableProfiling =
false;
3089 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3096 options.m_EnableProfiling =
false;
3104 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3105 options.m_EnableProfiling =
true;
3109 profilingService.
Update();
3113 std::stringstream ss;
3115 profilingService.
Update();
3118 options.m_EnableProfiling =
false;
3121 streamRedirector.CancelRedirect();
3124 if (ss.str().find(
"Cannot connect to stream socket: Connection refused") == std::string::npos)
3126 std::cout << ss.str();
3127 BOOST_FAIL(
"Expected string not found.");
3135 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3139 profilingService.
Update();
3141 options.m_EnableProfiling =
true;
3144 profilingService.
Update();
3148 std::stringstream ss;
3150 profilingService.
Update();
3153 options.m_EnableProfiling =
false;
3156 streamRedirector.CancelRedirect();
3159 if (ss.str().find(
"Cannot connect to stream socket: Connection refused") == std::string::npos)
3161 std::cout << ss.str();
3162 BOOST_FAIL(
"Expected string not found.");
3173 std::stringstream ss;
3177 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3178 options.m_EnableProfiling =
true;
3187 profilingService.
Update();
3189 profilingService.
Update();
3202 uint32_t packetFamily = 0;
3203 uint32_t packetId = 37;
3204 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
3207 Packet connectionAcknowledgedPacket(header);
3210 mockProfilingConnection->
WritePacket(std::move(connectionAcknowledgedPacket));
3213 profilingService.
Update();
3216 options.m_EnableProfiling =
false;
3219 streamRedirector.CancelRedirect();
3222 if (ss.str().find(
"Functor with requested PacketId=37 and Version=4194304 does not exist") == std::string::npos)
3224 std::cout << ss.str();
3225 BOOST_FAIL(
"Expected string not found.");
3235 std::stringstream ss;
3239 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3240 options.m_EnableProfiling =
true;
3251 profilingService.
Update();
3266 uint32_t packetFamily = 0;
3267 uint32_t packetId = 123;
3268 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
3271 Packet requestCounterDirectoryPacket(header);
3274 mockProfilingConnection->WritePacket(std::move(requestCounterDirectoryPacket));
3277 profilingService.
Update();
3280 options.m_EnableProfiling =
false;
3283 streamRedirector.CancelRedirect();
3286 if (ss.str().find(
"Functor with requested PacketId=123 and Version=4194304 does not exist") == std::string::npos)
3288 std::cout << ss.str();
3289 BOOST_FAIL(
"Expected string not found.");
3299 std::stringstream ss;
3303 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3304 options.m_EnableProfiling =
true;
3313 profilingService.
Update();
3315 profilingService.
Update();
3317 profilingService.
Update();
3331 uint32_t packetFamily = 0;
3332 uint32_t packetId = 999;
3333 uint32_t header = ((packetFamily & 0x0000003F) << 26) | ((packetId & 0x000003FF) << 16);
3336 Packet periodicCounterSelectionPacket(header);
3339 mockProfilingConnection->
WritePacket(std::move(periodicCounterSelectionPacket));
3340 profilingService.
Update();
3343 options.m_EnableProfiling =
false;
3347 streamRedirector.CancelRedirect();
3350 if (ss.str().find(
"Functor with requested PacketId=999 and Version=4194304 does not exist") == std::string::npos)
3352 std::cout << ss.str();
3353 BOOST_FAIL(
"Expected string not found.");
3363 uint16_t globalCounterIds = 0;
3368 std::vector<uint16_t> cpuRefCounters = {0, 1, 2, 3};
3369 std::vector<uint16_t> cpuAccCounters = {0, 1};
3371 for (uint16_t backendCounterId : cpuRefCounters)
3373 counterIdMap.
RegisterMapping(globalCounterIds, backendCounterId, cpuRefId);
3376 for (uint16_t backendCounterId : cpuAccCounters)
3378 counterIdMap.
RegisterMapping(globalCounterIds, backendCounterId, cpuAccId);
3399 uint16_t globalCounterIds = armnn::profiling::INFERENCES_RUN;
3403 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3404 options.m_EnableProfiling =
true;
3418 globalCounterIds = registerBackendCounters.
RegisterDevice(
"deviceOne");
3427 BOOST_CHECK(counterSetOnePtr->m_Name ==
"counterSetOne");
3429 uint16_t newGlobalCounterId = registerBackendCounters.
RegisterCounter(0,
3435 "first test counter");
3436 BOOST_CHECK(newGlobalCounterId = armnn::profiling::INFERENCES_RUN + 1);
3438 BOOST_CHECK(mappedGlobalId == newGlobalCounterId);
3444 options.m_EnableProfiling =
false;
3461 BackendProfiling backendProfilingCpuRef(options, profilingService, cpuRefId);
3462 BackendProfiling backendProfilingCpuAcc(options, profilingService, cpuAccId);
3464 uint16_t initialNumGlobalCounterIds = armnn::profiling::INFERENCES_RUN;
3467 RegisterBackendCounters registerBackendCountersCpuRef(initialNumGlobalCounterIds, cpuRefId, profilingService);
3481 std::vector<uint16_t> cpuRefCounters = {0, 1};
3482 std::vector<uint16_t> cpuAccCounters = {0};
3485 uint16_t currentNumGlobalCounterIds = registerBackendCountersCpuRef.
RegisterCounter(
3486 0,
"testCategory", 0, 0, 1.f,
"CpuRefCounter0",
"Zeroth CpuRef Counter");
3487 BOOST_CHECK(currentNumGlobalCounterIds == initialNumGlobalCounterIds + 1);
3489 BOOST_CHECK(mappedGlobalId == currentNumGlobalCounterIds);
3494 currentNumGlobalCounterIds = registerBackendCountersCpuRef.
RegisterCounter(
3495 1,
"testCategory", 0, 0, 1.f,
"CpuRefCounter1",
"First CpuRef Counter");
3496 BOOST_CHECK(currentNumGlobalCounterIds == initialNumGlobalCounterIds + 2);
3498 BOOST_CHECK(mappedGlobalId == currentNumGlobalCounterIds);
3504 RegisterBackendCounters registerBackendCountersCpuAcc(currentNumGlobalCounterIds, cpuAccId, profilingService);
3507 currentNumGlobalCounterIds = registerBackendCountersCpuAcc.
RegisterCounter(
3508 0,
"testCategory", 0, 0, 1.f,
"CpuAccCounter0",
"Zeroth CpuAcc Counter");
3509 BOOST_CHECK(currentNumGlobalCounterIds == initialNumGlobalCounterIds + 3);
3511 BOOST_CHECK(mappedGlobalId == currentNumGlobalCounterIds);
3517 const std::vector<uint16_t> activeGlobalCounterIds = {5};
3518 const std::vector<uint16_t> newActiveGlobalCounterIds = {6, 7};
3520 const uint32_t capturePeriod = 200;
3521 const uint32_t newCapturePeriod = 100;
3524 profilingService.
SetCaptureData(capturePeriod, activeGlobalCounterIds, {});
3527 std::vector<CounterStatus> cpuRefCounterStatus = backendProfilingCpuRef.
GetActiveCounters();
3528 std::vector<CounterStatus> cpuAccCounterStatus = backendProfilingCpuAcc.
GetActiveCounters();
3529 BOOST_CHECK_EQUAL(cpuRefCounterStatus.size(), 1);
3530 BOOST_CHECK_EQUAL(cpuAccCounterStatus.size(), 0);
3533 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_GlobalCounterId, activeGlobalCounterIds[0]);
3534 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_BackendCounterId, cpuRefCounters[0]);
3535 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_SamplingRateInMicroseconds, capturePeriod);
3536 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_Enabled,
true);
3543 BOOST_CHECK_EQUAL(inactiveCpuRefCounter.
m_Enabled,
false);
3550 BOOST_CHECK_EQUAL(inactiveCpuAccCounter.
m_Enabled,
false);
3553 profilingService.
SetCaptureData(newCapturePeriod, newActiveGlobalCounterIds, {});
3558 BOOST_CHECK_EQUAL(cpuRefCounterStatus.size(), 1);
3559 BOOST_CHECK_EQUAL(cpuAccCounterStatus.size(), 1);
3562 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_GlobalCounterId, newActiveGlobalCounterIds[0]);
3563 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_BackendCounterId, cpuRefCounters[1]);
3564 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_SamplingRateInMicroseconds, newCapturePeriod);
3565 BOOST_CHECK_EQUAL(cpuRefCounterStatus[0].m_Enabled,
true);
3568 BOOST_CHECK_EQUAL(cpuAccCounterStatus[0].m_GlobalCounterId, newActiveGlobalCounterIds[1]);
3569 BOOST_CHECK_EQUAL(cpuAccCounterStatus[0].m_BackendCounterId, cpuAccCounters[0]);
3570 BOOST_CHECK_EQUAL(cpuAccCounterStatus[0].m_SamplingRateInMicroseconds, newCapturePeriod);
3571 BOOST_CHECK_EQUAL(cpuAccCounterStatus[0].m_Enabled,
true);
3574 inactiveCpuRefCounter = backendProfilingCpuRef.
GetCounterStatus(cpuRefCounters[0]);
3578 BOOST_CHECK_EQUAL(inactiveCpuRefCounter.
m_Enabled,
false);
3600 mockProfilingService,
3607 std::vector<armnn::profiling::Timestamp> timestamps;
3608 timestamps.push_back(timestamp);
3613 uint32_t headerWord0 =
ReadUint32(readBuffer, 0);
3614 uint32_t headerWord1 =
ReadUint32(readBuffer, 4);
3615 uint64_t readTimestamp =
ReadUint64(readBuffer, 8);
3617 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
3618 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
3619 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
3620 BOOST_TEST(headerWord1 == 20);
3621 BOOST_TEST(1000998 == readTimestamp);
3623 uint32_t offset = 16;
3625 uint16_t readIndex =
ReadUint16(readBuffer, offset);
3626 BOOST_TEST(6 == readIndex);
3630 uint32_t readValue =
ReadUint32(readBuffer, offset);
3631 BOOST_TEST(700 == readValue);
3636 BOOST_TEST(8 == readIndex);
3641 BOOST_TEST(93 == readValue);
3649 armnn::Runtime::CreationOptions::ExternalProfilingOptions
options;
3650 options.m_EnableProfiling =
true;
3655 options.m_FileFormat =
"json";
3660 profilingService.
Update();
3664 std::stringstream ss;
3669 profilingService.
Update();
3671 streamRedirector.CancelRedirect();
3674 if (ss.str().find(
"Unsupported profiling file format, only binary is supported") == std::string::npos)
3676 std::cout << ss.str();
3677 BOOST_FAIL(
"Expected string not found.");
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
uint32_t GetFamilyId() const
uint32_t GetEncodedValue()
ProfilingState GetCurrentState() const
const Category * RegisterCategory(const std::string &categoryName) override
void ProfilingCurrentStateThreadImpl(ProfilingStateMachine &states)
const Counter * RegisterCounter(const BackendId &backendId, const uint16_t uid, const std::string &parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, const std::string &name, const std::string &description, const Optional< std::string > &units=EmptyOptional(), const Optional< uint16_t > &numberOfCores=EmptyOptional(), const Optional< uint16_t > &deviceUid=EmptyOptional(), const Optional< uint16_t > &counterSetUid=EmptyOptional()) override
void StringToSwTraceStringTestHelper(const std::string &testString, std::vector< uint32_t > buffer, size_t expectedSize)
uint32_t GetAbsoluteCounterValue(uint16_t counterUid) const override
uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId &backendId) const override
std::vector< CounterStatus > GetActiveCounters() override
CPU Execution: Reference C++ kernels.
long WaitForPacketsSent(MockProfilingConnection *mockProfilingConnection, MockProfilingConnection::PacketType packetType, uint32_t length=0, uint32_t timeout=1000)
ProfilingState GetCurrentState() const
void Start(IProfilingConnection &profilingConnection)
void WriteUint16(const IPacketBufferPtr &packetBuffer, unsigned int offset, uint16_t value)
const std::vector< uint16_t > & GetCounterIds() const
void WriteUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset, uint32_t value)
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
void ForceTransitionToState(ProfilingState newState)
uint32_t m_SamplingRateInMicroseconds
std::unordered_map< uint16_t, CounterPtr > Counters
virtual const Category * GetCategory(const std::string &name) const =0
uint16_t RegisterDevice(const std::string &deviceName, uint16_t cores=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
Version ResolvePacketVersion(uint32_t familyId, uint32_t packetId) const
uint32_t GetStreamMetaDataPacketSize()
void ForceTransitionToState(ProfilingState newState)
void ReportCounters(const std::vector< Timestamp > &) override
uint32_t GetPacketId() const
CommandHandlerFunctor * GetFunctor(uint32_t familyId, uint32_t packetId, uint32_t version) const
const Device * GetDevice(uint16_t uid) const override
virtual uint16_t GetCounterCount() const =0
uint16_t ReadUint16(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint16_t GetCounterSetCount() const override
uint32_t GetPacketId() const
virtual const Device * GetDevice(uint16_t uid) const =0
unsigned long GetWrittenDataSize()
Copyright (c) 2020 ARM Limited.
void IgnoreUnused(Ts &&...)
virtual const CounterSets & GetCounterSets() const =0
void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId &backendId) override
uint32_t IncrementCounterValue(uint16_t counterUid) override
uint32_t GetVersion() const
void CaptureDataReadThreadImpl(const Holder &holder, CaptureData &captureData)
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
virtual const Categories & GetCategories() const =0
uint16_t GetNextUid(bool peekOnly)
uint16_t GetDeviceCount() const override
uint32_t GetDeltaCounterValue(uint16_t counterUid) override
uint32_t SubtractCounterValue(uint16_t counterUid, uint32_t value) override
CounterStatus GetCounterStatus(uint16_t backendCounterId) override
virtual const Devices & GetDevices() const =0
void MarkRead(IPacketBufferPtr &packetBuffer) override
void SetCapturePeriod(uint32_t capturePeriod)
uint32_t GetCapturePeriod() const
virtual const CounterSet * GetCounterSet(uint16_t uid) const =0
profiling::ProfilingService & GetProfilingService(armnn::Runtime *runtime)
CaptureData GetCaptureData() const
void RegisterFunctor(CommandHandlerFunctor *functor, uint32_t familyId, uint32_t packetId, uint32_t version)
void SetCaptureData(uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< BackendId > &activeBackends)
void SetCaptureData(uint32_t capturePeriod, const std::vector< uint16_t > &counterIds, const std::set< armnn::BackendId > &activeBackends)
std::vector< uint16_t > GetNextCounterUids(uint16_t firstUid, uint16_t cores)
const std::pair< uint16_t, armnn::BackendId > & GetBackendId(uint16_t globalCounterId) const override
uint16_t RegisterCounterSet(const std::string &counterSetName, uint16_t count=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
IPacketBufferPtr GetReadableBuffer() override
const ICounterMappings & GetCounterMappings() const override
void ResetExternalProfilingOptions(const ExternalProfilingOptions &options, bool resetProfilingService=false)
uint32_t ConstructHeader(uint32_t packetFamily, uint32_t packetId)
uint32_t AddCounterValue(uint16_t counterUid, uint32_t value) override
uint16_t GetCategoryCount() const override
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
constexpr unsigned int LOWEST_CAPTURE_PERIOD
The lowest performance data capture interval we support is 10 miliseconds.
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
std::vector< CounterValue > counterValues
IPacketBufferPtr GetReadableBuffer() override
uint16_t RegisterCounter(const uint16_t uid, const std::string &parentCategoryName, uint16_t counterClass, uint16_t interpolation, double multiplier, const std::string &name, const std::string &description, const Optional< std::string > &units=EmptyOptional(), const Optional< uint16_t > &numberOfCores=EmptyOptional(), const Optional< uint16_t > &deviceUid=EmptyOptional(), const Optional< uint16_t > &counterSetUid=EmptyOptional()) override
uint16_t m_GlobalCounterId
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
armnn::profiling::ProfilingService profilingService
MockProfilingConnection * GetMockProfilingConnection()
std::vector< uint16_t > m_Counters
void SetCounterValue(uint16_t counterUid, uint32_t value) override
const Counter * GetCounter(uint16_t uid) const override
BOOST_AUTO_TEST_SUITE_END()
void RegisterCategory(const std::string &categoryName) override
const Category * GetCategory(const std::string &name) const override
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
std::string m_Description
uint32_t GetVersion() const
void CaptureDataWriteThreadImpl(Holder &holder, uint32_t capturePeriod, const std::vector< uint16_t > &counterIds)
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
Base class for all ArmNN exceptions so that users can filter to just those.
CPU Execution: NEON: ArmCompute.
static bool IsValidChar(unsigned char c)
BufferManager & GetProfilingBufferManager()
void SetCounterIds(const std::vector< uint16_t > &counterIds)
bool WritePacket(const unsigned char *buffer, uint32_t length) override
uint16_t GetCounterCount() const override
void TransitionToState(ProfilingState newState)
virtual const Counters & GetCounters() const =0
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
bool IsOpen() const override
virtual const std::pair< uint16_t, armnn::BackendId > & GetBackendId(uint16_t globalCounterId) const =0
void SetStopAfterTimeout(bool stopAfterTimeout)
const CounterSet * GetCounterSet(uint16_t uid) const override
armnn::Runtime::CreationOptions::ExternalProfilingOptions options
ExternalProfilingOptions m_ProfilingOptions
const ICounterDirectory & GetCounterDirectory() const
ProfilingState ConfigureProfilingService(const ExternalProfilingOptions &options, bool resetProfilingService=false)
FileOnlyHelperService helper
uint16_t m_BackendCounterId
void RegisterMapping(uint16_t globalCounterId, uint16_t backendCounterId, const armnn::BackendId &backendId)
static bool IsValidChar(unsigned char c)
virtual uint16_t GetGlobalId(uint16_t backendCounterId, const armnn::BackendId &backendId) const =0