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);
290 uint32_t sizeUint32 =
numeric_cast<uint32_t>(
sizeof(uint32_t));
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 const CategoryPtr category = std::make_unique<Category>(categoryName);
862 BOOST_ASSERT(category);
863 category->m_Counters = { 11u, 23u, 5670u };
867 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
879 counters.insert(std::make_pair<uint16_t, CounterPtr>(23,
887 "the second counter",
891 counters.insert(std::make_pair<uint16_t, CounterPtr>(5670,
898 "and this is number 3",
903 Counter* counter1 = counters.find(11)->second.get();
904 Counter* counter2 = counters.find(23)->second.get();
905 Counter* counter3 = counters.find(5670)->second.get();
906 BOOST_ASSERT(counter1);
907 BOOST_ASSERT(counter2);
908 BOOST_ASSERT(counter3);
913 std::string errorMessage;
921 uint16_t categoryRecordWord1[]
923 static_cast<uint16_t
>(categoryRecord[0] >> 16),
924 static_cast<uint16_t>(categoryRecord[0])
926 BOOST_CHECK(categoryRecordWord1[0] == categoryEventCount);
932 uint32_t eventPointerTableOffset = 0;
933 uint32_t categoryNameOffset = eventPointerTableOffset +
937 BOOST_CHECK(categoryRecord[1] == eventPointerTableOffset);
938 BOOST_CHECK(categoryRecord[2] == categoryNameOffset);
940 auto categoryRecordPool =
reinterpret_cast<unsigned char*
>(categoryRecord.data() + 3u);
943 uint32_t eventRecord0Offset = categoryRecordPool[eventPointerTableOffset + 0 *
uint32_t_size];
944 uint32_t eventRecord1Offset = categoryRecordPool[eventPointerTableOffset + 1 *
uint32_t_size];
945 uint32_t eventRecord2Offset = categoryRecordPool[eventPointerTableOffset + 2 *
uint32_t_size];
951 BOOST_CHECK(categoryRecordPool[categoryNameOffset] == categoryName.size() + 1);
957 categoryName.size()) == 0);
959 BOOST_CHECK(categoryRecordPool[categoryNameOffset + uint32_t_size + categoryName.size()] ==
'\0');
965 uint16_t eventRecord0Word0[2] = { 0u, 0u };
966 std::memcpy(eventRecord0Word0, categoryRecordPool + eventRecord0Offset,
sizeof(eventRecord0Word0));
971 uint32_t counter1NameOffset = 0;
972 std::memcpy(&counter1NameOffset, categoryRecordPool + eventRecord0Offset + 5u * uint32_t_size, uint32_t_size);
975 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
978 ] == counter1->
m_Name.size() + 1);
987 counter1->
m_Name.size()) == 0);
989 BOOST_CHECK(categoryRecordPool[eventRecord0Offset +
997 uint32_t counter2NameOffset = 0;
998 std::memcpy(&counter2NameOffset, categoryRecordPool + eventRecord1Offset + 5u * uint32_t_size, uint32_t_size);
1001 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1002 8u * uint32_t_size +
1004 ] == counter2->
m_Name.size() + 1);
1008 eventRecord1Offset +
1009 8u * uint32_t_size +
1010 counter2NameOffset +
1013 counter2->
m_Name.size()) == 0);
1015 BOOST_CHECK(categoryRecordPool[eventRecord1Offset +
1016 8u * uint32_t_size +
1017 counter2NameOffset +
1023 uint32_t counter3NameOffset = 0;
1024 std::memcpy(&counter3NameOffset, categoryRecordPool + eventRecord2Offset + 5u * uint32_t_size, uint32_t_size);
1027 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1028 8u * uint32_t_size +
1030 ] == counter3->
m_Name.size() + 1);
1034 eventRecord2Offset +
1035 8u * uint32_t_size +
1036 counter3NameOffset +
1039 counter3->
m_Name.size()) == 0);
1041 BOOST_CHECK(categoryRecordPool[eventRecord2Offset +
1042 8u * uint32_t_size +
1043 counter3NameOffset +
1055 const std::string categoryName =
"some invalid category";
1056 const CategoryPtr category = std::make_unique<Category>(categoryName);
1062 std::string errorMessage;
1076 const std::string categoryName =
"some_category";
1077 const CategoryPtr category = std::make_unique<Category>(categoryName);
1079 category->m_Counters = { 11u, 23u, 5670u };
1083 counters.insert(std::make_pair<uint16_t, CounterPtr>(11,
1091 "the first counter",
1096 Counter* counter1 = counters.find(11)->second.get();
1101 std::string errorMessage;
1115 const std::string device1Name =
"device1";
1116 const Device* device1 =
nullptr;
1117 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1122 const std::string device2Name =
"device2";
1123 const Device* device2 =
nullptr;
1124 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1141 const std::string device1Name =
"device1";
1142 const Device* device1 =
nullptr;
1143 BOOST_CHECK_NO_THROW(device1 = counterDirectory.
RegisterDevice(device1Name, 3));
1148 const std::string device2Name =
"device2";
1149 const Device* device2 =
nullptr;
1150 BOOST_CHECK_NO_THROW(device2 = counterDirectory.
RegisterDevice(device2Name));
1155 const std::string counterSet1Name =
"counterset1";
1157 BOOST_CHECK_NO_THROW(counterSet1 = counterDirectory.
RegisterCounterSet(counterSet1Name));
1162 const std::string category1Name =
"category1";
1163 const Category* category1 =
nullptr;
1164 BOOST_CHECK_NO_THROW(category1 = counterDirectory.
RegisterCategory(category1Name));
1169 const std::string category2Name =
"category2";
1170 const Category* category2 =
nullptr;
1171 BOOST_CHECK_NO_THROW(category2 = counterDirectory.
RegisterCategory(category2Name));
1175 uint16_t numberOfCores = 3;
1178 const Counter* counter1 =
nullptr;
1179 BOOST_CHECK_NO_THROW(counter1 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1186 "counter1description",
1187 std::string(
"counter1units"),
1193 const Counter* counter2 =
nullptr;
1194 BOOST_CHECK_NO_THROW(counter2 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1201 "counter2description",
1202 std::string(
"counter2units"),
1210 const Counter* counter3 =
nullptr;
1211 BOOST_CHECK_NO_THROW(counter3 = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1218 "counter3description",
1222 counterSet1->
m_Uid));
1235 uint32_t packetHeaderWord0 =
ReadUint32(readBuffer, 0);
1236 uint32_t packetHeaderWord1 =
ReadUint32(readBuffer, 4);
1237 BOOST_TEST(((packetHeaderWord0 >> 26) & 0x3F) == 0);
1238 BOOST_TEST(((packetHeaderWord0 >> 16) & 0x3FF) == 2);
1239 BOOST_TEST(packetHeaderWord1 == 928);
1242 uint32_t bodyHeaderWord0 =
ReadUint32(readBuffer, 8);
1243 uint32_t bodyHeaderWord1 =
ReadUint32(readBuffer, 12);
1244 uint32_t bodyHeaderWord2 =
ReadUint32(readBuffer, 16);
1245 uint32_t bodyHeaderWord3 =
ReadUint32(readBuffer, 20);
1246 uint32_t bodyHeaderWord4 =
ReadUint32(readBuffer, 24);
1247 uint32_t bodyHeaderWord5 =
ReadUint32(readBuffer, 28);
1248 uint16_t deviceRecordCount =
static_cast<uint16_t
>(bodyHeaderWord0 >> 16);
1249 uint16_t counterSetRecordCount =
static_cast<uint16_t
>(bodyHeaderWord2 >> 16);
1250 uint16_t categoryRecordCount =
static_cast<uint16_t
>(bodyHeaderWord4 >> 16);
1251 BOOST_TEST(deviceRecordCount == 2);
1252 BOOST_TEST(bodyHeaderWord1 == 0);
1253 BOOST_TEST(counterSetRecordCount == 1);
1254 BOOST_TEST(bodyHeaderWord3 == 8);
1255 BOOST_TEST(categoryRecordCount == 2);
1256 BOOST_TEST(bodyHeaderWord5 == 12);
1259 uint32_t deviceRecordOffset0 =
ReadUint32(readBuffer, 32);
1260 uint32_t deviceRecordOffset1 =
ReadUint32(readBuffer, 36);
1261 BOOST_TEST(deviceRecordOffset0 == 0);
1262 BOOST_TEST(deviceRecordOffset1 == 20);
1265 uint32_t counterSetRecordOffset0 =
ReadUint32(readBuffer, 40);
1266 BOOST_TEST(counterSetRecordOffset0 == 40);
1269 uint32_t categoryRecordOffset0 =
ReadUint32(readBuffer, 44);
1270 uint32_t categoryRecordOffset1 =
ReadUint32(readBuffer, 48);
1271 BOOST_TEST(categoryRecordOffset0 == 64);
1272 BOOST_TEST(categoryRecordOffset1 == 472);
1276 uint32_t packetBodyPoolOffset = 2u * uint32_t_size +
1277 6u * uint32_t_size +
1278 deviceRecordCount * uint32_t_size +
1279 counterSetRecordCount * uint32_t_size +
1287 uint32_t name_offset;
1288 uint32_t name_length;
1291 std::vector<DeviceRecord> deviceRecords;
1292 uint32_t deviceRecordsPointerTableOffset = 2u * uint32_t_size +
1293 6u * uint32_t_size +
1296 const unsigned char* readData = readBuffer->GetReadableData();
1298 for (uint32_t i = 0; i < deviceRecordCount; i++)
1301 uint32_t deviceRecordOffset =
ReadUint32(readBuffer, deviceRecordsPointerTableOffset + i * uint32_t_size);
1304 uint32_t deviceRecordWord0 =
ReadUint32(readBuffer,
1305 packetBodyPoolOffset + deviceRecordOffset + 0 * uint32_t_size);
1306 uint32_t deviceRecordWord1 =
ReadUint32(readBuffer,
1307 packetBodyPoolOffset + deviceRecordOffset + 1 * uint32_t_size);
1308 DeviceRecord deviceRecord;
1309 deviceRecord.uid =
static_cast<uint16_t
>(deviceRecordWord0 >> 16);
1310 deviceRecord.cores =
static_cast<uint16_t
>(deviceRecordWord0);
1311 deviceRecord.name_offset = deviceRecordWord1;
1313 uint32_t deviceRecordPoolOffset = packetBodyPoolOffset +
1314 deviceRecordOffset +
1316 deviceRecord.name_offset;
1317 uint32_t deviceRecordNameLength =
ReadUint32(readBuffer, deviceRecordPoolOffset);
1318 deviceRecord.name_length = deviceRecordNameLength;
1319 unsigned char deviceRecordNameNullTerminator =
1320 ReadUint8(readBuffer, deviceRecordPoolOffset + uint32_t_size + deviceRecordNameLength - 1);
1321 BOOST_CHECK(deviceRecordNameNullTerminator ==
'\0');
1322 std::vector<unsigned char> deviceRecordNameBuffer(deviceRecord.name_length - 1);
1323 std::memcpy(deviceRecordNameBuffer.data(),
1324 readData + deviceRecordPoolOffset +
uint32_t_size, deviceRecordNameBuffer.size());
1325 deviceRecord.name.assign(deviceRecordNameBuffer.begin(), deviceRecordNameBuffer.end());
1327 deviceRecords.push_back(deviceRecord);
1332 for (
const DeviceRecord& deviceRecord : deviceRecords)
1342 struct CounterSetRecord
1346 uint32_t name_offset;
1347 uint32_t name_length;
1350 std::vector<CounterSetRecord> counterSetRecords;
1351 uint32_t counterSetRecordsPointerTableOffset = 2u * uint32_t_size +
1352 6u * uint32_t_size +
1354 for (uint32_t i = 0; i < counterSetRecordCount; i++)
1357 uint32_t counterSetRecordOffset =
ReadUint32(readBuffer,
1358 counterSetRecordsPointerTableOffset + i * uint32_t_size);
1361 uint32_t counterSetRecordWord0 =
ReadUint32(readBuffer,
1362 packetBodyPoolOffset + counterSetRecordOffset + 0 * uint32_t_size);
1363 uint32_t counterSetRecordWord1 =
ReadUint32(readBuffer,
1364 packetBodyPoolOffset + counterSetRecordOffset + 1 * uint32_t_size);
1365 CounterSetRecord counterSetRecord;
1366 counterSetRecord.uid =
static_cast<uint16_t
>(counterSetRecordWord0 >> 16);
1367 counterSetRecord.count =
static_cast<uint16_t
>(counterSetRecordWord0);
1368 counterSetRecord.name_offset = counterSetRecordWord1;
1370 uint32_t counterSetRecordPoolOffset = packetBodyPoolOffset +
1371 counterSetRecordOffset +
1373 counterSetRecord.name_offset;
1374 uint32_t counterSetRecordNameLength =
ReadUint32(readBuffer, counterSetRecordPoolOffset);
1375 counterSetRecord.name_length = counterSetRecordNameLength;
1376 unsigned char counterSetRecordNameNullTerminator =
1377 ReadUint8(readBuffer, counterSetRecordPoolOffset + uint32_t_size + counterSetRecordNameLength - 1);
1378 BOOST_CHECK(counterSetRecordNameNullTerminator ==
'\0');
1379 std::vector<unsigned char> counterSetRecordNameBuffer(counterSetRecord.name_length - 1);
1380 std::memcpy(counterSetRecordNameBuffer.data(),
1381 readData + counterSetRecordPoolOffset +
uint32_t_size, counterSetRecordNameBuffer.size());
1382 counterSetRecord.name.assign(counterSetRecordNameBuffer.begin(), counterSetRecordNameBuffer.end());
1384 counterSetRecords.push_back(counterSetRecord);
1389 for (
const CounterSetRecord& counterSetRecord : counterSetRecords)
1401 uint16_t counter_uid;
1402 uint16_t max_counter_uid;
1404 uint16_t counter_set;
1405 uint16_t counter_class;
1406 uint16_t interpolation;
1408 uint32_t name_offset;
1409 uint32_t name_length;
1411 uint32_t description_offset;
1412 uint32_t description_length;
1413 std::string description;
1414 uint32_t units_offset;
1415 uint32_t units_length;
1419 struct CategoryRecord
1421 uint16_t event_count;
1422 uint32_t event_pointer_table_offset;
1423 uint32_t name_offset;
1424 uint32_t name_length;
1426 std::vector<uint32_t> event_pointer_table;
1427 std::vector<EventRecord> event_records;
1429 std::vector<CategoryRecord> categoryRecords;
1430 uint32_t categoryRecordsPointerTableOffset = 2u * uint32_t_size +
1431 6u * uint32_t_size +
1433 for (uint32_t i = 0; i < categoryRecordCount; i++)
1436 uint32_t categoryRecordOffset =
ReadUint32(readBuffer, categoryRecordsPointerTableOffset + i * uint32_t_size);
1439 uint32_t categoryRecordWord1 =
ReadUint32(readBuffer,
1440 packetBodyPoolOffset + categoryRecordOffset + 0 * uint32_t_size);
1441 uint32_t categoryRecordWord2 =
ReadUint32(readBuffer,
1442 packetBodyPoolOffset + categoryRecordOffset + 1 * uint32_t_size);
1443 uint32_t categoryRecordWord3 =
ReadUint32(readBuffer,
1444 packetBodyPoolOffset + categoryRecordOffset + 2 * uint32_t_size);
1445 CategoryRecord categoryRecord;
1446 categoryRecord.event_count =
static_cast<uint16_t
>(categoryRecordWord1 >> 16);
1447 categoryRecord.event_pointer_table_offset = categoryRecordWord2;
1448 categoryRecord.name_offset = categoryRecordWord3;
1450 uint32_t categoryRecordPoolOffset = packetBodyPoolOffset +
1451 categoryRecordOffset +
1454 uint32_t categoryRecordNameLength =
ReadUint32(readBuffer,
1455 categoryRecordPoolOffset + categoryRecord.name_offset);
1456 categoryRecord.name_length = categoryRecordNameLength;
1457 unsigned char categoryRecordNameNullTerminator =
1459 categoryRecordPoolOffset +
1460 categoryRecord.name_offset +
1462 categoryRecordNameLength - 1);
1463 BOOST_CHECK(categoryRecordNameNullTerminator ==
'\0');
1464 std::vector<unsigned char> categoryRecordNameBuffer(categoryRecord.name_length - 1);
1465 std::memcpy(categoryRecordNameBuffer.data(),
1467 categoryRecordPoolOffset +
1468 categoryRecord.name_offset +
1470 categoryRecordNameBuffer.size());
1471 categoryRecord.name.assign(categoryRecordNameBuffer.begin(), categoryRecordNameBuffer.end());
1473 categoryRecord.event_pointer_table.resize(categoryRecord.event_count);
1474 for (uint32_t eventIndex = 0; eventIndex < categoryRecord.event_count; eventIndex++)
1476 uint32_t eventRecordOffset =
ReadUint32(readBuffer,
1477 categoryRecordPoolOffset +
1478 categoryRecord.event_pointer_table_offset +
1479 eventIndex * uint32_t_size);
1480 categoryRecord.event_pointer_table[eventIndex] = eventRecordOffset;
1483 uint32_t eventRecordWord0 =
ReadUint32(readBuffer,
1484 categoryRecordPoolOffset + eventRecordOffset + 0 * uint32_t_size);
1485 uint32_t eventRecordWord1 =
ReadUint32(readBuffer,
1486 categoryRecordPoolOffset + eventRecordOffset + 1 * uint32_t_size);
1487 uint32_t eventRecordWord2 =
ReadUint32(readBuffer,
1488 categoryRecordPoolOffset + eventRecordOffset + 2 * uint32_t_size);
1489 uint64_t eventRecordWord34 =
ReadUint64(readBuffer,
1490 categoryRecordPoolOffset + eventRecordOffset + 3 * uint32_t_size);
1491 uint32_t eventRecordWord5 =
ReadUint32(readBuffer,
1492 categoryRecordPoolOffset + eventRecordOffset + 5 * uint32_t_size);
1493 uint32_t eventRecordWord6 =
ReadUint32(readBuffer,
1494 categoryRecordPoolOffset + eventRecordOffset + 6 * uint32_t_size);
1495 uint32_t eventRecordWord7 =
ReadUint32(readBuffer,
1496 categoryRecordPoolOffset + eventRecordOffset + 7 * uint32_t_size);
1497 EventRecord eventRecord;
1498 eventRecord.counter_uid =
static_cast<uint16_t
>(eventRecordWord0);
1499 eventRecord.max_counter_uid =
static_cast<uint16_t
>(eventRecordWord0 >> 16);
1500 eventRecord.device =
static_cast<uint16_t
>(eventRecordWord1 >> 16);
1501 eventRecord.counter_set =
static_cast<uint16_t
>(eventRecordWord1);
1502 eventRecord.counter_class =
static_cast<uint16_t
>(eventRecordWord2 >> 16);
1503 eventRecord.interpolation =
static_cast<uint16_t
>(eventRecordWord2);
1504 std::memcpy(&eventRecord.multiplier, &eventRecordWord34,
sizeof(eventRecord.multiplier));
1505 eventRecord.name_offset =
static_cast<uint32_t
>(eventRecordWord5);
1506 eventRecord.description_offset =
static_cast<uint32_t
>(eventRecordWord6);
1507 eventRecord.units_offset =
static_cast<uint32_t
>(eventRecordWord7);
1509 uint32_t eventRecordPoolOffset = categoryRecordPoolOffset +
1513 uint32_t eventRecordNameLength =
ReadUint32(readBuffer,
1514 eventRecordPoolOffset + eventRecord.name_offset);
1515 eventRecord.name_length = eventRecordNameLength;
1516 unsigned char eventRecordNameNullTerminator =
1518 eventRecordPoolOffset +
1519 eventRecord.name_offset +
1521 eventRecordNameLength - 1);
1522 BOOST_CHECK(eventRecordNameNullTerminator ==
'\0');
1523 std::vector<unsigned char> eventRecordNameBuffer(eventRecord.name_length - 1);
1524 std::memcpy(eventRecordNameBuffer.data(),
1526 eventRecordPoolOffset +
1527 eventRecord.name_offset +
1529 eventRecordNameBuffer.size());
1530 eventRecord.name.assign(eventRecordNameBuffer.begin(), eventRecordNameBuffer.end());
1532 uint32_t eventRecordDescriptionLength =
ReadUint32(readBuffer,
1533 eventRecordPoolOffset + eventRecord.description_offset);
1534 eventRecord.description_length = eventRecordDescriptionLength;
1535 unsigned char eventRecordDescriptionNullTerminator =
1537 eventRecordPoolOffset +
1538 eventRecord.description_offset +
1540 eventRecordDescriptionLength - 1);
1541 BOOST_CHECK(eventRecordDescriptionNullTerminator ==
'\0');
1542 std::vector<unsigned char> eventRecordDescriptionBuffer(eventRecord.description_length - 1);
1543 std::memcpy(eventRecordDescriptionBuffer.data(),
1545 eventRecordPoolOffset +
1546 eventRecord.description_offset +
1548 eventRecordDescriptionBuffer.size());
1549 eventRecord.description.assign(eventRecordDescriptionBuffer.begin(),
1550 eventRecordDescriptionBuffer.end());
1552 if (eventRecord.units_offset > 0)
1554 uint32_t eventRecordUnitsLength =
ReadUint32(readBuffer,
1555 eventRecordPoolOffset + eventRecord.units_offset);
1556 eventRecord.units_length = eventRecordUnitsLength;
1557 unsigned char eventRecordUnitsNullTerminator =
1559 eventRecordPoolOffset +
1560 eventRecord.units_offset +
1562 eventRecordUnitsLength - 1);
1563 BOOST_CHECK(eventRecordUnitsNullTerminator ==
'\0');
1564 std::vector<unsigned char> eventRecordUnitsBuffer(eventRecord.units_length - 1);
1565 std::memcpy(eventRecordUnitsBuffer.data(),
1567 eventRecordPoolOffset +
1568 eventRecord.units_offset +
1570 eventRecordUnitsBuffer.size());
1571 eventRecord.units.assign(eventRecordUnitsBuffer.begin(), eventRecordUnitsBuffer.end());
1574 categoryRecord.event_records.push_back(eventRecord);
1577 categoryRecords.push_back(categoryRecord);
1582 for (
const CategoryRecord& categoryRecord : categoryRecords)
1590 for (
const EventRecord& eventRecord : categoryRecord.event_records)
1613 const std::string deviceName =
"inv@lid dev!c€";
1614 const Device* device =
nullptr;
1615 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1631 const std::string counterSetName =
"inv@lid count€rs€t";
1633 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1649 const std::string categoryName =
"c@t€gory";
1650 const Category* category =
nullptr;
1651 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1667 const std::string deviceName =
"inv@lid dev!c€";
1668 const Device* device =
nullptr;
1669 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1674 const std::string counterSetName =
"inv@lid count€rs€t";
1676 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1681 const std::string categoryName =
"c@t€gory";
1682 const Category* category =
nullptr;
1683 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1699 const std::string deviceName =
"valid device";
1700 const Device* device =
nullptr;
1701 BOOST_CHECK_NO_THROW(device = counterDirectory.
RegisterDevice(deviceName, 3));
1706 const std::string counterSetName =
"valid counterset";
1708 BOOST_CHECK_NO_THROW(counterSet = counterDirectory.
RegisterCounterSet(counterSetName));
1713 const std::string categoryName =
"category";
1714 const Category* category =
nullptr;
1715 BOOST_CHECK_NO_THROW(category = counterDirectory.
RegisterCategory(categoryName));
1720 const Counter* counter =
nullptr;
1721 BOOST_CHECK_NO_THROW(counter = counterDirectory.
RegisterCounter(armnn::profiling::BACKEND_ID,
1728 "counter description",
1729 std::string(
"invalid counter units"),
1732 counterSet->
m_Uid));
1745 SetActiveProfilingState(profilingStateMachine);
1750 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1754 sendThread.
Start(mockProfilingConnection);
1756 sendThread.
Start(mockProfilingConnection);
1757 sendThread.
Start(mockProfilingConnection);
1758 sendThread.
Start(mockProfilingConnection);
1759 sendThread.
Start(mockProfilingConnection);
1769 SetActiveProfilingState(profilingStateMachine);
1771 unsigned int totalWrittenSize = 0;
1776 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1777 sendThread.
Start(mockProfilingConnection);
1782 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1789 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
1790 unsigned int streamMetadataPacketsize = 118 + processNameSize;
1791 totalWrittenSize += streamMetadataPacketsize;
1795 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1800 unsigned int counterDirectoryPacketSize = 32;
1801 totalWrittenSize += counterDirectoryPacketSize;
1805 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1814 unsigned int periodicCounterCapturePacketSize = 28;
1815 totalWrittenSize += periodicCounterCapturePacketSize;
1819 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1827 periodicCounterCapturePacketSize = 22;
1828 totalWrittenSize += periodicCounterCapturePacketSize;
1840 periodicCounterCapturePacketSize = 46;
1841 totalWrittenSize += periodicCounterCapturePacketSize;
1852 periodicCounterCapturePacketSize = 40;
1853 totalWrittenSize += periodicCounterCapturePacketSize;
1857 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1862 periodicCounterCapturePacketSize = 30;
1863 totalWrittenSize += periodicCounterCapturePacketSize;
1869 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1881 SetActiveProfilingState(profilingStateMachine);
1883 unsigned int totalWrittenSize = 0;
1888 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
1889 sendThread.
Start(mockProfilingConnection);
1894 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1903 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
1904 unsigned int streamMetadataPacketsize = 118 + processNameSize;
1905 totalWrittenSize += streamMetadataPacketsize;
1909 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1914 unsigned int counterDirectoryPacketSize = 32;
1915 totalWrittenSize += counterDirectoryPacketSize;
1920 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1929 unsigned int periodicCounterCapturePacketSize = 28;
1930 totalWrittenSize += periodicCounterCapturePacketSize;
1934 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1940 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1949 periodicCounterCapturePacketSize = 22;
1950 totalWrittenSize += periodicCounterCapturePacketSize;
1962 periodicCounterCapturePacketSize = 46;
1963 totalWrittenSize += periodicCounterCapturePacketSize;
1975 periodicCounterCapturePacketSize = 40;
1976 totalWrittenSize += periodicCounterCapturePacketSize;
1981 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_UNTIL_READABLE_MS));
1986 periodicCounterCapturePacketSize = 30;
1987 totalWrittenSize += periodicCounterCapturePacketSize;
2003 SetActiveProfilingState(profilingStateMachine);
2005 unsigned int totalWrittenSize = 0;
2010 SendThread sendThread(profilingStateMachine, mockStreamCounterBuffer, sendCounterPacket);
2011 sendThread.
Start(mockProfilingConnection);
2022 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2023 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2024 totalWrittenSize += streamMetadataPacketsize;
2030 unsigned int counterDirectoryPacketSize =32;
2031 totalWrittenSize += counterDirectoryPacketSize;
2042 unsigned int periodicCounterCapturePacketSize = 28;
2043 totalWrittenSize += periodicCounterCapturePacketSize;
2056 periodicCounterCapturePacketSize = 22;
2057 totalWrittenSize += periodicCounterCapturePacketSize;
2069 periodicCounterCapturePacketSize = 46;
2070 totalWrittenSize += periodicCounterCapturePacketSize;
2083 periodicCounterCapturePacketSize = 40;
2084 totalWrittenSize += periodicCounterCapturePacketSize;
2091 periodicCounterCapturePacketSize = 30;
2092 totalWrittenSize += periodicCounterCapturePacketSize;
2110 SetWaitingForAckProfilingState(profilingStateMachine);
2115 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2116 sendThread.
Start(mockProfilingConnection);
2119 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2120 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2127 SetActiveProfilingState(profilingStateMachine);
2128 sendThread.
Start(mockProfilingConnection);
2135 unsigned int counterDirectoryPacketSize = 32;
2138 {PacketType::CounterDirectory, counterDirectoryPacketSize}) == 1);
2140 sendThread.
Start(mockProfilingConnection);
2151 unsigned int periodicCounterCapturePacketSize = 28;
2153 {PacketType::PeriodicCounterCapture, periodicCounterCapturePacketSize}) == 1);
2159 SetActiveProfilingState(profilingStateMachine);
2164 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket, -1);
2165 sendThread.
Start(mockProfilingConnection);
2173 BOOST_TEST(packetBuffer.get());
2176 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2177 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2178 BOOST_TEST(packetBuffer->GetSize() == streamMetadataPacketsize);
2181 bufferManager.
Commit(packetBuffer, streamMetadataPacketsize);
2198 BOOST_TEST(!readBuffer);
2201 unsigned int reservedSize = 0;
2202 auto reservedBuffer = bufferManager.
Reserve(512, reservedSize);
2203 BOOST_TEST(reservedSize == 512);
2204 BOOST_TEST(reservedBuffer.get());
2207 const auto metaDataPacketCount =
2210 BOOST_TEST(metaDataPacketCount >= 1);
2211 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::CounterDirectory, 32}) == 1);
2212 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::PeriodicCounterCapture, 28}) == 1);
2214 BOOST_TEST(metaDataPacketCount + 2 == writtenDataSize);
2224 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2225 sendThread.
Start(mockProfilingConnection);
2234 SetNotConnectedProfilingState(profilingStateMachine);
2239 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2240 sendThread.
Start(mockProfilingConnection);
2249 SetWaitingForAckProfilingState(profilingStateMachine);
2253 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2254 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2259 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2260 sendThread.
Start(mockProfilingConnection);
2264 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2269 BOOST_TEST(writtenDataSize >= 1);
2271 {PacketType::StreamMetaData, streamMetadataPacketsize}) == writtenDataSize);
2277 SetWaitingForAckProfilingState(profilingStateMachine);
2281 unsigned int processNameSize = processName.empty() ? 0 :
boost::numeric_cast<
unsigned int>(processName.size()) + 1;
2282 unsigned int streamMetadataPacketsize = 118 + processNameSize;
2287 SendThread sendThread(profilingStateMachine, bufferManager, sendCounterPacket);
2288 sendThread.
Start(mockProfilingConnection);
2294 sendThread.
Start(mockProfilingConnection);
2299 BOOST_TEST(mockProfilingConnection.
CheckForPacket({PacketType::StreamMetaData, streamMetadataPacketsize}) >= 1);
2301 mockProfilingConnection.
Clear();
2304 sendThread.
Start(mockProfilingConnection);
2310 BOOST_CHECK_NO_THROW(sendThread.
Stop());
2318 BOOST_TEST(writtenDataSize >= 1);
2320 {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.
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
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)
static const unsigned int PIPE_MAGIC
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