From d44815fc0c8426364f3199bdf38da3fe2c5157dc Mon Sep 17 00:00:00 2001 From: Finn Williams Date: Fri, 1 May 2020 13:25:55 +0100 Subject: Update the CounterDirectory Packet offsets to be relative to the start of the table containing that offset * IVGCVSW-4763 Update the event pointer table offsets * IVGCVSW-4764 Update the event record block offsets * IVGCVSW-4765 Update the device name offset * IVGCVSW-4766 Update the counter set name offset * IVGCVSW-4767 Update device pointer table offsets * IVGCVSW-4768 Update the counter set pointer table offsets * IVGCVSW-4769 Update the category pointer table offsets Signed-off-by: Finn Williams Change-Id: I6e815ae5b16478fc5ec760caf704451fe5f84a29 --- src/profiling/DirectoryCaptureCommandHandler.cpp | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'src/profiling/DirectoryCaptureCommandHandler.cpp') 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 deviceRecordOffsets(deviceRecordCount); std::vector counterSetOffsets(counterSetRecordCount); std::vector 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 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& 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 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 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() : - GetStringNameFromBuffer(data, eventRecordOffset + unitsOffset); + GetStringNameFromBuffer(data, eventRecordsOffsets[i] + offset + unitsOffset + uint32_t_size); } return eventRecords; -- cgit v1.2.1