11 #include <CounterDirectory.hpp> 21 #include <common/include/Constants.hpp> 24 #include <boost/test/unit_test.hpp> 25 #include <boost/numeric/conversion/cast.hpp> 35 uint16_t constexpr WAIT_UNTIL_READABLE_MS = 20;
53 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
73 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
94 BOOST_CHECK_MESSAGE(
false,
"Invalid profiling state");
112 const char* buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
114 BOOST_TEST(strcmp(buffer,
"SendStreamMetaDataPacket") == 0);
122 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
124 BOOST_TEST(strcmp(buffer,
"SendCounterDirectoryPacket") == 0);
128 uint64_t timestamp = 0;
129 std::vector<CounterValue> indexValuePairs;
134 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
136 BOOST_TEST(strcmp(buffer,
"SendPeriodicCounterCapturePacket") == 0);
140 uint32_t capturePeriod = 0;
141 std::vector<uint16_t> selectedCounterIds;
145 buffer =
reinterpret_cast<const char*
>(packetBuffer->GetReadableData());
147 BOOST_TEST(strcmp(buffer,
"SendPeriodicCounterSelectionPacket") == 0);
158 uint32_t capturePeriod = 1000;
159 std::vector<uint16_t> selectedCounterIds;
168 auto readBuffer2 = mockBuffer2.GetReadableBuffer();
170 uint32_t headerWord0 =
ReadUint32(readBuffer2, 0);
171 uint32_t headerWord1 =
ReadUint32(readBuffer2, 4);
174 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
175 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
176 BOOST_TEST(headerWord1 == 4);
177 BOOST_TEST(period == 1000);
183 selectedCounterIds.reserve(5);
184 selectedCounterIds.emplace_back(100);
185 selectedCounterIds.emplace_back(200);
186 selectedCounterIds.emplace_back(300);
187 selectedCounterIds.emplace_back(400);
188 selectedCounterIds.emplace_back(500);
196 BOOST_TEST(((headerWord0 >> 26) & 0x3F) == 0);
197 BOOST_TEST(((headerWord0 >> 16) & 0x3FF) == 4);
198 BOOST_TEST(headerWord1 == 14);
199 BOOST_TEST(period == 1000);
201 uint16_t counterId = 0;
202 uint32_t offset = 12;
205 for(
const uint16_t&
id : selectedCounterIds)
208 BOOST_TEST(counterId ==
id);
221 auto captureTimestamp = std::chrono::steady_clock::now();
222 uint64_t time =
static_cast<uint64_t
>(captureTimestamp.time_since_epoch().count());
223 std::vector<CounterValue> indexValuePairs;
233 auto readBuffer2 = mockBuffer2.GetReadableBuffer();
235 uint32_t headerWord0 =
ReadUint32(readBuffer2, 0);
236 uint32_t headerWord1 =
ReadUint32(readBuffer2, 4);
237 uint64_t readTimestamp =
ReadUint64(readBuffer2, 8);
239 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
240 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
241 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
242 BOOST_TEST(headerWord1 == 8);
243 BOOST_TEST(time == readTimestamp);
249 indexValuePairs.reserve(5);
260 uint64_t readTimestamp2 =
ReadUint64(readBuffer3, 8);
262 BOOST_TEST(((headerWord0 >> 26) & 0x0000003F) == 3);
263 BOOST_TEST(((headerWord0 >> 19) & 0x0000007F) == 0);
264 BOOST_TEST(((headerWord0 >> 16) & 0x00000007) == 0);
265 BOOST_TEST(headerWord1 == 38);
266 BOOST_TEST(time == readTimestamp2);
268 uint16_t counterIndex = 0;
269 uint32_t counterValue = 100;
270 uint32_t offset = 16;
273 for (
auto it = indexValuePairs.begin(), end = indexValuePairs.end(); it != end; ++it)
276 uint16_t readIndex =
ReadUint16(readBuffer3, offset);
277 BOOST_TEST(counterIndex == readIndex);
282 uint32_t readValue =
ReadUint32(readBuffer3, offset);
283 BOOST_TEST(counterValue == readValue);
294 uint32_t sizeUint32 =
numeric_cast<uint32_t>(
sizeof(uint32_t));
308 uint32_t processNameSize =
numeric_cast<uint32_t>(processName.size()) + 1;
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;
330 BOOST_TEST(
ReadUint32(readBuffer2, offset) == armnnProfiling::PIPE_MAGIC);
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) == poolOffset);
341 offset += sizeUint32;
342 poolOffset += infoSize;
343 BOOST_TEST(
ReadUint32(readBuffer2, offset) == poolOffset);
344 offset += sizeUint32;
345 poolOffset += hardwareVersionSize;
346 BOOST_TEST(
ReadUint32(readBuffer2, offset) == poolOffset);
347 offset += sizeUint32;
348 poolOffset += softwareVersionSize;
349 BOOST_TEST(
ReadUint32(readBuffer2, offset) == poolOffset);
350 offset += sizeUint32;
351 poolOffset += processNameSize;
352 BOOST_TEST(
ReadUint32(readBuffer2, offset) == poolOffset);
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,
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[]
577 BOOST_CHECK(eventRecordWord2[1] == counterInterpolation);
578 BOOST_CHECK(std::memcmp(eventRecordWord34, &counterMultiplier,
sizeof(counterMultiplier)) == 0);
581 uint32_t eventRecordBlockSize = 8u *
sizeof(uint32_t);
582 uint32_t counterNameOffset = eventRecordBlockSize;
583 uint32_t counterDescriptionOffset = counterNameOffset +
589 size_t counterUnitsOffset = counterDescriptionOffset +
591 counterDescription.size() +
598 BOOST_CHECK(eventRecord[6] == counterDescriptionOffset);
602 auto eventRecordPool =
reinterpret_cast<unsigned char*
>(eventRecord.data());
606 BOOST_CHECK(eventRecordPool[counterNameOffset] == counterName.size() + 1);
612 counterName.size()) == 0);
614 BOOST_CHECK(eventRecordPool[counterNameOffset + uint32_t_size + counterName.size()] ==
'\0');
617 BOOST_CHECK(eventRecordPool[counterDescriptionOffset] == counterDescription.size() + 1);
620 counterDescriptionOffset +
622 counterDescription.data(),
623 counterDescription.size()) == 0);
625 BOOST_CHECK(eventRecordPool[counterDescriptionOffset + uint32_t_size + counterDescription.size()] ==
'\0');
628 BOOST_CHECK(eventRecordPool[counterUnitsOffset] == counterUnits.size() + 1);
634 counterUnits.size()) == 0);
636 BOOST_CHECK(eventRecordPool[counterUnitsOffset + uint32_t_size + counterUnits.size()] ==
'\0');
645 uint16_t counterUid = 44312;
646 uint16_t maxCounterUid = 345;
647 uint16_t deviceUid = 101;
648 uint16_t counterSetUid = 34035;
649 uint16_t counterClass = 0;
650 uint16_t counterInterpolation = 1;
651 double counterMultiplier = 4435.0023f;
652 const std::string counterName =
"some_valid_counter";
653 const std::string counterDescription =
"a_counter_for_testing";
654 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
658 counterInterpolation,
669 std::string errorMessage;
676 uint16_t eventRecordWord0[]
678 static_cast<uint16_t
>(eventRecord[0] >> 16),
679 static_cast<uint16_t>(eventRecord[0])
681 uint16_t eventRecordWord1[]
683 static_cast<uint16_t
>(eventRecord[1] >> 16),
684 static_cast<uint16_t>(eventRecord[1])
686 uint16_t eventRecordWord2[]
688 static_cast<uint16_t
>(eventRecord[2] >> 16),
689 static_cast<uint16_t>(eventRecord[2])
691 uint32_t eventRecordWord34[]
701 BOOST_CHECK(eventRecordWord2[1] == counterInterpolation);
702 BOOST_CHECK(std::memcmp(eventRecordWord34, &counterMultiplier,
sizeof(counterMultiplier)) == 0);
705 uint32_t eventRecordBlockSize = 8u *
sizeof(uint32_t);
706 uint32_t counterNameOffset = eventRecordBlockSize;
707 uint32_t counterDescriptionOffset = counterNameOffset +
715 BOOST_CHECK(eventRecord[6] == counterDescriptionOffset);
719 auto eventRecordPool =
reinterpret_cast<unsigned char*
>(eventRecord.data());
723 BOOST_CHECK(eventRecordPool[counterNameOffset] == counterName.size() + 1);
729 counterName.size()) == 0);
731 BOOST_CHECK(eventRecordPool[counterNameOffset + uint32_t_size + counterName.size()] ==
'\0');
734 BOOST_CHECK(eventRecordPool[counterDescriptionOffset] == counterDescription.size() + 1);
737 counterDescriptionOffset +
739 counterDescription.data(),
740 counterDescription.size()) == 0);
742 BOOST_CHECK(eventRecordPool[counterDescriptionOffset + uint32_t_size + counterDescription.size()] ==
'\0');
751 uint16_t counterUid = 7256;
752 uint16_t maxCounterUid = 132;
753 uint16_t deviceUid = 132;
754 uint16_t counterSetUid = 4497;
755 uint16_t counterClass = 1;
756 uint16_t counterInterpolation = 1;
757 double counterMultiplier = 1234.567f;
758 const std::string counterName =
"some_invalid_counter £££";
759 const std::string counterDescription =
"a_counter_for_testing";
760 const std::string counterUnits =
"Mrads2";
761 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
765 counterInterpolation,
776 std::string errorMessage;
790 uint16_t counterUid = 7256;
791 uint16_t maxCounterUid = 132;
792 uint16_t deviceUid = 132;
793 uint16_t counterSetUid = 4497;
794 uint16_t counterClass = 1;
795 uint16_t counterInterpolation = 1;
796 double counterMultiplier = 1234.567f;
797 const std::string counterName =
"some_invalid_counter";
798 const std::string counterDescription =
"an invalid d€scription";
799 const std::string counterUnits =
"Mrads2";
800 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
804 counterInterpolation,
815 std::string errorMessage;
829 uint16_t counterUid = 7256;
830 uint16_t maxCounterUid = 132;
831 uint16_t deviceUid = 132;
832 uint16_t counterSetUid = 4497;
833 uint16_t counterClass = 1;
834 uint16_t counterInterpolation = 1;
835 double counterMultiplier = 1234.567f;
836 const std::string counterName =
"some_invalid_counter";
837 const std::string counterDescription =
"a valid description";
838 const std::string counterUnits =
"Mrad s2";
839 const CounterPtr counter = std::make_unique<Counter>(armnn::profiling::BACKEND_ID,
843 counterInterpolation,
854 std::string errorMessage;
868 const std::string categoryName =
"some_category";
869 const CategoryPtr category = std::make_unique<Category>(categoryName);
871 category->m_Counters = { 11u, 23u, 5670u };
875 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
887 counters.insert(std::make_pair<uint16_t, CounterPtr>(23,
895 "the second counter",
899 counters.insert(std::make_pair<uint16_t, CounterPtr>(5670,
906 "and this is number 3",
911 Counter* counter1 = counters.find(11)->second.get();
912 Counter* counter2 = counters.find(23)->second.get();
913 Counter* counter3 = counters.find(5670)->second.get();
921 std::string errorMessage;
929 uint16_t categoryRecordWord1[]
931 static_cast<uint16_t
>(categoryRecord[0] >> 16),
932 static_cast<uint16_t>(categoryRecord[0])
934 BOOST_CHECK(categoryRecordWord1[0] == categoryEventCount);
941 uint32_t eventPointerTableOffset = categoryRecordBlockSize;
942 uint32_t categoryNameOffset = eventPointerTableOffset +
946 BOOST_CHECK(categoryRecord[1] == eventPointerTableOffset);
947 BOOST_CHECK(categoryRecord[2] == categoryNameOffset);
949 auto categoryRecordPool =
reinterpret_cast<unsigned char*
>(categoryRecord.data());
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 + categoryRecordBlockSize + eventRecord0Offset,
976 sizeof(eventRecord0Word0));
981 uint32_t counter1NameOffset = 0;
982 std::memcpy(&counter1NameOffset, categoryRecordPool + eventRecord0Offset + 5u * uint32_t_size, uint32_t_size);
985 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
986 categoryRecordBlockSize +
989 ] == counter1->
m_Name.size() + 1);
993 categoryRecordBlockSize +
999 counter1->
m_Name.size()) == 0);
1001 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
1002 categoryRecordBlockSize +
1003 8u * uint32_t_size +
1004 counter1NameOffset +
1010 uint32_t counter2NameOffset = 0;
1011 std::memcpy(&counter2NameOffset, categoryRecordPool +
1012 categoryRecordBlockSize +
1013 eventRecord1Offset +
1016 BOOST_CHECK(counter2NameOffset == 8u * uint32_t_size );
1019 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1020 categoryRecordBlockSize +
1022 ] == counter2->
m_Name.size() + 1);
1026 categoryRecordBlockSize +
1027 eventRecord1Offset +
1028 counter2NameOffset +
1031 counter2->
m_Name.size()) == 0);
1035 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1036 categoryRecordBlockSize +
1037 counter2NameOffset +
1043 uint32_t counter3NameOffset = 0;
1044 std::memcpy(&counter3NameOffset, categoryRecordPool + eventRecord2Offset + 5u * uint32_t_size, uint32_t_size);
1047 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1048 categoryRecordBlockSize +
1049 8u * uint32_t_size +
1051 ] == counter3->
m_Name.size() + 1);
1055 categoryRecordBlockSize +
1056 eventRecord2Offset +
1057 8u * uint32_t_size +
1058 counter3NameOffset +
1061 counter3->
m_Name.size()) == 0);
1063 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1064 categoryRecordBlockSize +
1065 8u * uint32_t_size +
1066 counter3NameOffset +
1078 const std::string categoryName =
"some invalid category";
1079 const CategoryPtr category = std::make_unique<Category>(categoryName);
1085 std::string errorMessage;
1099 const std::string categoryName =
"some_category";
1100 const CategoryPtr category = std::make_unique<Category>(categoryName);
1102 category->m_Counters = { 11u, 23u, 5670u };
1106 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
1114 "the first counter",
1119 Counter* counter1 = counters.find(11)->second.get();
1124 std::string errorMessage;
1138 const std::string device1Name =
"device1";
1139 const Device* device1 =
nullptr;
1140 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1145 const std::string device2Name =
"device2";
1146 const Device* device2 =
nullptr;
1147 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1164 const std::string device1Name =
"device1";
1165 const Device* device1 =
nullptr;
1166 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1171 const std::string device2Name =
"device2";
1172 const Device* device2 =
nullptr;
1173 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1178 const std::string counterSet1Name =
"counterset1";
1180 BOOST_CHECK_NO_THROW(counterSet1 = counterDirectory.
RegisterCounterSet(counterSet1Name));
1185 const std::string category1Name =
"category1";
1186 const Category* category1 =
nullptr;
1187 BOOST_CHECK_NO_THROW(category1 = counterDirectory.
RegisterCategory(category1Name));
1192 const std::string category2Name =
"category2";
1193 const Category* category2 =
nullptr;
1194 BOOST_CHECK_NO_THROW(category2 = counterDirectory.
RegisterCategory(category2Name));
1198 uint16_t numberOfCores = 4;
1201 const Counter* counter1 =
nullptr;
1202 BOOST_CHECK_NO_THROW(counter1 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1209 "counter1description",
1210 std::string(
"counter1units"),
1216 const Counter* counter2 =
nullptr;
1217 BOOST_CHECK_NO_THROW(counter2 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1224 "counter2description",
1225 std::string(
"counter2units"),
1233 const Counter* counter3 =
nullptr;
1234 BOOST_CHECK_NO_THROW(counter3 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1241 "counter3description",
1245 counterSet1->
m_Uid));
1258 const uint32_t packetHeaderWord0 =
ReadUint32(readBuffer, 0);
1259 const uint32_t packetHeaderWord1 =
ReadUint32(readBuffer, 4);
1260 BOOST_TEST(((packetHeaderWord0 >> 26) & 0x3F) == 0);
1261 BOOST_TEST(((packetHeaderWord0 >> 16) & 0x3FF) == 2);
1262 BOOST_TEST(packetHeaderWord1 == 432);
1265 const uint32_t bodyHeaderWord0 =
ReadUint32(readBuffer, 8);
1266 const uint32_t bodyHeaderWord1 =
ReadUint32(readBuffer, 12);
1267 const uint32_t bodyHeaderWord2 =
ReadUint32(readBuffer, 16);
1268 const uint32_t bodyHeaderWord3 =
ReadUint32(readBuffer, 20);
1269 const uint32_t bodyHeaderWord4 =
ReadUint32(readBuffer, 24);
1270 const uint32_t bodyHeaderWord5 =
ReadUint32(readBuffer, 28);
1271 const uint16_t deviceRecordCount =
static_cast<uint16_t
>(bodyHeaderWord0 >> 16);
1272 const uint16_t counterSetRecordCount =
static_cast<uint16_t
>(bodyHeaderWord2 >> 16);
1273 const uint16_t categoryRecordCount =
static_cast<uint16_t
>(bodyHeaderWord4 >> 16);
1274 BOOST_TEST(deviceRecordCount == 2);
1275 BOOST_TEST(bodyHeaderWord1 == bodyHeaderSize * 4);
1276 BOOST_TEST(counterSetRecordCount == 1);
1277 BOOST_TEST(bodyHeaderWord3 == 8 + bodyHeaderSize * 4);
1278 BOOST_TEST(categoryRecordCount == 2);
1279 BOOST_TEST(bodyHeaderWord5 == 12 + bodyHeaderSize * 4);
1282 const uint32_t deviceRecordOffset0 =
ReadUint32(readBuffer, 32);
1283 const uint32_t deviceRecordOffset1 =
ReadUint32(readBuffer, 36);
1284 BOOST_TEST(deviceRecordOffset0 == 20);
1285 BOOST_TEST(deviceRecordOffset1 == 40);
1288 const uint32_t counterSetRecordOffset0 =
ReadUint32(readBuffer, 40);
1289 BOOST_TEST(counterSetRecordOffset0 == 52);
1292 const uint32_t categoryRecordOffset0 =
ReadUint32(readBuffer, 44);
1293 const uint32_t categoryRecordOffset1 =
ReadUint32(readBuffer, 48);
1294 BOOST_TEST(categoryRecordOffset0 == 72);
1295 BOOST_TEST(categoryRecordOffset1 == 176);
1306 uint32_t name_offset;
1307 uint32_t name_length;
1310 std::vector<DeviceRecord> deviceRecords;
1311 const uint32_t deviceRecordsPointerTableOffset = packetHeaderSize +
1314 const unsigned char* readData = readBuffer->GetReadableData();
1316 uint32_t offset = 0;
1317 std::vector<uint32_t> data(800);
1325 std::vector<uint32_t> deviceRecordOffsets(deviceRecordCount);
1326 offset = deviceRecordsPointerTableOffset;
1327 for (uint32_t i = 0; i < deviceRecordCount; ++i)
1330 deviceRecordOffsets[i] =
ReadUint32(readBuffer, offset) + deviceRecordsPointerTableOffset;
1334 for (uint32_t i = 0; i < deviceRecordCount; i++)
1337 const uint32_t deviceRecordWord0 =
ReadUint32(readBuffer, deviceRecordOffsets[i] + 0 * uint32_t_size);
1338 const uint32_t deviceRecordWord1 =
ReadUint32(readBuffer, deviceRecordOffsets[i] + 1 * uint32_t_size);
1339 DeviceRecord deviceRecord;
1340 deviceRecord.uid =
static_cast<uint16_t
>(deviceRecordWord0 >> 16);
1341 deviceRecord.cores =
static_cast<uint16_t
>(deviceRecordWord0);
1342 deviceRecord.name_offset = deviceRecordWord1;
1344 uint32_t deviceRecordPoolOffset = deviceRecordOffsets[i] +
1345 deviceRecord.name_offset;
1346 uint32_t deviceRecordNameLength =
ReadUint32(readBuffer, deviceRecordPoolOffset);
1347 deviceRecord.name_length = deviceRecordNameLength;
1348 unsigned char deviceRecordNameNullTerminator =
1349 ReadUint8(readBuffer, deviceRecordPoolOffset + uint32_t_size + deviceRecordNameLength - 1);
1350 BOOST_CHECK(deviceRecordNameNullTerminator ==
'\0');
1351 std::vector<unsigned char> deviceRecordNameBuffer(deviceRecord.name_length - 1);
1352 std::memcpy(deviceRecordNameBuffer.data(),
1353 readData + deviceRecordPoolOffset +
uint32_t_size, deviceRecordNameBuffer.size());
1354 deviceRecord.name.assign(deviceRecordNameBuffer.begin(), deviceRecordNameBuffer.end());
1356 deviceRecords.push_back(deviceRecord);
1361 for (
const DeviceRecord& deviceRecord : deviceRecords)
1372 struct CounterSetRecord
1376 uint32_t name_offset;
1377 uint32_t name_length;
1380 std::vector<CounterSetRecord> counterSetRecords;
1381 const uint32_t counterSetRecordsPointerTableOffset = 2u * uint32_t_size +
1384 offset = counterSetRecordsPointerTableOffset;
1385 std::vector<uint32_t> counterSetRecordOffsets(counterSetRecordCount);
1387 for (uint32_t i = 0; i < counterSetRecordCount; ++i)
1390 counterSetRecordOffsets[i] =
ReadUint32(readBuffer, offset) + counterSetRecordsPointerTableOffset;
1394 for (uint32_t i = 0; i < counterSetRecordCount; i++)
1397 const uint32_t counterSetRecordWord0 =
ReadUint32(readBuffer, counterSetRecordOffsets[i] + 0 * uint32_t_size);
1398 const uint32_t counterSetRecordWord1 =
ReadUint32(readBuffer, counterSetRecordOffsets[i] + 1 * uint32_t_size);
1399 CounterSetRecord counterSetRecord;
1400 counterSetRecord.uid =
static_cast<uint16_t
>(counterSetRecordWord0 >> 16);
1401 counterSetRecord.count =
static_cast<uint16_t
>(counterSetRecordWord0);
1402 counterSetRecord.name_offset = counterSetRecordWord1;
1404 uint32_t counterSetRecordPoolOffset = counterSetRecordOffsets[i] +
1405 counterSetRecord.name_offset;
1406 uint32_t counterSetRecordNameLength =
ReadUint32(readBuffer, counterSetRecordPoolOffset);
1407 counterSetRecord.name_length = counterSetRecordNameLength;
1408 unsigned char counterSetRecordNameNullTerminator =
1409 ReadUint8(readBuffer, counterSetRecordPoolOffset + uint32_t_size + counterSetRecordNameLength - 1);
1410 BOOST_CHECK(counterSetRecordNameNullTerminator ==
'\0');
1411 std::vector<unsigned char> counterSetRecordNameBuffer(counterSetRecord.name_length - 1);
1412 std::memcpy(counterSetRecordNameBuffer.data(),
1413 readData + counterSetRecordPoolOffset +
uint32_t_size, counterSetRecordNameBuffer.size());
1414 counterSetRecord.name.assign(counterSetRecordNameBuffer.begin(), counterSetRecordNameBuffer.end());
1416 counterSetRecords.push_back(counterSetRecord);
1421 for (
const CounterSetRecord& counterSetRecord : counterSetRecords)
1433 uint16_t counter_uid;
1434 uint16_t max_counter_uid;
1436 uint16_t counter_set;
1437 uint16_t counter_class;
1438 uint16_t interpolation;
1440 uint32_t name_offset;
1441 uint32_t name_length;
1443 uint32_t description_offset;
1444 uint32_t description_length;
1445 std::string description;
1446 uint32_t units_offset;
1447 uint32_t units_length;
1451 struct CategoryRecord
1453 uint16_t event_count;
1454 uint32_t event_pointer_table_offset;
1455 uint32_t name_offset;
1456 uint32_t name_length;
1458 std::vector<uint32_t> event_pointer_table;
1459 std::vector<EventRecord> event_records;
1461 std::vector<CategoryRecord> categoryRecords;
1462 const uint32_t categoryRecordsPointerTableOffset = 2u * uint32_t_size +
1465 offset = categoryRecordsPointerTableOffset;
1466 std::vector<uint32_t> categoryRecordOffsets(categoryRecordCount);
1467 for (uint32_t i = 0; i < categoryRecordCount; ++i)
1470 categoryRecordOffsets[i] =
ReadUint32(readBuffer, offset) + categoryRecordsPointerTableOffset;
1474 for (uint32_t i = 0; i < categoryRecordCount; i++)
1477 const uint32_t categoryRecordWord1 =
ReadUint32(readBuffer, categoryRecordOffsets[i] + 0 * uint32_t_size);
1478 const uint32_t categoryRecordWord2 =
ReadUint32(readBuffer, categoryRecordOffsets[i] + 1 * uint32_t_size);
1479 const uint32_t categoryRecordWord3 =
ReadUint32(readBuffer, categoryRecordOffsets[i] + 2 * uint32_t_size);
1480 CategoryRecord categoryRecord;
1481 categoryRecord.event_count =
static_cast<uint16_t
>(categoryRecordWord1 >> 16);
1482 categoryRecord.event_pointer_table_offset = categoryRecordWord2;
1483 categoryRecord.name_offset = categoryRecordWord3;
1485 uint32_t categoryRecordNameLength =
ReadUint32(readBuffer,
1486 categoryRecordOffsets[i] + categoryRecord.name_offset);
1487 categoryRecord.name_length = categoryRecordNameLength;
1488 unsigned char categoryRecordNameNullTerminator =
1490 categoryRecordOffsets[i] +
1491 categoryRecord.name_offset +
1493 categoryRecordNameLength - 1);
1494 BOOST_CHECK(categoryRecordNameNullTerminator ==
'\0');
1495 std::vector<unsigned char> categoryRecordNameBuffer(categoryRecord.name_length - 1);
1496 std::memcpy(categoryRecordNameBuffer.data(),
1498 categoryRecordOffsets[i] +
1499 categoryRecord.name_offset +
1501 categoryRecordNameBuffer.size());
1502 categoryRecord.name.assign(categoryRecordNameBuffer.begin(), categoryRecordNameBuffer.end());
1504 categoryRecord.event_pointer_table.resize(categoryRecord.event_count);
1505 offset = categoryRecordOffsets[i] + categoryRecord.event_pointer_table_offset;
1506 for (uint32_t eventOffsetIndex = 0; eventOffsetIndex < categoryRecord.event_count; ++eventOffsetIndex)
1509 categoryRecord.event_pointer_table[eventOffsetIndex] =
ReadUint32(readBuffer, offset) +
1510 categoryRecordOffsets[i] +
1511 categoryRecord.event_pointer_table_offset;
1515 for (uint32_t eventIndex = 0; eventIndex < categoryRecord.event_count; eventIndex++)
1517 const uint32_t eventOffset = categoryRecord.event_pointer_table[eventIndex];
1519 const uint32_t eventRecordWord0 =
ReadUint32(readBuffer, eventOffset + 0 * uint32_t_size);
1520 const uint32_t eventRecordWord1 =
ReadUint32(readBuffer, eventOffset + 1 * uint32_t_size);
1521 const uint32_t eventRecordWord2 =
ReadUint32(readBuffer, eventOffset + 2 * uint32_t_size);
1522 const uint64_t eventRecordWord34 =
ReadUint64(readBuffer, eventOffset + 3 * uint32_t_size);
1523 const uint32_t eventRecordWord5 =
ReadUint32(readBuffer, eventOffset + 5 * uint32_t_size);
1524 const uint32_t eventRecordWord6 =
ReadUint32(readBuffer, eventOffset + 6 * uint32_t_size);
1525 const uint32_t eventRecordWord7 =
ReadUint32(readBuffer, eventOffset + 7 * uint32_t_size);
1527 EventRecord eventRecord;
1528 eventRecord.counter_uid =
static_cast<uint16_t
>(eventRecordWord0);
1529 eventRecord.max_counter_uid =
static_cast<uint16_t
>(eventRecordWord0 >> 16);
1530 eventRecord.device =
static_cast<uint16_t
>(eventRecordWord1 >> 16);
1531 eventRecord.counter_set =
static_cast<uint16_t
>(eventRecordWord1);
1532 eventRecord.counter_class =
static_cast<uint16_t
>(eventRecordWord2 >> 16);
1533 eventRecord.interpolation =
static_cast<uint16_t
>(eventRecordWord2);
1534 std::memcpy(&eventRecord.multiplier, &eventRecordWord34,
sizeof(eventRecord.multiplier));
1535 eventRecord.name_offset =
static_cast<uint32_t
>(eventRecordWord5);
1536 eventRecord.description_offset =
static_cast<uint32_t
>(eventRecordWord6);
1537 eventRecord.units_offset =
static_cast<uint32_t
>(eventRecordWord7);
1539 uint32_t eventRecordNameLength =
ReadUint32(readBuffer, eventOffset + eventRecord.name_offset);
1540 eventRecord.name_length = eventRecordNameLength;
1541 unsigned char eventRecordNameNullTerminator =
1544 eventRecord.name_offset +
1546 eventRecordNameLength - 1);
1547 BOOST_CHECK(eventRecordNameNullTerminator ==
'\0');
1548 std::vector<unsigned char> eventRecordNameBuffer(eventRecord.name_length - 1);
1549 std::memcpy(eventRecordNameBuffer.data(),
1552 eventRecord.name_offset +
1554 eventRecordNameBuffer.size());
1555 eventRecord.name.assign(eventRecordNameBuffer.begin(), eventRecordNameBuffer.end());
1557 uint32_t eventRecordDescriptionLength =
ReadUint32(readBuffer,
1558 eventOffset + eventRecord.description_offset);
1559 eventRecord.description_length = eventRecordDescriptionLength;
1560 unsigned char eventRecordDescriptionNullTerminator =
1563 eventRecord.description_offset +
1565 eventRecordDescriptionLength - 1);
1566 BOOST_CHECK(eventRecordDescriptionNullTerminator ==
'\0');
1567 std::vector<unsigned char> eventRecordDescriptionBuffer(eventRecord.description_length - 1);
1568 std::memcpy(eventRecordDescriptionBuffer.data(),
1571 eventRecord.description_offset +
1573 eventRecordDescriptionBuffer.size());
1574 eventRecord.description.assign(eventRecordDescriptionBuffer.begin(),
1575 eventRecordDescriptionBuffer.end());
1577 if (eventRecord.units_offset > 0)
1579 uint32_t eventRecordUnitsLength =
ReadUint32(readBuffer,
1580 eventOffset + eventRecord.units_offset);
1581 eventRecord.units_length = eventRecordUnitsLength;
1582 unsigned char eventRecordUnitsNullTerminator =
1585 eventRecord.units_offset +
1587 eventRecordUnitsLength - 1);
1588 BOOST_CHECK(eventRecordUnitsNullTerminator ==
'\0');
1589 std::vector<unsigned char> eventRecordUnitsBuffer(eventRecord.units_length - 1);
1590 std::memcpy(eventRecordUnitsBuffer.data(),
1593 eventRecord.units_offset +
1595 eventRecordUnitsBuffer.size());
1596 eventRecord.units.assign(eventRecordUnitsBuffer.begin(), eventRecordUnitsBuffer.end());
1599 categoryRecord.event_records.push_back(eventRecord);
1602 categoryRecords.push_back(categoryRecord);
1607 for (
const CategoryRecord& categoryRecord : categoryRecords)
1612 BOOST_CHECK(category->
m_Counters.size() == categoryRecord.event_count +
static_cast<size_t>(numberOfCores) -1);
1613 BOOST_CHECK(category->
m_Counters.size() == categoryRecord.event_count +
static_cast<size_t>(numberOfCores) -1);
1616 for (
const EventRecord& eventRecord : categoryRecord.event_records)
1639 const std::string deviceName =
"inv@lid dev!c€";
1640 const Device* device =
nullptr;
1641 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1657 const std::string counterSetName =
"inv@lid count€rs€t";
1659 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1675 const std::string categoryName =
"c@t€gory";
1676 const Category* category =
nullptr;
1677 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1693 const std::string deviceName =
"inv@lid dev!c€";
1694 const Device* device =
nullptr;
1695 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1700 const std::string counterSetName =
"inv@lid count€rs€t";
1702 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1707 const std::string categoryName =
"c@t€gory";
1708 const Category* category =
nullptr;
1709 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1725 const std::string deviceName =
"valid device";
1726 const Device* device =
nullptr;
1727 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1732 const std::string counterSetName =
"valid counterset";
1734 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1739 const std::string categoryName =
"category";
1740 const Category* category =
nullptr;
1741 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1746 const Counter* counter =
nullptr;
1747 BOOST_CHECK_NO_THROW(counter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1754 "counter description",
1755 std::string(
"invalid counter units"),
1758 counterSet->
m_Uid));
1771 SetActiveProfilingState(profilingStateMachine);
1776 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1780 sendThread.
Start(mockProfilingConnection);
1782 sendThread.
Start(mockProfilingConnection);
1783 sendThread.
Start(mockProfilingConnection);
1784 sendThread.
Start(mockProfilingConnection);
1785 sendThread.
Start(mockProfilingConnection);
1795 SetActiveProfilingState(profilingStateMachine);
1797 unsigned int totalWrittenSize = 0;
1802 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1803 sendThread.
Start(mockProfilingConnection);
1808 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1817 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1822 unsigned int counterDirectoryPacketSize = 32;
1823 totalWrittenSize += counterDirectoryPacketSize;
1827 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1836 unsigned int periodicCounterCapturePacketSize = 28;
1837 totalWrittenSize += periodicCounterCapturePacketSize;
1841 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1849 periodicCounterCapturePacketSize = 22;
1850 totalWrittenSize += periodicCounterCapturePacketSize;
1862 periodicCounterCapturePacketSize = 46;
1863 totalWrittenSize += periodicCounterCapturePacketSize;
1874 periodicCounterCapturePacketSize = 40;
1875 totalWrittenSize += periodicCounterCapturePacketSize;
1879 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1884 periodicCounterCapturePacketSize = 30;
1885 totalWrittenSize += periodicCounterCapturePacketSize;
1891 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1903 SetActiveProfilingState(profilingStateMachine);
1905 unsigned int totalWrittenSize = 0;
1910 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1911 sendThread.
Start(mockProfilingConnection);
1916 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1927 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1932 unsigned int counterDirectoryPacketSize = 32;
1933 totalWrittenSize += counterDirectoryPacketSize;
1938 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1947 unsigned int periodicCounterCapturePacketSize = 28;
1948 totalWrittenSize += periodicCounterCapturePacketSize;
1952 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1958 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1967 periodicCounterCapturePacketSize = 22;
1968 totalWrittenSize += periodicCounterCapturePacketSize;
1980 periodicCounterCapturePacketSize = 46;
1981 totalWrittenSize += periodicCounterCapturePacketSize;
1993 periodicCounterCapturePacketSize = 40;
1994 totalWrittenSize += periodicCounterCapturePacketSize;
1999 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
2004 periodicCounterCapturePacketSize = 30;
2005 totalWrittenSize += periodicCounterCapturePacketSize;
2021 SetActiveProfilingState(profilingStateMachine);
2023 unsigned int totalWrittenSize = 0;
2028 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
2029 sendThread.
Start(mockProfilingConnection);
2044 unsigned int counterDirectoryPacketSize =32;
2045 totalWrittenSize += counterDirectoryPacketSize;
2056 unsigned int periodicCounterCapturePacketSize = 28;
2057 totalWrittenSize += periodicCounterCapturePacketSize;
2070 periodicCounterCapturePacketSize = 22;
2071 totalWrittenSize += periodicCounterCapturePacketSize;
2083 periodicCounterCapturePacketSize = 46;
2084 totalWrittenSize += periodicCounterCapturePacketSize;
2097 periodicCounterCapturePacketSize = 40;
2098 totalWrittenSize += periodicCounterCapturePacketSize;
2105 periodicCounterCapturePacketSize = 30;
2106 totalWrittenSize += periodicCounterCapturePacketSize;
2124 SetWaitingForAckProfilingState(profilingStateMachine);
2129 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2130 sendThread.
Start(mockProfilingConnection);
2139 SetActiveProfilingState(profilingStateMachine);
2140 sendThread.
Start(mockProfilingConnection);
2147 unsigned int counterDirectoryPacketSize = 32;
2150 {PacketType::CounterDirectory, counterDirectoryPacketSize}) == 1);
2152 sendThread.
Start(mockProfilingConnection);
2163 unsigned int periodicCounterCapturePacketSize = 28;
2165 {PacketType::PeriodicCounterCapture, periodicCounterCapturePacketSize}) == 1);
2171 SetActiveProfilingState(profilingStateMachine);
2176 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2177 sendThread.
Start(mockProfilingConnection);
2185 BOOST_TEST(packetBuffer.get());
2188 BOOST_TEST(packetBuffer->GetSize() == streamMetadataPacketsize);
2191 bufferManager.
Commit(packetBuffer, streamMetadataPacketsize);
2208 BOOST_TEST(!readBuffer);
2211 unsigned int reservedSize = 0;
2212 auto reservedBuffer = bufferManager.
Reserve(512, reservedSize);
2213 BOOST_TEST(reservedSize == 512);
2214 BOOST_TEST(reservedBuffer.get());
2217 const auto metaDataPacketCount =
2220 BOOST_TEST(metaDataPacketCount >= 1);
2221 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::CounterDirectory, 32}) == 1);
2222 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::PeriodicCounterCapture, 28}) == 1);
2224 BOOST_TEST(metaDataPacketCount + 2 == writtenDataSize);
2234 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2235 sendThread.
Start(mockProfilingConnection);
2244 SetNotConnectedProfilingState(profilingStateMachine);
2249 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2250 sendThread.
Start(mockProfilingConnection);
2259 SetWaitingForAckProfilingState(profilingStateMachine);
2266 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2267 sendThread.
Start(mockProfilingConnection);
2271 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2276 BOOST_TEST(writtenDataSize >= 1);
2278 {PacketType::StreamMetaData, streamMetadataPacketsize}) == writtenDataSize);
2284 SetWaitingForAckProfilingState(profilingStateMachine);
2291 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2292 sendThread.
Start(mockProfilingConnection);
2298 sendThread.
Start(mockProfilingConnection);
2303 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::StreamMetaData, streamMetadataPacketsize}) >= 1);
2305 mockProfilingConnection.
Clear();
2308 sendThread.
Start(mockProfilingConnection);
2314 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2322 BOOST_TEST(writtenDataSize >= 1);
2324 {PacketType::StreamMetaData, streamMetadataPacketsize}) == writtenDataSize);
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
bool CreateCounterSetRecordTest(const CounterSetPtr &counterSet, CounterSetRecord &counterSetRecord, std::string &errorMessage)
std::vector< uint32_t > CounterSetRecord
ProfilingState GetCurrentState() const
const Category * RegisterCategory(const std::string &categoryName) 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
std::vector< uint32_t > DeviceRecord
std::string GetHardwareVersion()
uint64_t ReadUint64(const IPacketBufferPtr &packetBuffer, unsigned int offset)
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
std::unordered_map< uint16_t, CounterPtr > Counters
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
#define ARMNN_NO_CONVERSION_WARN_END
void SendCounterDirectoryPacket(const ICounterDirectory &counterDirectory) override
Create and write a CounterDirectoryPacket from the parameters to the buffer.
uint32_t GetStreamMetaDataPacketSize()
std::unique_ptr< Device > DevicePtr
std::string GetProcessName()
unsigned int GetCommittedSize() const
void SendStreamMetaDataPacket() override
Create and write a StreamMetaDataPacket in the buffer.
const Device * GetDevice(uint16_t uid) const override
bool CreateDeviceRecordTest(const DevicePtr &device, DeviceRecord &deviceRecord, std::string &errorMessage)
std::unique_ptr< CounterSet > CounterSetPtr
uint16_t ReadUint16(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint16_t GetCounterSetCount() const override
uint8_t ReadUint8(const IPacketBufferPtr &packetBuffer, unsigned int offset)
unsigned long GetWrittenDataSize()
std::string GetSoftwareInfo()
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
constexpr uint32_t EncodeVersion(uint32_t major, uint32_t minor, uint32_t patch)
bool CreateEventRecordTest(const CounterPtr &counter, EventRecord &eventRecord, std::string &errorMessage)
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())
uint16_t GetDeviceCount() const override
std::vector< uint32_t > EventRecord
uint16_t GetCategoryCount() const override
void MarkRead(IPacketBufferPtr &packetBuffer) override
std::shared_ptr< Counter > CounterPtr
void Commit(IPacketBufferPtr &packetBuffer, unsigned int size, bool notifyConsumer=true) override
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const IndexValuePairsVector &values) override
Create and write a PeriodicCounterCapturePacket from the parameters to the buffer.
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0)
unsigned int GetReadableSize() const
IPacketBufferPtr GetReadableBuffer() override
#define ARMNN_FALLTHROUGH
#define ARMNN_ASSERT(COND)
IPacketBufferPtr Reserve(unsigned int requestedSize, unsigned int &reservedSize) 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)
const Category * RegisterCategory(const std::string &categoryName)
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
void SendPeriodicCounterCapturePacket(uint64_t timestamp, const std::vector< CounterValue > &values) override
IPacketBufferPtr GetReadableBuffer() override
#define MAX_METADATA_PACKET_LENGTH
uint16_t GetCounterCount() const override
uint32_t ReadUint32(const IPacketBufferPtr &packetBuffer, unsigned int offset)
uint16_t GetCounterSetCount() const override
#define ARMNN_NO_CONVERSION_WARN_BEGIN
std::string GetSoftwareVersion()
std::vector< uint16_t > m_Counters
const Counter * GetCounter(uint16_t uid) const override
BOOST_AUTO_TEST_SUITE_END()
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...
void SetReadyToRead() override
Set a "ready to read" flag in the buffer to notify the reading thread to start reading it...
std::string m_Description
const Device * RegisterDevice(const std::string &deviceName, uint16_t cores=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
bool CreateCategoryRecordTest(const CategoryPtr &category, const Counters &counters, CategoryRecord &categoryRecord, std::string &errorMessage)
void SendPeriodicCounterSelectionPacket(uint32_t capturePeriod, const std::vector< uint16_t > &selectedCounterIds) override
Create and write a PeriodicCounterSelectionPacket from the parameters to the buffer.
std::vector< uint32_t > CategoryRecord
std::unique_ptr< Category > CategoryPtr
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0)
uint16_t GetCounterCount() const override
void TransitionToState(ProfilingState newState)
long CheckForPacket(const std::pair< PacketType, uint32_t > packetInfo)
const CounterSet * RegisterCounterSet(const std::string &counterSetName, uint16_t count=0, const Optional< std::string > &parentCategoryName=EmptyOptional()) override
const CounterSet * GetCounterSet(uint16_t uid) const override
void Stop(bool rethrowSendThreadExceptions=true) override
Stop the thread.
unsigned int GetReadSize() const
void Start(IProfilingConnection &profilingConnection) override
Start the thread.
uint16_t GetDeviceCount() const override