mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
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:
committed by
Compute-Runtime-Automation
parent
37f04dc670
commit
6a0f7afd64
@@ -310,6 +310,8 @@ ze_result_t ModuleTranslationUnit::createFromNativeBinary(const char *input, siz
|
||||
this->debugDataSize = singleDeviceBinary.debugData.size();
|
||||
}
|
||||
|
||||
this->isGeneratedByIgc = singleDeviceBinary.generator == NEO::GeneratorType::Igc;
|
||||
|
||||
bool rebuild = NEO::DebugManager.flags.RebuildPrecompiledKernels.get() && irBinarySize != 0;
|
||||
rebuild |= NEO::isRebuiltToPatchtokensRequired(device->getNEODevice(), archive, this->options, this->isBuiltIn, false);
|
||||
if (rebuild && irBinarySize == 0) {
|
||||
@@ -598,9 +600,12 @@ ze_result_t ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neo
|
||||
auto containsStatefulAccess = NEO::AddressingModeHelper::containsStatefulAccess(translationUnit->programInfo.kernelInfos, false);
|
||||
auto isUserKernel = (type == ModuleType::User);
|
||||
|
||||
auto isGeneratedByIgc = translationUnit->isGeneratedByIgc;
|
||||
|
||||
auto failBuildProgram = containsStatefulAccess &&
|
||||
isUserKernel &&
|
||||
NEO::AddressingModeHelper::failBuildProgramWithStatefulAccess(rootDeviceEnvironment);
|
||||
NEO::AddressingModeHelper::failBuildProgramWithStatefulAccess(rootDeviceEnvironment) &&
|
||||
isGeneratedByIgc;
|
||||
|
||||
if (failBuildProgram) {
|
||||
result = ZE_RESULT_ERROR_MODULE_BUILD_FAILURE;
|
||||
|
||||
@@ -85,6 +85,7 @@ struct ModuleTranslationUnit {
|
||||
|
||||
NEO::specConstValuesMap specConstantsValues;
|
||||
bool isBuiltIn{false};
|
||||
bool isGeneratedByIgc = true;
|
||||
};
|
||||
|
||||
struct ModuleImp : public Module {
|
||||
|
||||
@@ -3258,17 +3258,19 @@ TEST_F(ModuleInitializeTest, whenModuleInitializeIsCalledThenCorrectResultIsRetu
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
std::array<std::tuple<ze_result_t, bool, ModuleType, int32_t>, 5> testParams = {{
|
||||
{ZE_RESULT_SUCCESS, false, ModuleType::Builtin, -1},
|
||||
{ZE_RESULT_SUCCESS, true, ModuleType::Builtin, 0},
|
||||
{ZE_RESULT_SUCCESS, true, ModuleType::User, 0},
|
||||
{ZE_RESULT_SUCCESS, true, ModuleType::Builtin, 1},
|
||||
{ZE_RESULT_ERROR_MODULE_BUILD_FAILURE, true, ModuleType::User, 1},
|
||||
std::array<std::tuple<ze_result_t, bool, bool, ModuleType, int32_t>, 6> testParams = {{
|
||||
{ZE_RESULT_SUCCESS, false, true, ModuleType::Builtin, -1},
|
||||
{ZE_RESULT_SUCCESS, true, true, ModuleType::Builtin, 0},
|
||||
{ZE_RESULT_SUCCESS, true, true, ModuleType::User, 0},
|
||||
{ZE_RESULT_SUCCESS, true, true, ModuleType::Builtin, 1},
|
||||
{ZE_RESULT_ERROR_MODULE_BUILD_FAILURE, true, true, ModuleType::User, 1},
|
||||
{ZE_RESULT_SUCCESS, true, false, ModuleType::User, 1},
|
||||
}};
|
||||
|
||||
for (auto &[expectedResult, isStateful, moduleType, debugKey] : testParams) {
|
||||
for (auto &[expectedResult, isStateful, isIgcGenerated, moduleType, debugKey] : testParams) {
|
||||
MockModuleImp module(device, nullptr, moduleType);
|
||||
module.translationUnit = std::make_unique<MyMockModuleTU>(device);
|
||||
module.translationUnit->isGeneratedByIgc = isIgcGenerated;
|
||||
DebugManager.flags.FailBuildProgramWithStatefulAccess.set(debugKey);
|
||||
module.setAddressingMode(isStateful);
|
||||
EXPECT_EQ(expectedResult, module.initialize(&moduleDesc, device->getNEODevice()));
|
||||
|
||||
@@ -168,9 +168,10 @@ cl_int Program::build(
|
||||
auto containsStatefulAccess = AddressingModeHelper::containsStatefulAccess(buildInfos[clDevices[0]->getRootDeviceIndex()].kernelInfoArray, skipLastExplicitArg);
|
||||
auto isUserKernel = !isBuiltIn;
|
||||
|
||||
auto failBuildProgram = (containsStatefulAccess &&
|
||||
isUserKernel &&
|
||||
AddressingModeHelper::failBuildProgramWithStatefulAccess(clDevices[0]->getRootDeviceEnvironment()));
|
||||
auto failBuildProgram = containsStatefulAccess &&
|
||||
isUserKernel &&
|
||||
AddressingModeHelper::failBuildProgramWithStatefulAccess(clDevices[0]->getRootDeviceEnvironment()) &&
|
||||
isGeneratedByIgc;
|
||||
|
||||
if (failBuildProgram) {
|
||||
retVal = CL_BUILD_PROGRAM_FAILURE;
|
||||
|
||||
@@ -192,6 +192,9 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) {
|
||||
|
||||
this->buildInfos[rootDeviceIndex].unpackedDeviceBinary = makeCopy<char>(reinterpret_cast<const char *>(singleDeviceBinary.deviceBinary.begin()), singleDeviceBinarySize);
|
||||
this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = singleDeviceBinarySize;
|
||||
|
||||
this->isGeneratedByIgc = singleDeviceBinary.generator == GeneratorType::Igc;
|
||||
|
||||
} else {
|
||||
return CL_INVALID_BINARY;
|
||||
}
|
||||
|
||||
@@ -195,6 +195,8 @@ cl_int Program::createProgramFromBinary(
|
||||
this->buildInfos[rootDeviceIndex].debugData = makeCopy(reinterpret_cast<const char *>(singleDeviceBinary.debugData.begin()), singleDeviceBinary.debugData.size());
|
||||
this->buildInfos[rootDeviceIndex].debugDataSize = singleDeviceBinary.debugData.size();
|
||||
|
||||
this->isGeneratedByIgc = singleDeviceBinary.generator == GeneratorType::Igc;
|
||||
|
||||
auto isVmeUsed = containsVmeUsage(this->buildInfos[rootDeviceIndex].kernelInfoArray);
|
||||
bool rebuild = isRebuiltToPatchtokensRequired(&clDevice.getDevice(), archive, this->options, this->isBuiltIn, isVmeUsed);
|
||||
rebuild |= DebugManager.flags.RebuildPrecompiledKernels.get();
|
||||
@@ -207,6 +209,7 @@ cl_int Program::createProgramFromBinary(
|
||||
this->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize = singleDeviceBinary.deviceBinary.size();
|
||||
this->buildInfos[rootDeviceIndex].packedDeviceBinary = makeCopy<char>(reinterpret_cast<const char *>(archive.begin()), archive.size());
|
||||
this->buildInfos[rootDeviceIndex].packedDeviceBinarySize = archive.size();
|
||||
|
||||
} else {
|
||||
this->isCreatedFromBinary = false;
|
||||
this->requiresRebuild = true;
|
||||
|
||||
@@ -379,6 +379,8 @@ class Program : public BaseObject<_cl_program> {
|
||||
|
||||
bool isBuiltIn = false;
|
||||
bool kernelDebugEnabled = false;
|
||||
bool isGeneratedByIgc = true;
|
||||
|
||||
uint32_t maxRootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
||||
std::mutex lockMutex;
|
||||
uint32_t exposedKernels = 0;
|
||||
|
||||
@@ -168,6 +168,52 @@ HWTEST2_F(ClBuildProgramTests, GivenFailBuildProgramAndBinaryAsInputWhenCreating
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
HWTEST2_F(ClBuildProgramTests, GivenFailBuildProgramAndBinaryGeneratedByNgenAsInputWhenCreatingProgramWithSourceThenProgramBuildReturnsSuccess, IsAtLeastXeHpcCore) {
|
||||
|
||||
DebugManager.flags.FailBuildProgramWithStatefulAccess.set(1);
|
||||
|
||||
cl_program pProgram = nullptr;
|
||||
cl_int binaryStatus = CL_SUCCESS;
|
||||
|
||||
constexpr auto numBits = is32bit ? Elf::EI_CLASS_32 : Elf::EI_CLASS_64;
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinCopyBufferSimdModule<numBits>>(pDevice->getHardwareInfo(), 16);
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
auto &flags = reinterpret_cast<NEO::Zebin::Elf::ZebinTargetFlags &>(zebinData->elfHeader->flags);
|
||||
flags.generatorId = 0u; // ngen generated
|
||||
|
||||
ASSERT_NE(nullptr, src.data());
|
||||
ASSERT_NE(0u, src.size());
|
||||
|
||||
const unsigned char *binaries[1] = {reinterpret_cast<const unsigned char *>(src.data())};
|
||||
const size_t binarySize = src.size();
|
||||
|
||||
pProgram = clCreateProgramWithBinary(
|
||||
pContext,
|
||||
1,
|
||||
&testedClDevice,
|
||||
&binarySize,
|
||||
binaries,
|
||||
&binaryStatus,
|
||||
&retVal);
|
||||
|
||||
EXPECT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clBuildProgram(
|
||||
pProgram,
|
||||
1,
|
||||
&testedClDevice,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = clReleaseProgram(pProgram);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(ClBuildProgramTests, GivenBinaryAsInputWhenCreatingProgramWithBinaryForMultipleDevicesThenProgramBuildSucceeds) {
|
||||
MockUnrestrictiveContextMultiGPU context;
|
||||
cl_program pProgram = nullptr;
|
||||
|
||||
@@ -1872,6 +1872,7 @@ TEST_F(ProgramTests, givenStatefulAndStatelessAccessesWhenProgramBuildIsCalledTh
|
||||
using Program::irBinary;
|
||||
using Program::irBinarySize;
|
||||
using Program::isBuiltIn;
|
||||
using Program::isGeneratedByIgc;
|
||||
using Program::options;
|
||||
using Program::Program;
|
||||
using Program::sourceCode;
|
||||
@@ -1898,11 +1899,12 @@ TEST_F(ProgramTests, givenStatefulAndStatelessAccessesWhenProgramBuildIsCalledTh
|
||||
}
|
||||
};
|
||||
|
||||
std::array<std::tuple<int, bool, int32_t>, 3> testParams = {{{CL_SUCCESS, false, -1},
|
||||
{CL_SUCCESS, true, 0},
|
||||
{CL_BUILD_PROGRAM_FAILURE, true, 1}}};
|
||||
std::array<std::tuple<int, bool, bool, int32_t>, 4> testParams = {{{CL_SUCCESS, false, true, -1},
|
||||
{CL_SUCCESS, true, true, 0},
|
||||
{CL_BUILD_PROGRAM_FAILURE, true, true, 1},
|
||||
{CL_SUCCESS, true, false, 1}}};
|
||||
|
||||
for (auto &[result, isStatefulAccess, debuyKey] : testParams) {
|
||||
for (auto &[result, isStatefulAccess, isIgcGenerated, debuyKey] : testParams) {
|
||||
|
||||
if (!compilerProductHelper.isForceToStatelessRequired()) {
|
||||
result = CL_SUCCESS;
|
||||
@@ -1911,6 +1913,7 @@ TEST_F(ProgramTests, givenStatefulAndStatelessAccessesWhenProgramBuildIsCalledTh
|
||||
program.isBuiltIn = false;
|
||||
program.sourceCode = "test_kernel";
|
||||
program.createdFrom = Program::CreatedFrom::SOURCE;
|
||||
program.isGeneratedByIgc = isIgcGenerated;
|
||||
program.setAddressingMode(isStatefulAccess);
|
||||
DebugManager.flags.FailBuildProgramWithStatefulAccess.set(debuyKey);
|
||||
EXPECT_EQ(result, program.build(toClDeviceVector(*pClDevice), nullptr));
|
||||
|
||||
@@ -114,8 +114,15 @@ void EncodeDispatchKernel<Family>::encode(CommandContainer &container, EncodeDis
|
||||
idd.setSharedLocalMemorySize(slmSize);
|
||||
|
||||
auto bindingTableStateCount = kernelDescriptor.payloadMappings.bindingTable.numEntries;
|
||||
auto bufferAddressingMode = kernelDescriptor.kernelAttributes.bufferAddressingMode;
|
||||
|
||||
if (productHelper.isSkippingStatefulInformationRequired(kernelDescriptor)) {
|
||||
bindingTableStateCount = 0u;
|
||||
bufferAddressingMode = KernelDescriptor::Stateless;
|
||||
}
|
||||
|
||||
uint32_t bindingTablePointer = 0u;
|
||||
if ((kernelDescriptor.kernelAttributes.bufferAddressingMode == KernelDescriptor::BindfulAndStateless) ||
|
||||
if ((bufferAddressingMode == KernelDescriptor::BindfulAndStateless) ||
|
||||
kernelDescriptor.kernelAttributes.flags.usesImages) {
|
||||
container.prepareBindfulSsh();
|
||||
if (bindingTableStateCount > 0u) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -215,6 +215,7 @@ struct KernelDescriptor {
|
||||
|
||||
uint16_t compiledSubGroupsNumber = 0U;
|
||||
uint8_t requiredSubGroupSize = 0U;
|
||||
bool isGeneratedByIgc = true;
|
||||
} kernelMetadata;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -206,6 +206,7 @@ class ProductHelper {
|
||||
virtual bool is48bResourceNeededForRayTracing() const = 0;
|
||||
virtual bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isCachingOnCpuAvailable() const = 0;
|
||||
virtual bool isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const = 0;
|
||||
|
||||
virtual ~ProductHelper() = default;
|
||||
|
||||
|
||||
@@ -784,4 +784,10 @@ template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isCachingOnCpuAvailable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -159,6 +159,7 @@ class ProductHelperHw : public ProductHelper {
|
||||
bool is48bResourceNeededForRayTracing() const override;
|
||||
bool disableL3CacheForDebug(const HardwareInfo &hwInfo) const override;
|
||||
bool isCachingOnCpuAvailable() const override;
|
||||
bool isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const override;
|
||||
|
||||
~ProductHelperHw() override = default;
|
||||
|
||||
|
||||
@@ -212,4 +212,11 @@ template <>
|
||||
uint32_t ProductHelperHw<gfxProduct>::getNumberOfPartsInTileForConcurrentKernel() const {
|
||||
return PVC::numberOfpartsInTileForConcurrentKernels;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<gfxProduct>::isSkippingStatefulInformationRequired(const KernelDescriptor &kernelDescriptor) const {
|
||||
bool isGeneratedByNgen = !kernelDescriptor.kernelMetadata.isGeneratedByIgc;
|
||||
return isGeneratedByNgen;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -239,6 +239,8 @@ ZebinCopyBufferSimdModule<numBits>::ZebinCopyBufferSimdModule(const NEO::Hardwar
|
||||
elfHeader.type = NEO::Zebin::Elf::ET_ZEBIN_EXE;
|
||||
|
||||
elfHeader.machine = hwInfo.platform.eProductFamily;
|
||||
auto &flags = reinterpret_cast<NEO::Zebin::Elf::ZebinTargetFlags &>(elfHeader.flags);
|
||||
flags.generatorId = 1u;
|
||||
|
||||
const uint8_t testKernelData[0x2c0] = {0u};
|
||||
|
||||
|
||||
@@ -5459,7 +5459,8 @@ TEST_F(IntelGTNotesFixture, GivenValidTargetDeviceAndNoteWithUnrecognizedTypeWhe
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
|
||||
auto validationRes = validateTargetDevice(elf, targetDevice, outErrReason, outWarning);
|
||||
GeneratorType generator{};
|
||||
auto validationRes = validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator);
|
||||
EXPECT_TRUE(validationRes);
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
|
||||
@@ -5516,7 +5517,8 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndV
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
GeneratorType generator{};
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST_F(IntelGTNotesFixture, givenAotConfigInIntelGTNotesSectionWhenValidatingTargetDeviceThenUseOnlyItForValidation) {
|
||||
@@ -5546,8 +5548,9 @@ TEST_F(IntelGTNotesFixture, givenAotConfigInIntelGTNotesSectionWhenValidatingTar
|
||||
auto elf = NEO::Elf::decodeElf<NEO::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST(ValidateTargetDevice32BitZebin, Given32BitZebinAndValidIntelGTNotesWhenValidatingTargetDeviceThenReturnTrue) {
|
||||
@@ -5572,8 +5575,44 @@ TEST(ValidateTargetDevice32BitZebin, Given32BitZebinAndValidIntelGTNotesWhenVali
|
||||
auto elf = NEO::Elf::decodeElf<Zebin::Elf::EI_CLASS_32>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST(ValidateTargetDeviceGeneratorZebin, GivenZebinAndValidIntelGTNotesWithGeneratorIdWhenValidatingTargetDeviceThenGeneratorIsSetCorrectly) {
|
||||
|
||||
for (auto generatorId : {0u, 1u}) {
|
||||
TargetDevice targetDevice;
|
||||
targetDevice.productFamily = productFamily;
|
||||
targetDevice.coreFamily = renderCoreFamily;
|
||||
targetDevice.maxPointerSizeInBytes = 4;
|
||||
targetDevice.stepping = hardwareInfoTable[productFamily]->platform.usRevId;
|
||||
|
||||
ZebinTestData::ValidEmptyProgram<NEO::Elf::EI_CLASS_32> zebin;
|
||||
zebin.elfHeader->type = NEO::Elf::ET_REL;
|
||||
zebin.elfHeader->machine = NEO::Elf::ELF_MACHINE::EM_INTELGT;
|
||||
|
||||
Zebin::Elf::ZebinTargetFlags targetMetadata;
|
||||
targetMetadata.validateRevisionId = true;
|
||||
targetMetadata.minHwRevisionId = targetDevice.stepping;
|
||||
targetMetadata.maxHwRevisionId = targetDevice.stepping;
|
||||
targetMetadata.generatorId = generatorId;
|
||||
auto currentVersion = versionToString(NEO::Zebin::ZeInfo::zeInfoDecoderVersion);
|
||||
auto intelGTNotesSection = ZebinTestData::createIntelGTNoteSection(productFamily, renderCoreFamily, targetMetadata, currentVersion);
|
||||
zebin.appendSection(NEO::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, intelGTNotesSection);
|
||||
std::string outErrReason, outWarning;
|
||||
auto elf = NEO::Elf::decodeElf<Zebin::Elf::EI_CLASS_32>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
|
||||
GeneratorType generator{};
|
||||
EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
|
||||
bool isIgcGeneratedExpectation = static_cast<bool>(generatorId);
|
||||
bool isIgcGenerated = static_cast<bool>(generator);
|
||||
EXPECT_EQ(isIgcGeneratedExpectation, isIgcGenerated);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndNoNotesThenReturnFalse) {
|
||||
@@ -5587,8 +5626,9 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndN
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenInvalidTargetDeviceAndValidNotesThenReturnFalse) {
|
||||
@@ -5639,8 +5679,9 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenInvalidTargetDeviceAn
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndInvalidNoteTypeThenReturnFalse) {
|
||||
@@ -5664,8 +5705,9 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndI
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning));
|
||||
EXPECT_FALSE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator));
|
||||
}
|
||||
|
||||
TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenInvalidIntelGTNotesSecionSizeWhichWilLCauseOOBAccessThenReturnFalse) {
|
||||
@@ -5688,9 +5730,10 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenInvalidIntelGTNotesSe
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
TargetDevice targetDevice;
|
||||
auto result = validateTargetDevice(elf, targetDevice, outErrReason, outWarning);
|
||||
auto result = validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator);
|
||||
EXPECT_FALSE(result);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
auto errStr{"DeviceBinaryFormat::Zebin : Offseting will cause out-of-bound memory read! Section size: " + std::to_string(incorrectSectionDataSize) +
|
||||
@@ -5716,9 +5759,10 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidZeInfoVersionInI
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
TargetDevice targetDevice;
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning);
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator);
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
}
|
||||
|
||||
@@ -5763,9 +5807,10 @@ TEST_F(IntelGTNotesFixture, GivenInvalidVersioningWhenValidatingTargetDeviceThen
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
TargetDevice targetDevice;
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning);
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_STREQ("DeviceBinaryFormat::Zebin::.ze_info : Invalid version format - expected 'MAJOR.MINOR' string, got : .11\n", outErrReason.c_str());
|
||||
}
|
||||
@@ -5786,9 +5831,10 @@ TEST_F(IntelGTNotesFixture, GivenIncompatibleVersioningWhenValidatingTargetDevic
|
||||
auto elf = Zebin::Elf::decodeElf<Zebin::Elf::EI_CLASS_64>(zebin.storage, outErrReason, outWarning);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_TRUE(outErrReason.empty());
|
||||
GeneratorType generator{};
|
||||
|
||||
TargetDevice targetDevice;
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning);
|
||||
validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator);
|
||||
EXPECT_TRUE(outWarning.empty());
|
||||
EXPECT_STREQ("DeviceBinaryFormat::Zebin::.ze_info : Unhandled major version : 2, decoder is at : 1\n", outErrReason.c_str());
|
||||
}
|
||||
|
||||
@@ -1354,6 +1354,50 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindles
|
||||
EXPECT_NE(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
|
||||
}
|
||||
|
||||
using NgenGeneratorDispatchKernelEncodeTest = Test<CommandEncodeStatesFixture>;
|
||||
|
||||
HWTEST2_F(NgenGeneratorDispatchKernelEncodeTest, givenBindfulKernelAndIsNotGeneratedByIgcWhenEncodeDispatchKernelThenCmdContainerDoesNotHaveSsh, IsPVC) {
|
||||
using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE;
|
||||
|
||||
for (auto isGeneratedByIgc : {false, true}) {
|
||||
auto commandContainer = std::make_unique<MyMockCommandContainer>();
|
||||
commandContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false);
|
||||
commandContainer->setDirtyStateForAllHeaps(false);
|
||||
commandContainer->l1CachePolicyDataRef() = &l1CachePolicyData;
|
||||
|
||||
if (isGeneratedByIgc == false) {
|
||||
commandContainer->indirectHeaps[HeapType::SURFACE_STATE].reset(nullptr);
|
||||
}
|
||||
|
||||
uint32_t numBindingTable = 1;
|
||||
BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState;
|
||||
|
||||
uint32_t dims[] = {1, 1, 1};
|
||||
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
|
||||
|
||||
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable;
|
||||
dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U;
|
||||
dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindfulAndStateless;
|
||||
dispatchInterface->kernelDescriptor.kernelMetadata.isGeneratedByIgc = isGeneratedByIgc;
|
||||
|
||||
const uint8_t *sshData = reinterpret_cast<uint8_t *>(&bindingTableState);
|
||||
dispatchInterface->getSurfaceStateHeapDataResult = const_cast<uint8_t *>(sshData);
|
||||
dispatchInterface->getSurfaceStateHeapDataSizeResult = static_cast<uint32_t>(sizeof(BINDING_TABLE_STATE));
|
||||
|
||||
bool requiresUncachedMocs = false;
|
||||
|
||||
EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs);
|
||||
|
||||
EncodeDispatchKernel<FamilyType>::encode(*commandContainer.get(), dispatchArgs, nullptr);
|
||||
|
||||
if (isGeneratedByIgc) {
|
||||
EXPECT_NE(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
|
||||
} else {
|
||||
EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(CommandEncodeStatesTest, givenKernelInfoWhenGettingRequiredDshSpaceThenReturnCorrectValues) {
|
||||
using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA;
|
||||
using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE;
|
||||
|
||||
@@ -20,6 +20,7 @@ class CommandEncodeStatesFixture : public DeviceFixture {
|
||||
class MyMockCommandContainer : public CommandContainer {
|
||||
public:
|
||||
using CommandContainer::dirtyHeaps;
|
||||
using CommandContainer::indirectHeaps;
|
||||
|
||||
IndirectHeap *getHeapWithRequiredSizeAndAlignment(HeapType heapType, size_t sizeRequired, size_t alignment) override {
|
||||
getHeapWithRequiredSizeAndAlignmentCalled++;
|
||||
|
||||
@@ -342,6 +342,16 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenAskedIfHeapInLocalMemThenFals
|
||||
EXPECT_FALSE(productHelper->heapInLocalMem(pInHwInfo));
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenIsSkippingStatefulInformationRequiredThenFalseIsReturned, IsNotPVC) {
|
||||
|
||||
KernelDescriptor kernelDescriptor{};
|
||||
kernelDescriptor.kernelMetadata.isGeneratedByIgc = true;
|
||||
EXPECT_FALSE(productHelper->isSkippingStatefulInformationRequired(kernelDescriptor));
|
||||
|
||||
kernelDescriptor.kernelMetadata.isGeneratedByIgc = false;
|
||||
EXPECT_FALSE(productHelper->isSkippingStatefulInformationRequired(kernelDescriptor));
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenSettingCapabilityCoherencyFlagThenFlagIsSet, IsAtMostGen11) {
|
||||
|
||||
bool coherency = false;
|
||||
|
||||
@@ -178,6 +178,16 @@ PVCTEST_F(PvcProductHelper, givenPvcProductHelperWhenCheckCopyEngineSelectorEnab
|
||||
EXPECT_FALSE(productHelper->isCopyEngineSelectorEnabled(hwInfo));
|
||||
}
|
||||
|
||||
PVCTEST_F(PvcProductHelper, givenPvcProductHelperWhenIsSkippingStatefulInformationRequiredThenCorrectResultIsReturned) {
|
||||
|
||||
KernelDescriptor kernelDescriptor{};
|
||||
kernelDescriptor.kernelMetadata.isGeneratedByIgc = true;
|
||||
EXPECT_FALSE(productHelper->isSkippingStatefulInformationRequired(kernelDescriptor));
|
||||
|
||||
kernelDescriptor.kernelMetadata.isGeneratedByIgc = false;
|
||||
EXPECT_TRUE(productHelper->isSkippingStatefulInformationRequired(kernelDescriptor));
|
||||
}
|
||||
|
||||
PVCTEST_F(PvcProductHelper, givenProductHelperAndProgramExtendedPipeControlPriorToNonPipelinedStateCommandDisabledWhenAskedIfPipeControlPriorToNonPipelinedStateCommandsWARequiredThenFalseIsReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.ProgramExtendedPipeControlPriorToNonPipelinedStateCommand.set(0);
|
||||
|
||||
Reference in New Issue
Block a user