mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
feat(zebin): Add support for SHT_ZEBIN_GTPIN_INFO type section
This commit adds support for decoding SHT_ZEBIN_GTPIN_INFO type sections. For each section, passed data will be stored in kernel info (for corresponding kernel). Related-To: NEO-7689 Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7790e208fd
commit
1a4755694e
@@ -56,7 +56,7 @@ inline constexpr ConstStringRef debugPrefix = ".debug_";
|
||||
inline constexpr ConstStringRef debugInfo = ".debug_info";
|
||||
inline constexpr ConstStringRef debugAbbrev = ".debug_abbrev";
|
||||
inline constexpr ConstStringRef zeInfo = ".ze_info";
|
||||
inline constexpr ConstStringRef gtpinInfo = ".gtpin_info";
|
||||
inline constexpr ConstStringRef gtpinInfo = ".gtpin_info.";
|
||||
inline constexpr ConstStringRef noteIntelGT = ".note.intelgt.compat";
|
||||
inline constexpr ConstStringRef buildOptions = ".misc.buildOptions";
|
||||
inline constexpr ConstStringRef vIsaAsmPrefix = ".visaasm.";
|
||||
|
||||
@@ -270,8 +270,12 @@ DecodeError extractZebinSections(NEO::Elf::Elf<numBits> &elf, ZebinSections<numB
|
||||
// ignoring intentionally - rel/rela sections handled by Elf decoder
|
||||
continue;
|
||||
case NEO::Elf::SHT_ZEBIN_GTPIN_INFO:
|
||||
// ignoring intentionally - gtpin internal data
|
||||
continue;
|
||||
if (sectionName.startsWith(NEO::Elf::SectionsNamesZebin::gtpinInfo.data())) {
|
||||
out.gtpinInfoSections.push_back(&elfSectionHeader);
|
||||
} else {
|
||||
outWarning.append("DeviceBinaryFormat::Zebin : Unhandled SHT_ZEBIN_GTPIN_INFO section : " + sectionName.str() + ", currently supports only : " + NEO::Elf::SectionsNamesZebin::gtpinInfo.str() + "KERNEL_NAME\n");
|
||||
}
|
||||
break;
|
||||
case NEO::Elf::SHT_ZEBIN_VISA_ASM:
|
||||
// ignoring intentionally - visa asm
|
||||
continue;
|
||||
@@ -765,6 +769,11 @@ DecodeError decodeZebin(ProgramInfo &dst, NEO::Elf::Elf<numBits> &elf, std::stri
|
||||
return DecodeError::InvalidBinary;
|
||||
}
|
||||
|
||||
auto gtpinInfoForKernel = getKernelGtpinInfo(kernelName, elf, zebinSections);
|
||||
if (false == gtpinInfoForKernel.empty()) {
|
||||
kernelInfo->igcInfoForGtpin = reinterpret_cast<const gtpin::igc_info_t *>(gtpinInfoForKernel.begin());
|
||||
}
|
||||
|
||||
kernelInfo->heapInfo.pKernelHeap = kernelInstructions.begin();
|
||||
kernelInfo->heapInfo.KernelHeapSize = static_cast<uint32_t>(kernelInstructions.size());
|
||||
kernelInfo->heapInfo.KernelUnpaddedSize = static_cast<uint32_t>(kernelInstructions.size());
|
||||
@@ -797,6 +806,22 @@ ArrayRef<const uint8_t> getKernelHeap(ConstStringRef &kernelName, Elf::Elf<numBi
|
||||
return {};
|
||||
}
|
||||
|
||||
template ArrayRef<const uint8_t> getKernelGtpinInfo<Elf::EI_CLASS_32>(ConstStringRef &kernelName, Elf::Elf<Elf::EI_CLASS_32> &elf, const ZebinSections<Elf::EI_CLASS_32> &zebinSections);
|
||||
template ArrayRef<const uint8_t> getKernelGtpinInfo<Elf::EI_CLASS_64>(ConstStringRef &kernelName, Elf::Elf<Elf::EI_CLASS_64> &elf, const ZebinSections<Elf::EI_CLASS_64> &zebinSections);
|
||||
template <Elf::ELF_IDENTIFIER_CLASS numBits>
|
||||
ArrayRef<const uint8_t> getKernelGtpinInfo(ConstStringRef &kernelName, Elf::Elf<numBits> &elf, const ZebinSections<numBits> &zebinSections) {
|
||||
auto sectionHeaderNamesData = elf.sectionHeaders[elf.elfFileHeader->shStrNdx].data;
|
||||
ConstStringRef sectionHeaderNamesString(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (auto *gtpinInfoSection : zebinSections.gtpinInfoSections) {
|
||||
ConstStringRef sectionName = ConstStringRef(sectionHeaderNamesString.begin() + gtpinInfoSection->header->name);
|
||||
auto sufix = sectionName.substr(static_cast<int>(NEO::Elf::SectionsNamesZebin::gtpinInfo.length()));
|
||||
if (sufix == kernelName) {
|
||||
return gtpinInfoSection->data;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
DecodeError decodeZeInfo(ProgramInfo &dst, ConstStringRef zeInfo, std::string &outErrReason, std::string &outWarning) {
|
||||
Yaml::YamlParser yamlParser;
|
||||
bool parseSuccess = yamlParser.parse(zeInfo, outErrReason, outWarning);
|
||||
|
||||
@@ -28,6 +28,7 @@ template <Elf::ELF_IDENTIFIER_CLASS numBits = Elf::EI_CLASS_64>
|
||||
struct ZebinSections {
|
||||
using SectionHeaderData = typename NEO::Elf::Elf<numBits>::SectionHeaderAndData;
|
||||
StackVec<SectionHeaderData *, 32> textKernelSections;
|
||||
StackVec<SectionHeaderData *, 32> gtpinInfoSections;
|
||||
StackVec<SectionHeaderData *, 1> zeInfoSections;
|
||||
StackVec<SectionHeaderData *, 1> globalDataSections;
|
||||
StackVec<SectionHeaderData *, 1> globalZeroInitDataSections;
|
||||
@@ -104,6 +105,9 @@ NEO::DecodeError decodeZebin(ProgramInfo &dst, NEO::Elf::Elf<numBits> &elf, std:
|
||||
template <Elf::ELF_IDENTIFIER_CLASS numBits>
|
||||
ArrayRef<const uint8_t> getKernelHeap(ConstStringRef &kernelName, Elf::Elf<numBits> &elf, const ZebinSections<numBits> &zebinSections);
|
||||
|
||||
template <Elf::ELF_IDENTIFIER_CLASS numBits>
|
||||
ArrayRef<const uint8_t> getKernelGtpinInfo(ConstStringRef &kernelName, Elf::Elf<numBits> &elf, const ZebinSections<numBits> &zebinSections);
|
||||
|
||||
NEO::DecodeError decodeZeInfo(ProgramInfo &dst, ConstStringRef zeInfo, std::string &outErrReason, std::string &outWarning);
|
||||
|
||||
void setKernelMiscInfoPosition(ConstStringRef metadata, NEO::ProgramInfo &dst);
|
||||
|
||||
Reference in New Issue
Block a user