From c65de3df7fce6c0527388f68603a54c7b6da92c6 Mon Sep 17 00:00:00 2001 From: Compute-Runtime-Validation Date: Wed, 10 Sep 2025 03:18:48 +0200 Subject: [PATCH] Revert "fix: correctly set unpacked device binary prior decoding" This reverts commit f7188038b4ac2c88d9040f65028eba6295b99c5a. Signed-off-by: Compute-Runtime-Validation --- .../source/program/process_device_binary.cpp | 14 +-- opencl/source/program/program.cpp | 2 +- .../unit_test/api/cl_build_program_tests.inl | 98 ------------------- .../device_binary_format_zebin.cpp | 1 - 4 files changed, 6 insertions(+), 109 deletions(-) diff --git a/opencl/source/program/process_device_binary.cpp b/opencl/source/program/process_device_binary.cpp index 35891b1810..fbf5cb8721 100644 --- a/opencl/source/program/process_device_binary.cpp +++ b/opencl/source/program/process_device_binary.cpp @@ -227,19 +227,15 @@ cl_int Program::processGenBinary(const ClDevice &clDevice) { } if (!decodedSingleDeviceBinary.isSet) { - - auto blob = ArrayRef(reinterpret_cast(buildInfo.unpackedDeviceBinary.get()), buildInfo.unpackedDeviceBinarySize); - SingleDeviceBinary singleDeviceBinary = {}; decodedSingleDeviceBinary.programInfo = {}; - singleDeviceBinary.deviceBinary = blob; - singleDeviceBinary.targetDevice = NEO::getTargetDevice(clDevice.getRootDeviceEnvironment()); - singleDeviceBinary.generatorFeatureVersions.indirectMemoryAccessDetection = this->indirectDetectionVersion; - singleDeviceBinary.generatorFeatureVersions.indirectAccessBuffer = this->indirectAccessBufferMajorVersion; - singleDeviceBinary.generator = this->isGeneratedByIgc ? GeneratorType::igc : GeneratorType::unknown; + auto blob = ArrayRef(reinterpret_cast(buildInfo.unpackedDeviceBinary.get()), buildInfo.unpackedDeviceBinarySize); + SingleDeviceBinary binary = {}; + binary.deviceBinary = blob; + binary.targetDevice = NEO::getTargetDevice(clDevice.getRootDeviceEnvironment()); auto &gfxCoreHelper = clDevice.getGfxCoreHelper(); - std::tie(decodedSingleDeviceBinary.decodeError, std::ignore) = NEO::decodeSingleDeviceBinary(decodedSingleDeviceBinary.programInfo, singleDeviceBinary, decodedSingleDeviceBinary.decodeErrors, decodedSingleDeviceBinary.decodeWarnings, gfxCoreHelper); + std::tie(decodedSingleDeviceBinary.decodeError, std::ignore) = NEO::decodeSingleDeviceBinary(decodedSingleDeviceBinary.programInfo, binary, decodedSingleDeviceBinary.decodeErrors, decodedSingleDeviceBinary.decodeWarnings, gfxCoreHelper); } else { decodedSingleDeviceBinary.isSet = false; } diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index fff78ee3c7..40bfccb643 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -217,7 +217,7 @@ cl_int Program::createProgramFromBinary( this->isGeneratedByIgc = singleDeviceBinary.generator == GeneratorType::igc; this->indirectDetectionVersion = singleDeviceBinary.generatorFeatureVersions.indirectMemoryAccessDetection; - this->indirectAccessBufferMajorVersion = singleDeviceBinary.generatorFeatureVersions.indirectAccessBuffer; + this->indirectAccessBufferMajorVersion = singleDeviceBinary.generatorFeatureVersions.indirectMemoryAccessDetection; bool rebuild = AddressingModeHelper::containsBindlessKernel(decodedSingleDeviceBinary.programInfo.kernelInfos); rebuild |= !clDevice.getDevice().getExecutionEnvironment()->isOneApiPvcWaEnv(); diff --git a/opencl/test/unit_test/api/cl_build_program_tests.inl b/opencl/test/unit_test/api/cl_build_program_tests.inl index a9e22a4e93..a9ec781178 100644 --- a/opencl/test/unit_test/api/cl_build_program_tests.inl +++ b/opencl/test/unit_test/api/cl_build_program_tests.inl @@ -597,104 +597,6 @@ TEST_F(ClBuildProgramMultiDeviceTests, givenMultiDeviceProgramWithProgramBuiltFo EXPECT_EQ(CL_SUCCESS, retVal); } -TEST_F(ClBuildProgramMultiDeviceTests, GivenProgramCreatedFromSourceWhenBuildingThenCorrectlyFilledSingleDeviceBinaryIsUsed) { - MockUnrestrictiveContextMultiGPU context; - cl_program pProgram = nullptr; - - std::string zeinfo = std::string("version :\'") + versionToString(Zebin::ZeInfo::zeInfoDecoderVersion) + R"===(' -kernels: - - name : some_kernel - execution_env : - simd_size : 32 - require_iab: true - - name : some_other_kernel - execution_env : - simd_size : 32 -)==="; - - uint8_t kernelIsa[8]{0U}; - ZebinTestData::ValidEmptyProgram zebin; - zebin.removeSection(NEO::Zebin::Elf::SectionHeaderTypeZebin::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo); - zebin.appendSection(NEO::Zebin::Elf::SectionHeaderTypeZebin::SHT_ZEBIN_ZEINFO, NEO::Zebin::Elf::SectionNames::zeInfo, ArrayRef::fromAny(zeinfo.data(), zeinfo.size())); - zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "some_kernel", {kernelIsa, sizeof(kernelIsa)}); - zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::textPrefix.str() + "some_other_kernel", {kernelIsa, sizeof(kernelIsa)}); - - const uint8_t data[] = {'H', 'e', 'l', 'l', 'o', '!'}; - zebin.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Zebin::Elf::SectionNames::dataConstString, data); - - { - const uint32_t indirectAccessBufferMajorVersion = 4u; - - Zebin::Elf::ElfNoteSection elfNoteSection = {}; - elfNoteSection.type = Zebin::Elf::IntelGTSectionType::indirectAccessBufferMajorVersion; - elfNoteSection.descSize = sizeof(uint32_t); - elfNoteSection.nameSize = 8u; - - auto sectionDataSize = sizeof(Zebin::Elf::ElfNoteSection) + elfNoteSection.nameSize + alignUp(elfNoteSection.descSize, 4); - auto noteIntelGTSectionData = std::make_unique(sectionDataSize); - auto appendSingleIntelGTSectionData = [](const NEO::Elf::ElfNoteSection &elfNoteSection, uint8_t *const intelGTSectionData, const uint8_t *descData, const char *ownerName, size_t spaceAvailable) { - size_t offset = 0; - ASSERT_GE(spaceAvailable, sizeof(Zebin::Elf::ElfNoteSection) + elfNoteSection.nameSize + elfNoteSection.descSize); - memcpy_s(ptrOffset(intelGTSectionData, offset), sizeof(NEO::Elf::ElfNoteSection), &elfNoteSection, sizeof(NEO::Elf::ElfNoteSection)); - offset += sizeof(NEO::Elf::ElfNoteSection); - memcpy_s(reinterpret_cast(ptrOffset(intelGTSectionData, offset)), elfNoteSection.nameSize, ownerName, elfNoteSection.nameSize); - offset += elfNoteSection.nameSize; - memcpy_s(ptrOffset(intelGTSectionData, offset), elfNoteSection.descSize, descData, elfNoteSection.descSize); - offset += elfNoteSection.descSize; - }; - - appendSingleIntelGTSectionData(elfNoteSection, noteIntelGTSectionData.get(), reinterpret_cast(&indirectAccessBufferMajorVersion), - Zebin::Elf::intelGTNoteOwnerName.str().c_str(), sectionDataSize); - zebin.appendSection(Zebin::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, ArrayRef::fromAny(noteIntelGTSectionData.get(), sectionDataSize)); - } - - MockCompilerDebugVars debugVars; - debugVars.binaryToReturn = const_cast(zebin.storage.data()); - debugVars.binaryToReturnSize = zebin.storage.size(); - gEnvironment->igcPushDebugVars(debugVars); - gEnvironment->fclPushDebugVars(debugVars); - - cl_int retVal = CL_INVALID_PROGRAM; - pProgram = clCreateProgramWithSource( - &context, - 1, - sources, - &sourceKernelSize, - &retVal); - - EXPECT_NE(nullptr, pProgram); - ASSERT_EQ(CL_SUCCESS, retVal); - - cl_device_id firstDevice = context.pRootDevice0; - cl_device_id secondDevice = context.pRootDevice1; - cl_device_id devices[] = {firstDevice, secondDevice}; - - retVal = clBuildProgram( - pProgram, - 2, - devices, - nullptr, - nullptr, - nullptr); - EXPECT_EQ(CL_SUCCESS, retVal); - - cl_kernel pKernel = clCreateKernel(pProgram, "some_kernel", &retVal); - EXPECT_EQ(CL_SUCCESS, retVal); - - MultiDeviceKernel *kernel = castToObject(pKernel); - Program *program = castToObject(pProgram); - EXPECT_EQ(4u, program->getIndirectAccessBufferVersion()); - EXPECT_FALSE(kernel->getKernelInfos()[1]->kernelDescriptor.kernelMetadata.isGeneratedByIgc); - - retVal = clReleaseKernel(pKernel); - EXPECT_EQ(CL_SUCCESS, retVal); - retVal = clReleaseProgram(pProgram); - EXPECT_EQ(CL_SUCCESS, retVal); - - gEnvironment->igcPopDebugVars(); - gEnvironment->fclPopDebugVars(); -} - TEST_F(ClBuildProgramMultiDeviceTests, givenMultiDeviceProgramWithProgramBuiltForSingleDeviceWithCreatedKernelWhenBuildingProgramForSecondDeviceThenInvalidOperationReturned) { MockUnrestrictiveContextMultiGPU context; cl_program pProgram = nullptr; diff --git a/shared/source/device_binary_format/device_binary_format_zebin.cpp b/shared/source/device_binary_format/device_binary_format_zebin.cpp index 387ec03ed0..59cfc1652f 100644 --- a/shared/source/device_binary_format/device_binary_format_zebin.cpp +++ b/shared/source/device_binary_format/device_binary_format_zebin.cpp @@ -61,7 +61,6 @@ SingleDeviceBinary unpackSingleZebin(const ArrayRef archive, cons if (elf.elfFileHeader->machine == Elf::ElfMachine::EM_INTELGT) { validForTarget &= Zebin::validateTargetDevice(elf, requestedTargetDevice, outErrReason, outWarning, ret); } else { - Zebin::validateTargetDevice(elf, requestedTargetDevice, outErrReason, outWarning, ret); const auto &flags = reinterpret_cast(elf.elfFileHeader->flags); validForTarget &= flags.machineEntryUsesGfxCoreInsteadOfProductFamily ? (requestedTargetDevice.coreFamily == static_cast(elf.elfFileHeader->machine))