10 #include <CounterDirectory.hpp> 20 #include <boost/test/unit_test.hpp> 21 #include <boost/numeric/conversion/cast.hpp> 31 uint16_t constexpr WAIT_UNTIL_READABLE_MS = 20;
49 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
69 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
90 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
108 const char* buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
110 BOOST_TEST(strcmp(buffer,
"SendStreamMetaDataPacket") == 0);
118 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
120 BOOST_TEST(strcmp(buffer,
"SendCounterDirectoryPacket") == 0);
124 uint64_t timestamp = 0;
125 std::vector<CounterValue> indexValuePairs;
130 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
132 BOOST_TEST(strcmp(buffer,
"SendPeriodicCounterCapturePacket") == 0);
136 uint32_t capturePeriod = 0;
137 std::vector<uint16_t> selectedCounterIds;
141 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
143 BOOST_TEST(strcmp(buffer,
"SendPeriodicCounterSelectionPacket") == 0);
154 uint32_t capturePeriod = 1000;
155 std::vector<uint16_t> selectedCounterIds;
164 auto readBuffer2 = mockBuffer2.GetReadableBuffer();
166 uint32_t headerWord0 =
ReadUint32(readBuffer2, 0);
167 uint32_t headerWord1 =
ReadUint32(readBuffer2, 4);
170 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
171 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
172 BOOST_TEST(headerWord1 == 4);
173 BOOST_TEST(period == 1000);
179 selectedCounterIds.reserve(5);
180 selectedCounterIds.emplace_back(100);
181 selectedCounterIds.emplace_back(200);
182 selectedCounterIds.emplace_back(300);
183 selectedCounterIds.emplace_back(400);
184 selectedCounterIds.emplace_back(500);
192 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
193 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
194 BOOST_TEST(headerWord1 == 14);
195 BOOST_TEST(period == 1000);
197 uint16_t counterId = 0;
198 uint32_t offset = 12;
201 for(
const uint16_t&
id : selectedCounterIds)
204 BOOST_TEST(counterId ==
id);
217 auto captureTimestamp = std::chrono::steady_clock::now();
218 uint64_t time =
static_cast<uint64_t
>(captureTimestamp.time_since_epoch().count());
219 std::vector<CounterValue> indexValuePairs;
229 auto readBuffer2 = mockBuffer2.GetReadableBuffer();
231 uint32_t headerWord0 =
ReadUint32(readBuffer2, 0);
232 uint32_t headerWord1 =
ReadUint32(readBuffer2, 4);
233 uint64_t readTimestamp =
ReadUint64(readBuffer2, 8);
235 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
236 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
237 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
238 BOOST_TEST(headerWord1 == 8);
239 BOOST_TEST(time == readTimestamp);
245 indexValuePairs.reserve(5);
256 uint64_t readTimestamp2 =
ReadUint64(readBuffer3, 8);
258 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
259 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
260 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
261 BOOST_TEST(headerWord1 == 38);
262 BOOST_TEST(time == readTimestamp2);
264 uint16_t counterIndex = 0;
265 uint32_t counterValue = 100;
266 uint32_t offset = 16;
269 for (
auto it = indexValuePairs.begin(), end = indexValuePairs.end(); it != end; ++it)
272 uint16_t readIndex =
ReadUint16(readBuffer3, offset);
273 BOOST_TEST(counterIndex == readIndex);
278 uint32_t readValue =
ReadUint32(readBuffer3, offset);
279 BOOST_TEST(counterValue == readValue);
288 using boost::numeric_cast;
290 uint32_t sizeUint32 = numeric_cast<uint32_t>(
sizeof(uint32_t));
301 uint32_t infoSize = numeric_cast<uint32_t>(
GetSoftwareInfo().size()) > 0 ?
303 uint32_t hardwareVersionSize = numeric_cast<uint32_t>(
GetHardwareVersion().size()) > 0 ?
305 uint32_t softwareVersionSize = numeric_cast<uint32_t>(
GetSoftwareVersion().size()) > 0 ?
307 uint32_t processNameSize = numeric_cast<uint32_t>(processName.size()) > 0 ?
308 numeric_cast<uint32_t>(processName.size()) + 1 : 0;
310 uint32_t packetEntries = 6;
317 uint32_t headerWord0 =
ReadUint32(readBuffer2, 0);
318 uint32_t headerWord1 =
ReadUint32(readBuffer2, sizeUint32);
320 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
321 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 0);
323 uint32_t totalLength = numeric_cast<uint32_t>(2 * sizeUint32 + 10 * sizeUint32 + infoSize + hardwareVersionSize +
324 softwareVersionSize + processNameSize + sizeUint32 +
325 2 * packetEntries * sizeUint32);
327 BOOST_TEST(headerWord1 == totalLength - (2 * sizeUint32));
329 uint32_t offset = sizeUint32 * 2;
331 offset += sizeUint32;
333 offset += sizeUint32;
335 offset += sizeUint32;
337 BOOST_TEST(
ReadUint32(readBuffer2, offset) == numeric_cast<uint32_t>(pid));
338 offset += sizeUint32;
339 uint32_t poolOffset = 10 * sizeUint32;
340 BOOST_TEST(
ReadUint32(readBuffer2, offset) == (infoSize ? poolOffset : 0));
341 offset += sizeUint32;
342 poolOffset += infoSize;
343 BOOST_TEST(
ReadUint32(readBuffer2, offset) == (hardwareVersionSize ? poolOffset : 0));
344 offset += sizeUint32;
345 poolOffset += hardwareVersionSize;
346 BOOST_TEST(
ReadUint32(readBuffer2, offset) == (softwareVersionSize ? poolOffset : 0));
347 offset += sizeUint32;
348 poolOffset += softwareVersionSize;
349 BOOST_TEST(
ReadUint32(readBuffer2, offset) == (processNameSize ? poolOffset : 0));
350 offset += sizeUint32;
351 poolOffset += processNameSize;
352 BOOST_TEST(
ReadUint32(readBuffer2, offset) == (packetEntries ? poolOffset : 0));
353 offset += sizeUint32;
354 BOOST_TEST(
ReadUint32(readBuffer2, offset) == 0);
356 const unsigned char* readData2 = readBuffer2->GetReadableData();
358 offset += sizeUint32;
361 BOOST_TEST(strcmp(reinterpret_cast<const char *>(&readData2[offset]),
GetSoftwareInfo().c_str()) == 0);
365 if (hardwareVersionSize)
367 BOOST_TEST(strcmp(reinterpret_cast<const char *>(&readData2[offset]),
GetHardwareVersion().c_str()) == 0);
368 offset += hardwareVersionSize;
371 if (softwareVersionSize)
373 BOOST_TEST(strcmp(reinterpret_cast<const char *>(&readData2[offset]),
GetSoftwareVersion().c_str()) == 0);
374 offset += softwareVersionSize;
379 BOOST_TEST(strcmp(reinterpret_cast<const char *>(&readData2[offset]),
GetProcessName().c_str()) == 0);
380 offset += processNameSize;
385 BOOST_TEST((
ReadUint32(readBuffer2, offset) >> 16) == packetEntries);
386 offset += sizeUint32;
387 for (uint32_t i = 0; i < packetEntries - 1; ++i)
389 BOOST_TEST(((
ReadUint32(readBuffer2, offset) >> 26) & 0x3F) == 0);
390 BOOST_TEST(((
ReadUint32(readBuffer2, offset) >> 16) & 0x3FF) == i);
391 offset += sizeUint32;
393 offset += sizeUint32;
396 BOOST_TEST(((
ReadUint32(readBuffer2, offset) >> 26) & 0x3F) == 1);
397 BOOST_TEST(((
ReadUint32(readBuffer2, offset) >> 16) & 0x3FF) == 0);
398 offset += sizeUint32;
400 offset += sizeUint32;
403 BOOST_TEST(offset == totalLength);
412 uint16_t deviceUid = 27;
413 const std::string deviceName =
"some_device";
414 uint16_t deviceCores = 3;
415 const DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, deviceCores);
419 std::string errorMessage;
426 uint16_t deviceRecordWord0[]
428 static_cast<uint16_t
>(deviceRecord[0] >> 16),
429 static_cast<uint16_t>(deviceRecord[0])
434 BOOST_CHECK(deviceRecord[2] == deviceName.size() + 1);
435 BOOST_CHECK(std::memcmp(deviceRecord.data() + 3, deviceName.data(), deviceName.size()) == 0);
444 uint16_t deviceUid = 27;
445 const std::string deviceName =
"some€£invalid‡device";
446 uint16_t deviceCores = 3;
447 const DevicePtr device = std::make_unique<Device>(deviceUid, deviceName, deviceCores);
451 std::string errorMessage;
465 uint16_t counterSetUid = 27;
466 const std::string counterSetName =
"some_counter_set";
467 uint16_t counterSetCount = 3421;
468 const CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, counterSetCount);
472 std::string errorMessage;
479 uint16_t counterSetRecordWord0[]
481 static_cast<uint16_t
>(counterSetRecord[0] >> 16),
482 static_cast<uint16_t>(counterSetRecord[0])
484 BOOST_CHECK(counterSetRecordWord0[0] == counterSetUid);
485 BOOST_CHECK(counterSetRecordWord0[1] == counterSetCount);
487 BOOST_CHECK(counterSetRecord[2] == counterSetName.size() + 1);
488 BOOST_CHECK(std::memcmp(counterSetRecord.data() + 3, counterSetName.data(), counterSetName.size()) == 0);
497 uint16_t counterSetUid = 27;
498 const std::string counterSetName =
"some invalid_counter€£set";
499 uint16_t counterSetCount = 3421;
500 const CounterSetPtr counterSet = std::make_unique<CounterSet>(counterSetUid, counterSetName, counterSetCount);
504 std::string errorMessage;
518 uint16_t counterUid = 7256;
519 uint16_t maxCounterUid = 132;
520 uint16_t deviceUid = 132;
521 uint16_t counterSetUid = 4497;
522 uint16_t counterClass = 1;
523 uint16_t counterInterpolation = 1;
524 double counterMultiplier = 1234.567f;
525 const std::string counterName =
"some_valid_counter";
526 const std::string counterDescription =
"a_counter_for_testing";
527 const std::string counterUnits =
"Mrads2";
528 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
532 counterInterpolation,
539 BOOST_ASSERT(counter);
543 std::string errorMessage;
550 uint16_t eventRecordWord0[]
552 static_cast<uint16_t
>(eventRecord[0] >> 16),
553 static_cast<uint16_t>(eventRecord[0])
555 uint16_t eventRecordWord1[]
557 static_cast<uint16_t
>(eventRecord[1] >> 16),
558 static_cast<uint16_t>(eventRecord[1])
560 uint16_t eventRecordWord2[]
562 static_cast<uint16_t
>(eventRecord[2] >> 16),
563 static_cast<uint16_t>(eventRecord[2])
565 uint32_t eventRecordWord34[]
575 BOOST_CHECK(eventRecordWord2[1] == counterInterpolation);
576 BOOST_CHECK(std::memcmp(eventRecordWord34, &counterMultiplier,
sizeof(counterMultiplier)) == 0);
579 uint32_t counterNameOffset = 0;
580 uint32_t counterDescriptionOffset = counterNameOffset +
585 size_t counterUnitsOffset = counterDescriptionOffset +
587 counterDescription.size() +
593 BOOST_CHECK(eventRecord[6] == counterDescriptionOffset);
596 auto eventRecordPool =
reinterpret_cast<unsigned char*
>(eventRecord.data() + 8u);
600 BOOST_CHECK(eventRecordPool[counterNameOffset] == counterName.size() + 1);
606 counterName.size()) == 0);
608 BOOST_CHECK(eventRecordPool[counterNameOffset + uint32_t_size + counterName.size()] ==
'\0');
611 BOOST_CHECK(eventRecordPool[counterDescriptionOffset] == counterDescription.size() + 1);
614 counterDescriptionOffset +
616 counterDescription.data(),
617 counterDescription.size()) == 0);
619 BOOST_CHECK(eventRecordPool[counterDescriptionOffset + uint32_t_size + counterDescription.size()] ==
'\0');
622 BOOST_CHECK(eventRecordPool[counterUnitsOffset] == counterUnits.size() + 1);
628 counterUnits.size()) == 0);
630 BOOST_CHECK(eventRecordPool[counterUnitsOffset + uint32_t_size + counterUnits.size()] ==
'\0');
639 uint16_t counterUid = 44312;
640 uint16_t maxCounterUid = 345;
641 uint16_t deviceUid = 101;
642 uint16_t counterSetUid = 34035;
643 uint16_t counterClass = 0;
644 uint16_t counterInterpolation = 1;
645 double counterMultiplier = 4435.0023f;
646 const std::string counterName =
"some_valid_counter";
647 const std::string counterDescription =
"a_counter_for_testing";
648 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
652 counterInterpolation,
659 BOOST_ASSERT(counter);
663 std::string errorMessage;
670 uint16_t eventRecordWord0[]
672 static_cast<uint16_t
>(eventRecord[0] >> 16),
673 static_cast<uint16_t>(eventRecord[0])
675 uint16_t eventRecordWord1[]
677 static_cast<uint16_t
>(eventRecord[1] >> 16),
678 static_cast<uint16_t>(eventRecord[1])
680 uint16_t eventRecordWord2[]
682 static_cast<uint16_t
>(eventRecord[2] >> 16),
683 static_cast<uint16_t>(eventRecord[2])
685 uint32_t eventRecordWord34[]
695 BOOST_CHECK(eventRecordWord2[1] == counterInterpolation);
696 BOOST_CHECK(std::memcmp(eventRecordWord34, &counterMultiplier,
sizeof(counterMultiplier)) == 0);
699 uint32_t counterNameOffset = 0;
700 uint32_t counterDescriptionOffset = counterNameOffset +
708 BOOST_CHECK(eventRecord[6] == counterDescriptionOffset);
711 auto eventRecordPool =
reinterpret_cast<unsigned char*
>(eventRecord.data() + 8u);
715 BOOST_CHECK(eventRecordPool[counterNameOffset] == counterName.size() + 1);
721 counterName.size()) == 0);
723 BOOST_CHECK(eventRecordPool[counterNameOffset + uint32_t_size + counterName.size()] ==
'\0');
726 BOOST_CHECK(eventRecordPool[counterDescriptionOffset] == counterDescription.size() + 1);
729 counterDescriptionOffset +
731 counterDescription.data(),
732 counterDescription.size()) == 0);
734 BOOST_CHECK(eventRecordPool[counterDescriptionOffset + uint32_t_size + counterDescription.size()] ==
'\0');
743 uint16_t counterUid = 7256;
744 uint16_t maxCounterUid = 132;
745 uint16_t deviceUid = 132;
746 uint16_t counterSetUid = 4497;
747 uint16_t counterClass = 1;
748 uint16_t counterInterpolation = 1;
749 double counterMultiplier = 1234.567f;
750 const std::string counterName =
"some_invalid_counter £££";
751 const std::string counterDescription =
"a_counter_for_testing";
752 const std::string counterUnits =
"Mrads2";
753 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
757 counterInterpolation,
764 BOOST_ASSERT(counter);
768 std::string errorMessage;
782 uint16_t counterUid = 7256;
783 uint16_t maxCounterUid = 132;
784 uint16_t deviceUid = 132;
785 uint16_t counterSetUid = 4497;
786 uint16_t counterClass = 1;
787 uint16_t counterInterpolation = 1;
788 double counterMultiplier = 1234.567f;
789 const std::string counterName =
"some_invalid_counter";
790 const std::string counterDescription =
"an invalid d€scription";
791 const std::string counterUnits =
"Mrads2";
792 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
796 counterInterpolation,
803 BOOST_ASSERT(counter);
807 std::string errorMessage;
821 uint16_t counterUid = 7256;
822 uint16_t maxCounterUid = 132;
823 uint16_t deviceUid = 132;
824 uint16_t counterSetUid = 4497;
825 uint16_t counterClass = 1;
826 uint16_t counterInterpolation = 1;
827 double counterMultiplier = 1234.567f;
828 const std::string counterName =
"some_invalid_counter";
829 const std::string counterDescription =
"a valid description";
830 const std::string counterUnits =
"Mrad s2";
831 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
835 counterInterpolation,
842 BOOST_ASSERT(counter);
846 std::string errorMessage;
860 const std::string categoryName =
"some_category";
861 uint16_t deviceUid = 1302;
862 uint16_t counterSetUid = 20734;
863 const CategoryPtr category = std::make_unique<Category>(categoryName, deviceUid, counterSetUid);
864 BOOST_ASSERT(category);
865 category->m_Counters = { 11u, 23u, 5670u };
869 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
881 counters.insert(std::make_pair<uint16_t, CounterPtr>(23,
889 "the second counter",
893 counters.insert(std::make_pair<uint16_t, CounterPtr>(5670,
900 "and this is number 3",
905 Counter* counter1 = counters.find(11)->second.get();
906 Counter* counter2 = counters.find(23)->second.get();
907 Counter* counter3 = counters.find(5670)->second.get();
908 BOOST_ASSERT(counter1);
909 BOOST_ASSERT(counter2);
910 BOOST_ASSERT(counter3);
911 uint16_t categoryEventCount = boost::numeric_cast<uint16_t>(counters.size());
915 std::string errorMessage;
923 uint16_t categoryRecordWord0[]
925 static_cast<uint16_t
>(categoryRecord[0] >> 16),
926 static_cast<uint16_t>(categoryRecord[0])
928 uint16_t categoryRecordWord1[]
930 static_cast<uint16_t
>(categoryRecord[1] >> 16),
931 static_cast<uint16_t>(categoryRecord[1])
934 BOOST_CHECK(categoryRecordWord0[1] == counterSetUid);
935 BOOST_CHECK(categoryRecordWord1[0] == categoryEventCount);
941 uint32_t eventPointerTableOffset = 0;
942 uint32_t categoryNameOffset = eventPointerTableOffset +
946 BOOST_CHECK(categoryRecord[2] == eventPointerTableOffset);
947 BOOST_CHECK(categoryRecord[3] == categoryNameOffset);
949 auto categoryRecordPool =
reinterpret_cast<unsigned char*
>(categoryRecord.data() + 4u);
952 uint32_t eventRecord0Offset = categoryRecordPool[eventPointerTableOffset + 0 *
uint32_t_size];
953 uint32_t eventRecord1Offset = categoryRecordPool[eventPointerTableOffset + 1 *
uint32_t_size];
954 uint32_t eventRecord2Offset = categoryRecordPool[eventPointerTableOffset + 2 *
uint32_t_size];
960 BOOST_CHECK(categoryRecordPool[categoryNameOffset] == categoryName.size() + 1);
966 categoryName.size()) == 0);
968 BOOST_CHECK(categoryRecordPool[categoryNameOffset + uint32_t_size + categoryName.size()] ==
'\0');
974 uint16_t eventRecord0Word0[2] = { 0u, 0u };
975 std::memcpy(eventRecord0Word0, categoryRecordPool + eventRecord0Offset,
sizeof(eventRecord0Word0));
980 uint32_t counter1NameOffset = 0;
981 std::memcpy(&counter1NameOffset, categoryRecordPool + eventRecord0Offset + 5u * uint32_t_size, uint32_t_size);
984 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
987 ] == counter1->
m_Name.size() + 1);
996 counter1->
m_Name.size()) == 0);
998 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
1000 counter1NameOffset +
1006 uint32_t counter2NameOffset = 0;
1007 std::memcpy(&counter2NameOffset, categoryRecordPool + eventRecord1Offset + 5u * uint32_t_size, uint32_t_size);
1010 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1011 8u * uint32_t_size +
1013 ] == counter2->
m_Name.size() + 1);
1017 eventRecord1Offset +
1018 8u * uint32_t_size +
1019 counter2NameOffset +
1022 counter2->
m_Name.size()) == 0);
1024 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1025 8u * uint32_t_size +
1026 counter2NameOffset +
1032 uint32_t counter3NameOffset = 0;
1033 std::memcpy(&counter3NameOffset, categoryRecordPool + eventRecord2Offset + 5u * uint32_t_size, uint32_t_size);
1036 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1037 8u * uint32_t_size +
1039 ] == counter3->
m_Name.size() + 1);
1043 eventRecord2Offset +
1044 8u * uint32_t_size +
1045 counter3NameOffset +
1048 counter3->
m_Name.size()) == 0);
1050 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1051 8u * uint32_t_size +
1052 counter3NameOffset +
1064 const std::string categoryName =
"some invalid category";
1065 uint16_t deviceUid = 1302;
1066 uint16_t counterSetUid = 20734;
1067 const CategoryPtr category = std::make_unique<Category>(categoryName, deviceUid, counterSetUid);
1073 std::string errorMessage;
1087 const std::string categoryName =
"some_category";
1088 uint16_t deviceUid = 1302;
1089 uint16_t counterSetUid = 20734;
1090 const CategoryPtr category = std::make_unique<Category>(categoryName, deviceUid, counterSetUid);
1092 category->m_Counters = { 11u, 23u, 5670u };
1096 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
1104 "the first counter",
1109 Counter* counter1 = counters.find(11)->second.get();
1114 std::string errorMessage;
1128 const std::string device1Name =
"device1";
1129 const Device* device1 =
nullptr;
1130 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1135 const std::string device2Name =
"device2";
1136 const Device* device2 =
nullptr;
1137 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1154 const std::string device1Name =
"device1";
1155 const Device* device1 =
nullptr;
1156 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1161 const std::string device2Name =
"device2";
1162 const Device* device2 =
nullptr;
1163 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1168 const std::string counterSet1Name =
"counterset1";
1170 BOOST_CHECK_NO_THROW(counterSet1 = counterDirectory.
RegisterCounterSet(counterSet1Name));
1175 const std::string category1Name =
"category1";
1176 const Category* category1 =
nullptr;
1177 BOOST_CHECK_NO_THROW(category1 = counterDirectory.
RegisterCategory(category1Name,
1179 counterSet1->
m_Uid));
1184 const std::string category2Name =
"category2";
1185 const Category* category2 =
nullptr;
1186 BOOST_CHECK_NO_THROW(category2 = counterDirectory.
RegisterCategory(category2Name,
1192 const Counter* counter1 =
nullptr;
1193 BOOST_CHECK_NO_THROW(counter1 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1200 "counter1description",
1201 std::string(
"counter1units")));
1206 const Counter* counter2 =
nullptr;
1207 BOOST_CHECK_NO_THROW(counter2 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1214 "counter2description",
1215 std::string(
"counter2units"),
1223 const Counter* counter3 =
nullptr;
1224 BOOST_CHECK_NO_THROW(counter3 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1231 "counter3description",
1235 counterSet1->
m_Uid));
1248 uint32_t packetHeaderWord0 =
ReadUint32(readBuffer, 0);
1249 uint32_t packetHeaderWord1 =
ReadUint32(readBuffer, 4);
1250 BOOST_TEST(((packetHeaderWord0 >> 26) & 0x3F) == 0);
1251 BOOST_TEST(((packetHeaderWord0 >> 16) & 0x3FF) == 2);
1252 BOOST_TEST(packetHeaderWord1 == 936);
1255 uint32_t bodyHeaderWord0 =
ReadUint32(readBuffer, 8);
1256 uint32_t bodyHeaderWord1 =
ReadUint32(readBuffer, 12);
1257 uint32_t bodyHeaderWord2 =
ReadUint32(readBuffer, 16);
1258 uint32_t bodyHeaderWord3 =
ReadUint32(readBuffer, 20);
1259 uint32_t bodyHeaderWord4 =
ReadUint32(readBuffer, 24);
1260 uint32_t bodyHeaderWord5 =
ReadUint32(readBuffer, 28);
1261 uint16_t deviceRecordCount =
static_cast<uint16_t
>(bodyHeaderWord0 >> 16);
1262 uint16_t counterSetRecordCount =
static_cast<uint16_t
>(bodyHeaderWord2 >> 16);
1263 uint16_t categoryRecordCount =
static_cast<uint16_t
>(bodyHeaderWord4 >> 16);
1264 BOOST_TEST(deviceRecordCount == 2);
1265 BOOST_TEST(bodyHeaderWord1 == 0);
1266 BOOST_TEST(counterSetRecordCount == 1);
1267 BOOST_TEST(bodyHeaderWord3 == 8);
1268 BOOST_TEST(categoryRecordCount == 2);
1269 BOOST_TEST(bodyHeaderWord5 == 12);
1272 uint32_t deviceRecordOffset0 =
ReadUint32(readBuffer, 32);
1273 uint32_t deviceRecordOffset1 =
ReadUint32(readBuffer, 36);
1274 BOOST_TEST(deviceRecordOffset0 == 0);
1275 BOOST_TEST(deviceRecordOffset1 == 20);
1278 uint32_t counterSetRecordOffset0 =
ReadUint32(readBuffer, 40);
1279 BOOST_TEST(counterSetRecordOffset0 == 40);
1282 uint32_t categoryRecordOffset0 =
ReadUint32(readBuffer, 44);
1283 uint32_t categoryRecordOffset1 =
ReadUint32(readBuffer, 48);
1284 BOOST_TEST(categoryRecordOffset0 == 64);
1285 BOOST_TEST(categoryRecordOffset1 == 476);
1289 uint32_t packetBodyPoolOffset = 2u * uint32_t_size +
1290 6u * uint32_t_size +
1291 deviceRecordCount * uint32_t_size +
1292 counterSetRecordCount * uint32_t_size +
1300 uint32_t name_offset;
1301 uint32_t name_length;
1304 std::vector<DeviceRecord> deviceRecords;
1305 uint32_t deviceRecordsPointerTableOffset = 2u * uint32_t_size +
1306 6u * uint32_t_size +
1309 const unsigned char* readData = readBuffer->GetReadableData();
1311 for (uint32_t i = 0; i < deviceRecordCount; i++)
1314 uint32_t deviceRecordOffset =
ReadUint32(readBuffer, deviceRecordsPointerTableOffset + i * uint32_t_size);
1317 uint32_t deviceRecordWord0 =
ReadUint32(readBuffer,
1318 packetBodyPoolOffset + deviceRecordOffset + 0 * uint32_t_size);
1319 uint32_t deviceRecordWord1 =
ReadUint32(readBuffer,
1320 packetBodyPoolOffset + deviceRecordOffset + 1 * uint32_t_size);
1321 DeviceRecord deviceRecord;
1322 deviceRecord.uid =
static_cast<uint16_t
>(deviceRecordWord0 >> 16);
1323 deviceRecord.cores =
static_cast<uint16_t
>(deviceRecordWord0);
1324 deviceRecord.name_offset = deviceRecordWord1;
1326 uint32_t deviceRecordPoolOffset = packetBodyPoolOffset +
1327 deviceRecordOffset +
1329 deviceRecord.name_offset;
1330 uint32_t deviceRecordNameLength =
ReadUint32(readBuffer, deviceRecordPoolOffset);
1331 deviceRecord.name_length = deviceRecordNameLength;
1332 unsigned char deviceRecordNameNullTerminator =
1333 ReadUint8(readBuffer, deviceRecordPoolOffset + uint32_t_size + deviceRecordNameLength - 1);
1334 BOOST_CHECK(deviceRecordNameNullTerminator ==
'\0');
1335 std::vector<unsigned char> deviceRecordNameBuffer(deviceRecord.name_length - 1);
1336 std::memcpy(deviceRecordNameBuffer.data(),
1337 readData + deviceRecordPoolOffset +
uint32_t_size, deviceRecordNameBuffer.size());
1338 deviceRecord.name.assign(deviceRecordNameBuffer.begin(), deviceRecordNameBuffer.end());
1340 deviceRecords.push_back(deviceRecord);
1345 for (
const DeviceRecord& deviceRecord : deviceRecords)
1355 struct CounterSetRecord
1359 uint32_t name_offset;
1360 uint32_t name_length;
1363 std::vector<CounterSetRecord> counterSetRecords;
1364 uint32_t counterSetRecordsPointerTableOffset = 2u * uint32_t_size +
1365 6u * uint32_t_size +
1367 for (uint32_t i = 0; i < counterSetRecordCount; i++)
1370 uint32_t counterSetRecordOffset =
ReadUint32(readBuffer,
1371 counterSetRecordsPointerTableOffset + i * uint32_t_size);
1374 uint32_t counterSetRecordWord0 =
ReadUint32(readBuffer,
1375 packetBodyPoolOffset + counterSetRecordOffset + 0 * uint32_t_size);
1376 uint32_t counterSetRecordWord1 =
ReadUint32(readBuffer,
1377 packetBodyPoolOffset + counterSetRecordOffset + 1 * uint32_t_size);
1378 CounterSetRecord counterSetRecord;
1379 counterSetRecord.uid =
static_cast<uint16_t
>(counterSetRecordWord0 >> 16);
1380 counterSetRecord.count =
static_cast<uint16_t
>(counterSetRecordWord0);
1381 counterSetRecord.name_offset = counterSetRecordWord1;
1383 uint32_t counterSetRecordPoolOffset = packetBodyPoolOffset +
1384 counterSetRecordOffset +
1386 counterSetRecord.name_offset;
1387 uint32_t counterSetRecordNameLength =
ReadUint32(readBuffer, counterSetRecordPoolOffset);
1388 counterSetRecord.name_length = counterSetRecordNameLength;
1389 unsigned char counterSetRecordNameNullTerminator =
1390 ReadUint8(readBuffer, counterSetRecordPoolOffset + uint32_t_size + counterSetRecordNameLength - 1);
1391 BOOST_CHECK(counterSetRecordNameNullTerminator ==
'\0');
1392 std::vector<unsigned char> counterSetRecordNameBuffer(counterSetRecord.name_length - 1);
1393 std::memcpy(counterSetRecordNameBuffer.data(),
1394 readData + counterSetRecordPoolOffset +
uint32_t_size, counterSetRecordNameBuffer.size());
1395 counterSetRecord.name.assign(counterSetRecordNameBuffer.begin(), counterSetRecordNameBuffer.end());
1397 counterSetRecords.push_back(counterSetRecord);
1402 for (
const CounterSetRecord& counterSetRecord : counterSetRecords)
1414 uint16_t counter_uid;
1415 uint16_t max_counter_uid;
1417 uint16_t counter_set;
1418 uint16_t counter_class;
1419 uint16_t interpolation;
1421 uint32_t name_offset;
1422 uint32_t name_length;
1424 uint32_t description_offset;
1425 uint32_t description_length;
1426 std::string description;
1427 uint32_t units_offset;
1428 uint32_t units_length;
1432 struct CategoryRecord
1435 uint16_t counter_set;
1436 uint16_t event_count;
1437 uint32_t event_pointer_table_offset;
1438 uint32_t name_offset;
1439 uint32_t name_length;
1441 std::vector<uint32_t> event_pointer_table;
1442 std::vector<EventRecord> event_records;
1444 std::vector<CategoryRecord> categoryRecords;
1445 uint32_t categoryRecordsPointerTableOffset = 2u * uint32_t_size +
1446 6u * uint32_t_size +
1448 for (uint32_t i = 0; i < categoryRecordCount; i++)
1451 uint32_t categoryRecordOffset =
ReadUint32(readBuffer, categoryRecordsPointerTableOffset + i * uint32_t_size);
1454 uint32_t categoryRecordWord0 =
ReadUint32(readBuffer,
1455 packetBodyPoolOffset + categoryRecordOffset + 0 * uint32_t_size);
1456 uint32_t categoryRecordWord1 =
ReadUint32(readBuffer,
1457 packetBodyPoolOffset + categoryRecordOffset + 1 * uint32_t_size);
1458 uint32_t categoryRecordWord2 =
ReadUint32(readBuffer,
1459 packetBodyPoolOffset + categoryRecordOffset + 2 * uint32_t_size);
1460 uint32_t categoryRecordWord3 =
ReadUint32(readBuffer,
1461 packetBodyPoolOffset + categoryRecordOffset + 3 * uint32_t_size);
1462 CategoryRecord categoryRecord;
1463 categoryRecord.device =
static_cast<uint16_t
>(categoryRecordWord0 >> 16);
1464 categoryRecord.counter_set =
static_cast<uint16_t
>(categoryRecordWord0);
1465 categoryRecord.event_count =
static_cast<uint16_t
>(categoryRecordWord1 >> 16);
1466 categoryRecord.event_pointer_table_offset = categoryRecordWord2;
1467 categoryRecord.name_offset = categoryRecordWord3;
1469 uint32_t categoryRecordPoolOffset = packetBodyPoolOffset +
1470 categoryRecordOffset +
1473 uint32_t categoryRecordNameLength =
ReadUint32(readBuffer,
1474 categoryRecordPoolOffset + categoryRecord.name_offset);
1475 categoryRecord.name_length = categoryRecordNameLength;
1476 unsigned char categoryRecordNameNullTerminator =
1478 categoryRecordPoolOffset +
1479 categoryRecord.name_offset +
1481 categoryRecordNameLength - 1);
1482 BOOST_CHECK(categoryRecordNameNullTerminator ==
'\0');
1483 std::vector<unsigned char> categoryRecordNameBuffer(categoryRecord.name_length - 1);
1484 std::memcpy(categoryRecordNameBuffer.data(),
1486 categoryRecordPoolOffset +
1487 categoryRecord.name_offset +
1489 categoryRecordNameBuffer.size());
1490 categoryRecord.name.assign(categoryRecordNameBuffer.begin(), categoryRecordNameBuffer.end());
1492 categoryRecord.event_pointer_table.resize(categoryRecord.event_count);
1493 for (uint32_t eventIndex = 0; eventIndex < categoryRecord.event_count; eventIndex++)
1495 uint32_t eventRecordOffset =
ReadUint32(readBuffer,
1496 categoryRecordPoolOffset +
1497 categoryRecord.event_pointer_table_offset +
1498 eventIndex * uint32_t_size);
1499 categoryRecord.event_pointer_table[eventIndex] = eventRecordOffset;
1502 uint32_t eventRecordWord0 =
ReadUint32(readBuffer,
1503 categoryRecordPoolOffset + eventRecordOffset + 0 * uint32_t_size);
1504 uint32_t eventRecordWord1 =
ReadUint32(readBuffer,
1505 categoryRecordPoolOffset + eventRecordOffset + 1 * uint32_t_size);
1506 uint32_t eventRecordWord2 =
ReadUint32(readBuffer,
1507 categoryRecordPoolOffset + eventRecordOffset + 2 * uint32_t_size);
1508 uint64_t eventRecordWord34 =
ReadUint64(readBuffer,
1509 categoryRecordPoolOffset + eventRecordOffset + 3 * uint32_t_size);
1510 uint32_t eventRecordWord5 =
ReadUint32(readBuffer,
1511 categoryRecordPoolOffset + eventRecordOffset + 5 * uint32_t_size);
1512 uint32_t eventRecordWord6 =
ReadUint32(readBuffer,
1513 categoryRecordPoolOffset + eventRecordOffset + 6 * uint32_t_size);
1514 uint32_t eventRecordWord7 =
ReadUint32(readBuffer,
1515 categoryRecordPoolOffset + eventRecordOffset + 7 * uint32_t_size);
1516 EventRecord eventRecord;
1517 eventRecord.counter_uid =
static_cast<uint16_t
>(eventRecordWord0);
1518 eventRecord.max_counter_uid =
static_cast<uint16_t
>(eventRecordWord0 >> 16);
1519 eventRecord.device =
static_cast<uint16_t
>(eventRecordWord1 >> 16);
1520 eventRecord.counter_set =
static_cast<uint16_t
>(eventRecordWord1);
1521 eventRecord.counter_class =
static_cast<uint16_t
>(eventRecordWord2 >> 16);
1522 eventRecord.interpolation =
static_cast<uint16_t
>(eventRecordWord2);
1523 std::memcpy(&eventRecord.multiplier, &eventRecordWord34,
sizeof(eventRecord.multiplier));
1524 eventRecord.name_offset =
static_cast<uint32_t
>(eventRecordWord5);
1525 eventRecord.description_offset =
static_cast<uint32_t
>(eventRecordWord6);
1526 eventRecord.units_offset =
static_cast<uint32_t
>(eventRecordWord7);
1528 uint32_t eventRecordPoolOffset = categoryRecordPoolOffset +
1532 uint32_t eventRecordNameLength =
ReadUint32(readBuffer,
1533 eventRecordPoolOffset + eventRecord.name_offset);
1534 eventRecord.name_length = eventRecordNameLength;
1535 unsigned char eventRecordNameNullTerminator =
1537 eventRecordPoolOffset +
1538 eventRecord.name_offset +
1540 eventRecordNameLength - 1);
1541 BOOST_CHECK(eventRecordNameNullTerminator ==
'\0');
1542 std::vector<unsigned char> eventRecordNameBuffer(eventRecord.name_length - 1);
1543 std::memcpy(eventRecordNameBuffer.data(),
1545 eventRecordPoolOffset +
1546 eventRecord.name_offset +
1548 eventRecordNameBuffer.size());
1549 eventRecord.name.assign(eventRecordNameBuffer.begin(), eventRecordNameBuffer.end());
1551 uint32_t eventRecordDescriptionLength =
ReadUint32(readBuffer,
1552 eventRecordPoolOffset + eventRecord.description_offset);
1553 eventRecord.description_length = eventRecordDescriptionLength;
1554 unsigned char eventRecordDescriptionNullTerminator =
1556 eventRecordPoolOffset +
1557 eventRecord.description_offset +
1559 eventRecordDescriptionLength - 1);
1560 BOOST_CHECK(eventRecordDescriptionNullTerminator ==
'\0');
1561 std::vector<unsigned char> eventRecordDescriptionBuffer(eventRecord.description_length - 1);
1562 std::memcpy(eventRecordDescriptionBuffer.data(),
1564 eventRecordPoolOffset +
1565 eventRecord.description_offset +
1567 eventRecordDescriptionBuffer.size());
1568 eventRecord.description.assign(eventRecordDescriptionBuffer.begin(),
1569 eventRecordDescriptionBuffer.end());
1571 if (eventRecord.units_offset > 0)
1573 uint32_t eventRecordUnitsLength =
ReadUint32(readBuffer,
1574 eventRecordPoolOffset + eventRecord.units_offset);
1575 eventRecord.units_length = eventRecordUnitsLength;
1576 unsigned char eventRecordUnitsNullTerminator =
1578 eventRecordPoolOffset +
1579 eventRecord.units_offset +
1581 eventRecordUnitsLength - 1);
1582 BOOST_CHECK(eventRecordUnitsNullTerminator ==
'\0');
1583 std::vector<unsigned char> eventRecordUnitsBuffer(eventRecord.units_length - 1);
1584 std::memcpy(eventRecordUnitsBuffer.data(),
1586 eventRecordPoolOffset +
1587 eventRecord.units_offset +
1589 eventRecordUnitsBuffer.size());
1590 eventRecord.units.assign(eventRecordUnitsBuffer.begin(), eventRecordUnitsBuffer.end());
1593 categoryRecord.event_records.push_back(eventRecord);
1596 categoryRecords.push_back(categoryRecord);
1601 for (
const CategoryRecord& categoryRecord : categoryRecords)
1611 for (
const EventRecord& eventRecord : categoryRecord.event_records)
1634 const std::string deviceName =
"inv@lid dev!c€";
1635 const Device* device =
nullptr;
1636 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1652 const std::string counterSetName =
"inv@lid count€rs€t";
1654 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1670 const std::string categoryName =
"c@t€gory";
1671 const Category* category =
nullptr;
1672 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1688 const std::string deviceName =
"inv@lid dev!c€";
1689 const Device* device =
nullptr;
1690 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1695 const std::string counterSetName =
"inv@lid count€rs€t";
1697 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1702 const std::string categoryName =
"c@t€gory";
1703 const Category* category =
nullptr;
1704 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName,
1706 counterSet->
m_Uid));
1722 const std::string deviceName =
"valid device";
1723 const Device* device =
nullptr;
1724 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1729 const std::string counterSetName =
"valid counterset";
1731 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1736 const std::string categoryName =
"category";
1737 const Category* category =
nullptr;
1738 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName,
1740 counterSet->
m_Uid));
1745 const Counter* counter =
nullptr;
1746 BOOST_CHECK_NO_THROW(counter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1753 "counter description",
1754 std::string(
"invalid counter units"),
1757 counterSet->
m_Uid));
1770 SetActiveProfilingState(profilingStateMachine);
1775 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1779 sendThread.
Start(mockProfilingConnection);
1781 sendThread.
Start(mockProfilingConnection);
1782 sendThread.
Start(mockProfilingConnection);
1783 sendThread.
Start(mockProfilingConnection);
1784 sendThread.
Start(mockProfilingConnection);
1794 SetActiveProfilingState(profilingStateMachine);
1796 unsigned int totalWrittenSize = 0;
1801 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1802 sendThread.
Start(mockProfilingConnection);
1807 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1814 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
1815 unsigned int streamMetadataPacketsize = 118 + processNameSize;
1816 totalWrittenSize += streamMetadataPacketsize;
1820 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1825 unsigned int counterDirectoryPacketSize = 32;
1826 totalWrittenSize += counterDirectoryPacketSize;
1830 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1839 unsigned int periodicCounterCapturePacketSize = 28;
1840 totalWrittenSize += periodicCounterCapturePacketSize;
1844 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1852 periodicCounterCapturePacketSize = 22;
1853 totalWrittenSize += periodicCounterCapturePacketSize;
1865 periodicCounterCapturePacketSize = 46;
1866 totalWrittenSize += periodicCounterCapturePacketSize;
1877 periodicCounterCapturePacketSize = 40;
1878 totalWrittenSize += periodicCounterCapturePacketSize;
1882 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1887 periodicCounterCapturePacketSize = 30;
1888 totalWrittenSize += periodicCounterCapturePacketSize;
1894 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1906 SetActiveProfilingState(profilingStateMachine);
1908 unsigned int totalWrittenSize = 0;
1913 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1914 sendThread.
Start(mockProfilingConnection);
1919 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1928 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
1929 unsigned int streamMetadataPacketsize = 118 + processNameSize;
1930 totalWrittenSize += streamMetadataPacketsize;
1934 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1939 unsigned int counterDirectoryPacketSize = 32;
1940 totalWrittenSize += counterDirectoryPacketSize;
1945 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1954 unsigned int periodicCounterCapturePacketSize = 28;
1955 totalWrittenSize += periodicCounterCapturePacketSize;
1959 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1965 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1974 periodicCounterCapturePacketSize = 22;
1975 totalWrittenSize += periodicCounterCapturePacketSize;
1987 periodicCounterCapturePacketSize = 46;
1988 totalWrittenSize += periodicCounterCapturePacketSize;
2000 periodicCounterCapturePacketSize = 40;
2001 totalWrittenSize += periodicCounterCapturePacketSize;
2006 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
2011 periodicCounterCapturePacketSize = 30;
2012 totalWrittenSize += periodicCounterCapturePacketSize;
2028 SetActiveProfilingState(profilingStateMachine);
2030 unsigned int totalWrittenSize = 0;
2035 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
2036 sendThread.
Start(mockProfilingConnection);
2047 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2048 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2049 totalWrittenSize += streamMetadataPacketsize;
2055 unsigned int counterDirectoryPacketSize =32;
2056 totalWrittenSize += counterDirectoryPacketSize;
2067 unsigned int periodicCounterCapturePacketSize = 28;
2068 totalWrittenSize += periodicCounterCapturePacketSize;
2081 periodicCounterCapturePacketSize = 22;
2082 totalWrittenSize += periodicCounterCapturePacketSize;
2094 periodicCounterCapturePacketSize = 46;
2095 totalWrittenSize += periodicCounterCapturePacketSize;
2108 periodicCounterCapturePacketSize = 40;
2109 totalWrittenSize += periodicCounterCapturePacketSize;
2116 periodicCounterCapturePacketSize = 30;
2117 totalWrittenSize += periodicCounterCapturePacketSize;
2135 SetWaitingForAckProfilingState(profilingStateMachine);
2140 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2141 sendThread.
Start(mockProfilingConnection);
2144 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2145 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2152 SetActiveProfilingState(profilingStateMachine);
2153 sendThread.
Start(mockProfilingConnection);
2160 unsigned int counterDirectoryPacketSize = 32;
2163 {PacketType::CounterDirectory, counterDirectoryPacketSize}) == 1);
2165 sendThread.
Start(mockProfilingConnection);
2176 unsigned int periodicCounterCapturePacketSize = 28;
2178 {PacketType::PeriodicCounterCapture, periodicCounterCapturePacketSize}) == 1);
2184 SetActiveProfilingState(profilingStateMachine);
2189 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2190 sendThread.
Start(mockProfilingConnection);
2198 BOOST_TEST(packetBuffer.get());
2201 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2202 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2203 BOOST_TEST(packetBuffer->GetSize() == streamMetadataPacketsize);
2206 bufferManager.
Commit(packetBuffer, streamMetadataPacketsize);
2223 BOOST_TEST(!readBuffer);
2226 unsigned int reservedSize = 0;
2227 auto reservedBuffer = bufferManager.
Reserve(512, reservedSize);
2228 BOOST_TEST(reservedSize == 512);
2229 BOOST_TEST(reservedBuffer.get());
2232 const auto metaDataPacketCount =
2235 BOOST_TEST(metaDataPacketCount >= 1);
2236 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::CounterDirectory, 32}) == 1);
2237 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::PeriodicCounterCapture, 28}) == 1);
2239 BOOST_TEST(metaDataPacketCount + 2 == writtenDataSize);
2249 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2250 sendThread.
Start(mockProfilingConnection);
2259 SetNotConnectedProfilingState(profilingStateMachine);
2264 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2265 sendThread.
Start(mockProfilingConnection);
2274 SetWaitingForAckProfilingState(profilingStateMachine);
2278 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2279 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2284 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2285 sendThread.
Start(mockProfilingConnection);
2289 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2294 BOOST_TEST(writtenDataSize >= 1);
2296 {PacketType::StreamMetaData, streamMetadataPacketsize}) == writtenDataSize);
2302 SetWaitingForAckProfilingState(profilingStateMachine);
2306 unsigned int processNameSize = processName.empty() ? 0 : boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2307 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2312 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2313 sendThread.
Start(mockProfilingConnection);
2319 sendThread.
Start(mockProfilingConnection);
2324 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::StreamMetaData, streamMetadataPacketsize}) >= 1);
2326 mockProfilingConnection.
Clear();
2329 sendThread.
Start(mockProfilingConnection);
2335 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2343 BOOST_TEST(writtenDataSize >= 1);
2345 {PacketType::StreamMetaData, streamMetadataPacketsize}) == writtenDataSize);
void Start(IProfilingConnection &profilingConnection) override
Start the thread.
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
bool CreateCounterSetRecordTest(const CounterSetPtr &counterSet, CounterSetRecord &counterSetRecord, std::string &errorMessage)
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
std::string GetSoftwareVersion()
#define ARMNN_NO_CONVERSION_WARN_BEGIN
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) override
std::unique_ptr< CounterSet > CounterSetPtr
const CounterSet * GetCounterSet(uint16_t uid) const override
const Device * GetDevice(uint16_t uid) const override
const Category * RegisterCategory(const std::string &categoryName, const Optional< uint16_t > &deviceUid=EmptyOptional(), const Optional< uint16_t > &counterSetUid=EmptyOptional()) override
unsigned int GetReadableSize() const
#define ARMNN_FALLTHROUGH
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
uint16_t ReadUint16(const IPacketBufferPtr &packetBuffer, unsigned int offset)
unsigned int GetReadSize() const
std::vector< uint32_t > EventRecord
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
std::string GetSoftwareInfo()
static const unsigned int PIPE_MAGIC
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
void TransitionToState(ProfilingState newState)
const Counter * GetCounter(uint16_t uid) const override
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
bool CreateCategoryRecordTest(const CategoryPtr &category, const Counters &counters, CategoryRecord &categoryRecord, std::string &errorMessage)
std::string GetProcessName()
bool CreateEventRecordTest(const CounterPtr &counter, EventRecord &eventRecord, std::string &errorMessage)
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
long CheckForPacket(const std::pair< PacketType, uint32_t > packetInfo)
uint16_t GetCounterCount() const override
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
std::string GetHardwareVersion()
std::string m_Description
void Stop(bool rethrowSendThreadExceptions=true) override
Stop the thread.
void MarkRead(IPacketBufferPtr &packetBuffer) override
constexpr uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch)
std::shared_ptr< Counter > CounterPtr
IPacketBufferPtr GetReadableBuffer() override
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0, const armnn::Optional< std::string > &parentCategoryName=armnn::EmptyOptional())
std::vector< uint16_t > m_Counters
uint16_t GetCounterCount() const override
uint16_t GetCategoryCount() const override
std::unique_ptr< Category > CategoryPtr
ProfilingState GetCurrentState() const
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
void SetReadyToRead() override
Set a "ready to read" flag in the buffer to notify the reading thread to start reading it...
unsigned int GetCommittedSize() const
std::vector< uint32_t > CounterSetRecord
std::unique_ptr< Device > DevicePtr
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const IndexValuePairsVector &values) override
Create and write a PeriodicCounterCapturePacket from the parameters to the buffer.
std::vector< uint32_t > CategoryRecord
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
BOOST_AUTO_TEST_SUITE_END()
uint16_t GetDeviceCount() const override
uint16_t GetCounterSetCount() const override
#define MAX_METADATA_PACKET_LENGTH
uint16_t GetCounterSetCount() const override
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 armnn::Optional< std::string > &units=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &numberOfCores=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &deviceUid=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &counterSetUid=armnn::EmptyOptional())
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
bool CreateDeviceRecordTest(const DevicePtr &device, DeviceRecord &deviceRecord, std::string &errorMessage)
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const std::vector< CounterValue > &values) override
#define ARMNN_NO_CONVERSION_WARN_END
std::unordered_map< uint16_t, CounterPtr > Counters
IPacketBufferPtr GetReadableBuffer() override
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
uint16_t GetDeviceCount() const override
uint8_t ReadUint8(const IPacketBufferPtr &packetBuffer, unsigned int offset)
std::vector< uint32_t > DeviceRecord
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0, const armnn::Optional< std::string > &parentCategoryName=armnn::EmptyOptional())
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
uint16_t GetCategoryCount() const override
unsigned long GetWrittenDataSize()
const Category * GetCategory(const std::string &name) const override
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
const Category * RegisterCategory(const std::string &categoryName, const armnn::Optional< uint16_t > &deviceUid=armnn::EmptyOptional(), const armnn::Optional< uint16_t > &counterSetUid=armnn::EmptyOptional())