mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
feat(zebin): add support for build options section
This change: * Adds support for build options section in zebinary - using build options in binary when rebuilding. * Appends "-cl-intel-allow-zebin" flag to build options when zebin is used. Resolves: NEO-6916 Signed-off-by: Krystian Chmielewski <krystian.chmielewski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0d82216f43
commit
e007ba499f
@@ -38,7 +38,7 @@ SingleDeviceBinary unpackSingleDeviceBinary<NEO::DeviceBinaryFormat::Zebin>(cons
|
||||
|
||||
switch (elf.elfFileHeader->type) {
|
||||
default:
|
||||
outErrReason = "Unhandled elf type";
|
||||
outErrReason.append("Unhandled elf type\n");
|
||||
return {};
|
||||
case NEO::Elf::ET_ZEBIN_EXE:
|
||||
break;
|
||||
@@ -51,9 +51,13 @@ SingleDeviceBinary unpackSingleDeviceBinary<NEO::DeviceBinaryFormat::Zebin>(cons
|
||||
ret.format = NEO::DeviceBinaryFormat::Zebin;
|
||||
ret.targetDevice = requestedTargetDevice;
|
||||
|
||||
for (auto &elfSH : elf.sectionHeaders) {
|
||||
for (size_t sectionId = 0U; sectionId < elf.sectionHeaders.size(); sectionId++) {
|
||||
auto &elfSH = elf.sectionHeaders[sectionId];
|
||||
if (elfSH.header->type == Elf::SHT_ZEBIN_SPIRV) {
|
||||
ret.intermediateRepresentation = elfSH.data;
|
||||
} else if (elfSH.header->type == Elf::SHT_ZEBIN_MISC &&
|
||||
Elf::SectionsNamesZebin::buildOptions == elf.getSectionName(static_cast<uint32_t>(sectionId))) {
|
||||
ret.buildOptions = ConstStringRef(reinterpret_cast<const char *>(elfSH.data.begin()), elfSH.data.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +75,10 @@ SingleDeviceBinary unpackSingleDeviceBinary<NEO::DeviceBinaryFormat::Zebin>(cons
|
||||
|
||||
if (false == validForTarget) {
|
||||
if (false == ret.intermediateRepresentation.empty()) {
|
||||
ret.buildOptions = NEO::CompilerOptions::allowZebin;
|
||||
ret.deviceBinary = {};
|
||||
outWarning.append("Invalid target device. Rebuilding from intermediate representation.\n");
|
||||
} else {
|
||||
outErrReason = "Unhandled target device";
|
||||
outErrReason.append("Unhandled target device\n");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ enum SHT_ZEBIN : uint32_t {
|
||||
SHT_ZEBIN_SPIRV = 0xff000009, // .spv.kernel section, value the same as SHT_OPENCL_SPIRV
|
||||
SHT_ZEBIN_ZEINFO = 0xff000011, // .ze_info section
|
||||
SHT_ZEBIN_GTPIN_INFO = 0xff000012, // .gtpin_info section
|
||||
SHT_ZEBIN_VISA_ASM = 0xff000013 // .visaasm sections
|
||||
SHT_ZEBIN_VISA_ASM = 0xff000013, // .visaasm sections
|
||||
SHT_ZEBIN_MISC = 0xff000014 // .misc section
|
||||
};
|
||||
|
||||
enum RELOC_TYPE_ZEBIN : uint32_t {
|
||||
@@ -54,6 +55,7 @@ static constexpr ConstStringRef debugAbbrev = ".debug_abbrev";
|
||||
static constexpr ConstStringRef zeInfo = ".ze_info";
|
||||
static constexpr ConstStringRef gtpinInfo = ".gtpin_info";
|
||||
static constexpr ConstStringRef noteIntelGT = ".note.intelgt.compat";
|
||||
static constexpr ConstStringRef buildOptions = ".misc.buildOptions";
|
||||
static constexpr ConstStringRef vIsaAsmPrefix = ".visaasm.";
|
||||
static constexpr ConstStringRef externalFunctions = "Intel_Symbol_Table_Void_Program";
|
||||
} // namespace SectionsNamesZebin
|
||||
|
||||
@@ -123,6 +123,13 @@ DecodeError extractZebinSections(NEO::Elf::Elf<Elf::EI_CLASS_64> &elf, ZebinSect
|
||||
outWarning.append("DeviceBinaryFormat::Zebin : Unhandled SHT_NOTE section : " + sectionName.str() + " currently supports only : " + NEO::Elf::SectionsNamesZebin::noteIntelGT.str() + ".\n");
|
||||
}
|
||||
break;
|
||||
case NEO::Elf::SHT_ZEBIN_MISC:
|
||||
if (sectionName == NEO::Elf::SectionsNamesZebin::buildOptions) {
|
||||
out.buildOptionsSection.push_back(&elfSectionHeader);
|
||||
} else {
|
||||
outWarning.append("DeviceBinaryFormat::Zebin : unhandled SHT_ZEBIN_MISC section : " + sectionName.str() + " currently supports only : " + NEO::Elf::SectionsNamesZebin::buildOptions.str() + ".\n");
|
||||
}
|
||||
break;
|
||||
case NEO::Elf::SHT_STRTAB:
|
||||
// ignoring intentionally - section header names
|
||||
continue;
|
||||
|
||||
@@ -30,6 +30,7 @@ struct ZebinSections {
|
||||
StackVec<SectionHeaderData *, 1> symtabSections;
|
||||
StackVec<SectionHeaderData *, 1> spirvSections;
|
||||
StackVec<SectionHeaderData *, 1> noteIntelGTSections;
|
||||
StackVec<SectionHeaderData *, 1> buildOptionsSection;
|
||||
};
|
||||
|
||||
using UniqueNode = StackVec<const NEO::Yaml::Node *, 1>;
|
||||
|
||||
Reference in New Issue
Block a user