diff --git a/opencl/source/helpers/hardware_commands_helper_base.inl b/opencl/source/helpers/hardware_commands_helper_base.inl index 6430dcbb25..13c9381ae6 100644 --- a/opencl/source/helpers/hardware_commands_helper_base.inl +++ b/opencl/source/helpers/hardware_commands_helper_base.inl @@ -188,6 +188,10 @@ size_t HardwareCommandsHelper::sendInterfaceDescriptorData( auto programmableIDSLMSize = static_cast(HwHelperHw::get().computeSlmValues(hardwareInfo, slmTotalSize)); + if (DebugManager.flags.OverrideSlmAllocationSize.get() != -1) { + programmableIDSLMSize = static_cast(DebugManager.flags.OverrideSlmAllocationSize.get()); + } + interfaceDescriptor.setSharedLocalMemorySize(programmableIDSLMSize); EncodeDispatchKernel::programBarrierEnable(interfaceDescriptor, kernel.getKernelInfo(rootDeviceIndex).kernelDescriptor.kernelAttributes.barrierCount, diff --git a/opencl/test/unit_test/kernel/kernel_slm_tests.cpp b/opencl/test/unit_test/kernel/kernel_slm_tests.cpp index 95771c5020..2d65c07e2c 100644 --- a/opencl/test/unit_test/kernel/kernel_slm_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_slm_tests.cpp @@ -5,6 +5,8 @@ * */ +#include "shared/test/common/helpers/debug_manager_state_restore.h" + #include "opencl/source/command_queue/command_queue_hw.h" #include "opencl/source/helpers/hardware_commands_helper.h" #include "opencl/source/kernel/kernel.h" @@ -144,3 +146,42 @@ INSTANTIATE_TEST_CASE_P( SlmSizes, KernelSLMAndBarrierTest, testing::ValuesIn(slmSizeInKb)); + +HWTEST_F(KernelSLMAndBarrierTest, GivenInterfaceDescriptorProgrammedWhenOverrideSlmAllocationSizeIsSetThenSlmSizeIsOverwritten) { + using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; + + uint32_t expectedSlmSize = 5; + DebugManagerStateRestore dbgRestore; + DebugManager.flags.OverrideSlmAllocationSize.set(expectedSlmSize); + + kernelInfo.workloadInfo.slmStaticSize = 0; + + MockKernel kernel(program.get(), MockKernel::toKernelInfoContainer(kernelInfo, rootDeviceIndex)); + ASSERT_EQ(CL_SUCCESS, kernel.initialize()); + + CommandQueueHw cmdQ(nullptr, pClDevice, 0, false); + auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 8192); + + uint64_t interfaceDescriptorOffset = indirectHeap.getUsed(); + INTERFACE_DESCRIPTOR_DATA interfaceDescriptorData; + + HardwareCommandsHelper::sendInterfaceDescriptorData( + indirectHeap, + interfaceDescriptorOffset, + 0, + sizeof(crossThreadData), + sizeof(perThreadData), + 0, + 0, + 0, + 1, + kernel, + 4u, + pDevice->getPreemptionMode(), + &interfaceDescriptorData, + *pDevice); + + auto pInterfaceDescriptor = HardwareCommandsHelper::getInterfaceDescriptor(indirectHeap, interfaceDescriptorOffset, &interfaceDescriptorData); + + EXPECT_EQ(expectedSlmSize, pInterfaceDescriptor->getSharedLocalMemorySize()); +} diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 30cf099d4b..d383476caf 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -220,3 +220,4 @@ GpuScratchRegWriteAfterWalker = -1 GpuScratchRegWriteRegisterData = 0 GpuScratchRegWriteRegisterOffset = 0 UseBindlessDebugSip = 0 +OverrideSlmAllocationSize = -1 diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 88e08eb413..967f048ca0 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -90,6 +90,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideProfilingTimerResolution, -1, "-1: defau DECLARE_DEBUG_VARIABLE(int32_t, GpuScratchRegWriteAfterWalker, -1, "-1: disabled, x: add GPU scratch register write after x walker") DECLARE_DEBUG_VARIABLE(int32_t, GpuScratchRegWriteRegisterOffset, 0, "register offset for GPU scratch register write after walker") DECLARE_DEBUG_VARIABLE(int32_t, GpuScratchRegWriteRegisterData, 0, "register data for GPU scratch register write after walker") +DECLARE_DEBUG_VARIABLE(int32_t, OverrideSlmAllocationSize, -1, "-1: default, >=0: program value for shared local memory size") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")