From 2df001327a8cee6cc65760c7f81bd1785b6f3ef3 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 26 Oct 2022 17:45:19 +0000 Subject: [PATCH] Unify meaning of RebuildPrecompiledKernels across OCL and L0 APIs Resolves: NEO-7364 Signed-off-by: Mateusz Jablonski --- opencl/source/program/program.cpp | 2 +- opencl/test/unit_test/program/program_tests.cpp | 17 ++++++++++++----- .../debug_settings/debug_variables_base.inl | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 621f294a91..8035c623b5 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -193,7 +193,7 @@ cl_int Program::createProgramFromBinary( this->buildInfos[rootDeviceIndex].debugDataSize = singleDeviceBinary.debugData.size(); bool rebuild = isRebuiltToPatchtokensRequired(&clDevice.getDevice(), archive, this->options, this->isBuiltIn); - rebuild |= isBuiltIn && DebugManager.flags.RebuildPrecompiledKernels.get(); + rebuild |= DebugManager.flags.RebuildPrecompiledKernels.get(); if (rebuild && 0u == this->irBinarySize) { return CL_INVALID_BINARY; } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 4ea389ca6f..0734d535d6 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -2757,12 +2757,19 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramBuiltInWhenKernelRebulildIs ASSERT_TRUE(pProgram->requiresRebuild); } -TEST(CreateProgramFromBinaryTests, givenBinaryProgramNotBuiltInWhenBuiltInKernelRebulildIsForcedThenDeviceBinaryIsUsed) { +TEST(CreateProgramFromBinaryTests, givenBinaryProgramNotBuiltInWhenBuiltInKernelRebulildIsForcedThenDeviceBinaryIsNotUsed) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.RebuildPrecompiledKernels.set(true); cl_int retVal = CL_INVALID_BINARY; PatchTokensTestData::ValidEmptyProgram programTokens; + Elf::ElfEncoder elfEncoder; + elfEncoder.getElfFileHeader().type = Elf::ET_OPENCL_EXECUTABLE; + + constexpr auto mockSpirvDataSize = 0x10; + uint8_t mockSpirvData[mockSpirvDataSize]{0}; + elfEncoder.appendSection(Elf::SHT_OPENCL_SPIRV, Elf::SectionNamesOpenCl::spirvObject, ArrayRef::fromAny(mockSpirvData, mockSpirvDataSize)); + programTokens.storage = elfEncoder.encode(); const unsigned char *binaries[] = {programTokens.storage.data()}; size_t lengths[] = {programTokens.storage.size()}; auto clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); @@ -2777,10 +2784,10 @@ TEST(CreateProgramFromBinaryTests, givenBinaryProgramNotBuiltInWhenBuiltInKernel EXPECT_EQ(CL_SUCCESS, retVal); auto rootDeviceIndex = clDevice->getRootDeviceIndex(); - EXPECT_NE(nullptr, pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()); - EXPECT_LT(0U, pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize); - EXPECT_NE(nullptr, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinary); - EXPECT_LT(0U, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinarySize); + EXPECT_EQ(nullptr, pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinary.get()); + EXPECT_EQ(0U, pProgram->buildInfos[rootDeviceIndex].unpackedDeviceBinarySize); + EXPECT_EQ(nullptr, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinary); + EXPECT_EQ(0U, pProgram->buildInfos[rootDeviceIndex].packedDeviceBinarySize); } TEST(CreateProgramFromBinaryTests, givenBinaryProgramWhenKernelRebulildIsNotForcedThenDeviceBinaryIsUsed) { diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index a39fed1d91..8b58d878bd 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -49,7 +49,7 @@ DECLARE_DEBUG_VARIABLE(bool, DoNotFlushCaches, false, "clear all possible cache DECLARE_DEBUG_VARIABLE(bool, MakeEachEnqueueBlocking, false, "equivalent of finish after each enqueue") DECLARE_DEBUG_VARIABLE(bool, DisableResourceRecycling, false, "when set to true disables resource recycling optimization") DECLARE_DEBUG_VARIABLE(bool, TrackParentEvents, false, "events track their parents") -DECLARE_DEBUG_VARIABLE(bool, RebuildPrecompiledKernels, false, "forces driver to recompile precompiled kernels from sources") +DECLARE_DEBUG_VARIABLE(bool, RebuildPrecompiledKernels, false, "forces driver to recompile precompiled kernels from sources. Works for both builtin and user kernels") DECLARE_DEBUG_VARIABLE(bool, DisableKernelRecompilation, false, "Disable kernel recompilation") DECLARE_DEBUG_VARIABLE(bool, LoopAtDriverInit, false, "Adds endless loop in DebugSettingsManager constructor, useful for debugging.") DECLARE_DEBUG_VARIABLE(bool, DoNotRegisterTrimCallback, false, "When set to true driver does not register trim callback.")