feature: verify stateful information only when binary is generated by IGC

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>

Related-To: NEO-6075

Ngen binaries contain stateful information, however they are
not used in isa on Pvc. Therefore, we can just ignore them.
This commit is contained in:
Kamil Kopryk
2023-06-09 15:23:03 +00:00
committed by Compute-Runtime-Automation
parent 37f04dc670
commit 6a0f7afd64
25 changed files with 249 additions and 32 deletions

View File

@@ -59,7 +59,7 @@ SingleDeviceBinary unpackSingleZebin(const ArrayRef<const uint8_t> archive, cons
bool validForTarget = true;
if (elf.elfFileHeader->machine == Elf::ELF_MACHINE::EM_INTELGT) {
validForTarget &= Zebin::validateTargetDevice(elf, requestedTargetDevice, outErrReason, outWarning);
validForTarget &= Zebin::validateTargetDevice(elf, requestedTargetDevice, outErrReason, outWarning, ret.generator);
} else {
const auto &flags = reinterpret_cast<const NEO::Zebin::Elf::ZebinTargetFlags &>(elf.elfFileHeader->flags);
validForTarget &= flags.machineEntryUsesGfxCoreInsteadOfProductFamily
@@ -67,6 +67,8 @@ SingleDeviceBinary unpackSingleZebin(const ArrayRef<const uint8_t> archive, cons
: (requestedTargetDevice.productFamily == static_cast<PRODUCT_FAMILY>(elf.elfFileHeader->machine));
validForTarget &= (0 == flags.validateRevisionId) | ((requestedTargetDevice.stepping >= flags.minHwRevisionId) & (requestedTargetDevice.stepping <= flags.maxHwRevisionId));
validForTarget &= (requestedTargetDevice.maxPointerSizeInBytes >= static_cast<uint32_t>(numBits == Elf::EI_CLASS_32 ? 4 : 8));
ret.generator = static_cast<GeneratorType>(flags.generatorId);
}
if (false == validForTarget) {
@@ -119,6 +121,12 @@ DecodeError decodeSingleZebin(ProgramInfo &dst, const SingleDeviceBinary &src, s
return decodeError;
}
bool isGeneratedByIgc = src.generator == GeneratorType::Igc;
for (auto &kernelInfo : dst.kernelInfos) {
kernelInfo->kernelDescriptor.kernelMetadata.isGeneratedByIgc = isGeneratedByIgc;
}
prepareLinkerInputForZebin<numBits>(dst, elf);
return decodeError;
}

View File

@@ -37,6 +37,11 @@ enum class DecodeError : uint8_t {
UnhandledBinary
};
enum class GeneratorType : uint8_t {
Unknown,
Igc
};
inline const char *asString(DecodeError err) {
switch (err) {
default:
@@ -73,6 +78,7 @@ struct SingleDeviceBinary {
ArrayRef<const uint8_t> packedTargetDeviceBinary;
ConstStringRef buildOptions;
TargetDevice targetDevice;
GeneratorType generator = GeneratorType::Igc;
};
template <DeviceBinaryFormat Format>

View File

@@ -75,10 +75,10 @@ bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ELF_IDENTIFIER_
return true;
}
template bool validateTargetDevice<Elf::EI_CLASS_32>(const Elf::Elf<Elf::EI_CLASS_32> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning);
template bool validateTargetDevice<Elf::EI_CLASS_64>(const Elf::Elf<Elf::EI_CLASS_64> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning);
template bool validateTargetDevice<Elf::EI_CLASS_32>(const Elf::Elf<Elf::EI_CLASS_32> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning, GeneratorType &generatorType);
template bool validateTargetDevice<Elf::EI_CLASS_64>(const Elf::Elf<Elf::EI_CLASS_64> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning, GeneratorType &generatorType);
template <Elf::ELF_IDENTIFIER_CLASS numBits>
bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning) {
bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning, GeneratorType &generatorType) {
GFXCORE_FAMILY gfxCore = IGFX_UNKNOWN_CORE;
PRODUCT_FAMILY productFamily = IGFX_UNKNOWN;
AOT::PRODUCT_CONFIG productConfig = AOT::UNKNOWN_ISA;
@@ -106,6 +106,7 @@ bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targ
DEBUG_BREAK_IF(sizeof(uint32_t) != intelGTNote.data.size());
auto targetMetadataPacked = reinterpret_cast<const uint32_t *>(intelGTNote.data.begin());
targetMetadata.packed = static_cast<uint32_t>(*targetMetadataPacked);
generatorType = static_cast<GeneratorType>(targetMetadata.generatorId);
break;
}
case Elf::IntelGTSectionType::ZebinVersion: {

View File

@@ -50,7 +50,7 @@ bool isZebin(ArrayRef<const uint8_t> binary);
bool validateTargetDevice(const TargetDevice &targetDevice, Elf::ELF_IDENTIFIER_CLASS numBits, PRODUCT_FAMILY productFamily, GFXCORE_FAMILY gfxCore, AOT::PRODUCT_CONFIG productConfig, Zebin::Elf::ZebinTargetFlags targetMetadata);
template <Elf::ELF_IDENTIFIER_CLASS numBits>
bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning);
bool validateTargetDevice(const Elf::Elf<numBits> &elf, const TargetDevice &targetDevice, std::string &outErrReason, std::string &outWarning, GeneratorType &generatorType);
template <Elf::ELF_IDENTIFIER_CLASS numBits>
DecodeError decodeIntelGTNoteSection(ArrayRef<const uint8_t> intelGTNotesSection, std::vector<Elf::IntelGTNote> &intelGTNotes, std::string &outErrReason, std::string &outWarning);