aboutsummaryrefslogtreecommitdiff
path: root/src/profiling/DirectoryCaptureCommandHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/profiling/DirectoryCaptureCommandHandler.cpp')
-rw-r--r--src/profiling/DirectoryCaptureCommandHandler.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/profiling/DirectoryCaptureCommandHandler.cpp b/src/profiling/DirectoryCaptureCommandHandler.cpp
index 93cdde736e..23221fb74e 100644
--- a/src/profiling/DirectoryCaptureCommandHandler.cpp
+++ b/src/profiling/DirectoryCaptureCommandHandler.cpp
@@ -45,6 +45,7 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
// Body header word 1:
// 0:31 [32] device_records_pointer_table_offset: offset to the device_records_pointer_table
// The offset is always zero here, as the device record pointer table field is always the first item in the pool
+ const uint32_t deviceRecordsPointerTableOffset = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
// Body header word 2:
@@ -56,7 +57,7 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
// Body header word 3:
// 0:31 [32] counter_set_pointer_table_offset: offset to the counter_set_pointer_table
- // counterPointerTableSetOffset = profiling::ReadUint32(data, offset);
+ const uint32_t counterPointerTableSetOffset = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
// Body header word 4:
@@ -68,31 +69,35 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
// Body header word 5:
// 0:31 [32] categories_pointer_table_offset: offset to the categories_pointer_table
- // categoriesPointerTableOffset = profiling::ReadUint32(data, offset);
+ const uint32_t categoriesPointerTableOffset = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
std::vector<uint32_t> deviceRecordOffsets(deviceRecordCount);
std::vector<uint32_t> counterSetOffsets(counterSetRecordCount);
std::vector<uint32_t> categoryOffsets(categoryRecordCount);
+ offset = deviceRecordsPointerTableOffset;
for (uint32_t i = 0; i < deviceRecordCount; ++i)
{
deviceRecordOffsets[i] = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
}
+ offset = counterPointerTableSetOffset;
for (uint32_t i = 0; i < counterSetRecordCount; ++i)
{
counterSetOffsets[i] = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
}
+ offset = categoriesPointerTableOffset;
for (uint32_t i = 0; i < categoryRecordCount; ++i)
{
categoryOffsets[i] = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
}
+ offset = deviceRecordsPointerTableOffset;
for (uint32_t deviceIndex = 0; deviceIndex < deviceRecordCount; ++deviceIndex)
{
uint32_t deviceRecordOffset = offset + deviceRecordOffsets[deviceIndex];
@@ -108,15 +113,14 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
// Offset from the beginning of the device record pool to the name field.
uint32_t nameOffset = profiling::ReadUint32(data, deviceRecordOffset);
- deviceRecordOffset += uint32_t_size;
- deviceRecordOffset += uint32_t_size;
- deviceRecordOffset += nameOffset;
+ deviceRecordOffset = deviceRecordsPointerTableOffset + nameOffset;
const std::string& deviceName = GetStringNameFromBuffer(data, deviceRecordOffset);
const Device* registeredDevice = m_CounterDirectory.RegisterDevice(deviceName, deviceCores);
m_UidTranslation[registeredDevice->m_Uid] = deviceUid;
}
+ offset = counterPointerTableSetOffset;
for (uint32_t counterSetIndex = 0; counterSetIndex < counterSetRecordCount; ++counterSetIndex)
{
uint32_t counterSetOffset = offset + counterSetOffsets[counterSetIndex];
@@ -140,7 +144,7 @@ void DirectoryCaptureCommandHandler::ParseData(const armnn::profiling::Packet& p
m_CounterDirectory.RegisterCounterSet(GetStringNameFromBuffer(data, counterSetOffset), counterSetCount);
m_UidTranslation[counterSet->m_Uid] = counterSetUid;
}
- ReadCategoryRecords(data, offset, categoryOffsets);
+ ReadCategoryRecords(data, categoriesPointerTableOffset, categoryOffsets);
}
void DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* const data,
@@ -172,7 +176,7 @@ void DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* co
std::vector<uint32_t> eventRecordsOffsets(eventCount);
- eventPointerTableOffset += categoryRecordOffset;
+ eventPointerTableOffset += offset + categoryOffsets[categoryIndex];
for (uint32_t eventIndex = 0; eventIndex < eventCount; ++eventIndex)
{
@@ -181,11 +185,10 @@ void DirectoryCaptureCommandHandler::ReadCategoryRecords(const unsigned char* co
}
const std::vector<CounterDirectoryEventRecord>& eventRecords =
- ReadEventRecords(data, categoryRecordOffset, eventRecordsOffsets);
- categoryRecordOffset += uint32_t_size;
+ ReadEventRecords(data, eventPointerTableOffset, eventRecordsOffsets);
const Category* category = m_CounterDirectory.RegisterCategory(
- GetStringNameFromBuffer(data, categoryRecordOffset + nameOffset));
+ GetStringNameFromBuffer(data, offset + categoryOffsets[categoryIndex] + nameOffset + uint32_t_size));
for (auto& counter : eventRecords)
{
const Counter* registeredCounter = m_CounterDirectory.RegisterCounter(armnn::profiling::BACKEND_ID,
@@ -260,6 +263,7 @@ std::vector<CounterDirectoryEventRecord> DirectoryCaptureCommandHandler::ReadEve
// 0:31 [32] name_eventRecordOffset: eventRecordOffset from the
// beginning of the event record pool to the name field
// The eventRecordOffset is always zero here, as the name field is always the first item in the pool
+ uint32_t nameOffset = profiling::ReadUint32(data, eventRecordOffset);
eventRecordOffset += uint32_t_size;
// Event record word 6:
@@ -274,15 +278,19 @@ std::vector<CounterDirectoryEventRecord> DirectoryCaptureCommandHandler::ReadEve
// beginning of the event record pool to the units field.
// An eventRecordOffset value of zero indicates this field is not provided
uint32_t unitsOffset = profiling::ReadUint32(data, eventRecordOffset);
- eventRecordOffset += uint32_t_size;
- eventRecordOffset += uint32_t_size;
- eventRecords[i].m_CounterName = GetStringNameFromBuffer(data, eventRecordOffset);
+ eventRecords[i].m_CounterName = GetStringNameFromBuffer(data, offset +
+ eventRecordsOffsets[i] +
+ nameOffset +
+ uint32_t_size);
- eventRecords[i].m_CounterDescription = GetStringNameFromBuffer(data, eventRecordOffset + descriptionOffset);
+ eventRecords[i].m_CounterDescription = GetStringNameFromBuffer(data, offset +
+ eventRecordsOffsets[i] +
+ descriptionOffset +
+ uint32_t_size);
eventRecords[i].m_CounterUnits = unitsOffset == 0 ? Optional<std::string>() :
- GetStringNameFromBuffer(data, eventRecordOffset + unitsOffset);
+ GetStringNameFromBuffer(data, eventRecordsOffsets[i] + offset + unitsOffset + uint32_t_size);
}
return eventRecords;