From b6c51c67934c8afb7efc72c793f789969a2f71e7 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Thu, 8 Dec 2022 11:56:06 +0000 Subject: [PATCH] Add helper method to get support for MidThread preemption for RT kernels Move raii hw info config helper to shared Related-To: NEO-7547, NEO-7548 Signed-off-by: Mateusz Jablonski --- .../unified/unified_sharing_image_tests.cpp | 2 +- shared/source/command_stream/preemption.cpp | 3 ++ shared/source/os_interface/hw_info_config.h | 2 + shared/source/os_interface/hw_info_config.inl | 5 +++ shared/test/common/helpers/CMakeLists.txt | 1 + .../common/helpers}/raii_hw_info_config.h | 2 +- .../unit_test/preemption/preemption_tests.cpp | 42 +++++++++++++++++++ 7 files changed, 55 insertions(+), 2 deletions(-) rename {opencl/test/unit_test/os_interface => shared/test/common/helpers}/raii_hw_info_config.h (92%) diff --git a/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp b/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp index fcb89ade0a..24a02ee599 100644 --- a/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp +++ b/opencl/test/unit_test/sharings/unified/unified_sharing_image_tests.cpp @@ -6,11 +6,11 @@ */ #include "shared/source/gmm_helper/gmm.h" +#include "shared/test/common/helpers/raii_hw_info_config.h" #include "shared/test/common/mocks/mock_gmm_resource_info.h" #include "opencl/source/mem_obj/image.h" #include "opencl/source/sharings/unified/unified_image.h" -#include "opencl/test/unit_test/os_interface/raii_hw_info_config.h" #include "opencl/test/unit_test/sharings/unified/unified_sharing_fixtures.h" #include "opencl/test/unit_test/sharings/unified/unified_sharing_mocks.h" diff --git a/shared/source/command_stream/preemption.cpp b/shared/source/command_stream/preemption.cpp index 9651db10d3..ee7b04b318 100644 --- a/shared/source/command_stream/preemption.cpp +++ b/shared/source/command_stream/preemption.cpp @@ -79,10 +79,13 @@ PreemptionMode PreemptionHelper::getDefaultPreemptionMode(const HardwareInfo &hw PreemptionFlags PreemptionHelper::createPreemptionLevelFlags(Device &device, const KernelDescriptor *kernelDescriptor) { PreemptionFlags flags = {}; + auto &productHelper = device.getRootDeviceEnvironment().getHelper(); if (kernelDescriptor) { flags.flags.disabledMidThreadPreemptionKernel = kernelDescriptor->kernelAttributes.flags.requiresDisabledMidThreadPreemption; flags.flags.vmeKernel = kernelDescriptor->kernelAttributes.flags.usesVme; flags.flags.usesFencesForReadWriteImages = kernelDescriptor->kernelAttributes.flags.usesFencesForReadWriteImages; + + flags.flags.disabledMidThreadPreemptionKernel |= kernelDescriptor->kernelAttributes.flags.hasRTCalls && productHelper.isMidThreadPreemptionDisallowedForRayTracingKernels(); } flags.flags.deviceSupportsVmePreemption = device.getDeviceInfo().vmeAvcSupportsPreemption; flags.flags.disablePerCtxtPreemptionGranularityControl = device.getHardwareInfo().workaroundTable.flags.waDisablePerCtxtPreemptionGranularityControl; diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index cb8a53efc5..6cb58736df 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -148,6 +148,7 @@ class HwInfoConfig { virtual bool isPlatformQuerySupported() const = 0; virtual bool isNonBlockingGpuSubmissionSupported() const = 0; virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ) const = 0; + virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0; virtual bool getFrontEndPropertyScratchSizeSupport() const = 0; virtual bool getFrontEndPropertyPrivateScratchSizeSupport() const = 0; @@ -291,6 +292,7 @@ class HwInfoConfigHw : public HwInfoConfig { bool isPlatformQuerySupported() const override; bool isNonBlockingGpuSubmissionSupported() const override; bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ) const override; + bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override; bool getFrontEndPropertyScratchSizeSupport() const override; bool getFrontEndPropertyPrivateScratchSizeSupport() const override; diff --git a/shared/source/os_interface/hw_info_config.inl b/shared/source/os_interface/hw_info_config.inl index fa301c5641..3a05b779cf 100644 --- a/shared/source/os_interface/hw_info_config.inl +++ b/shared/source/os_interface/hw_info_config.inl @@ -532,6 +532,11 @@ bool HwInfoConfigHw::isResolveDependenciesByPipeControlsSupported(co return enabled; } +template +bool HwInfoConfigHw::isMidThreadPreemptionDisallowedForRayTracingKernels() const { + return false; +} + template void HwInfoConfigHw::fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) { propertiesSupport.coherencyRequired = getScmPropertyCoherencyRequiredSupport(); diff --git a/shared/test/common/helpers/CMakeLists.txt b/shared/test/common/helpers/CMakeLists.txt index 6146f1097e..2ddaae0eed 100644 --- a/shared/test/common/helpers/CMakeLists.txt +++ b/shared/test/common/helpers/CMakeLists.txt @@ -10,6 +10,7 @@ target_sources(neo_libult_common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/batch_buffer_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/gtest_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/raii_hw_helper.h + ${CMAKE_CURRENT_SOURCE_DIR}/raii_hw_info_config.h ${CMAKE_CURRENT_SOURCE_DIR}/static_size3.h ${CMAKE_CURRENT_SOURCE_DIR}/ult_limits.h ) diff --git a/opencl/test/unit_test/os_interface/raii_hw_info_config.h b/shared/test/common/helpers/raii_hw_info_config.h similarity index 92% rename from opencl/test/unit_test/os_interface/raii_hw_info_config.h rename to shared/test/common/helpers/raii_hw_info_config.h index 818df2db18..5938432819 100644 --- a/opencl/test/unit_test/os_interface/raii_hw_info_config.h +++ b/shared/test/common/helpers/raii_hw_info_config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * diff --git a/shared/test/unit_test/preemption/preemption_tests.cpp b/shared/test/unit_test/preemption/preemption_tests.cpp index 06773ac216..8c1257cafb 100644 --- a/shared/test/unit_test/preemption/preemption_tests.cpp +++ b/shared/test/unit_test/preemption/preemption_tests.cpp @@ -7,10 +7,12 @@ #include "shared/source/command_stream/preemption.h" #include "shared/source/helpers/hw_helper.h" +#include "shared/source/kernel/kernel_descriptor.h" #include "shared/source/memory_manager/allocation_properties.h" #include "shared/test/common/cmd_parse/hw_parse.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/dispatch_flags_helper.h" +#include "shared/test/common/helpers/raii_hw_info_config.h" #include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/mocks/mock_builtins.h" #include "shared/test/common/mocks/mock_device.h" @@ -399,3 +401,43 @@ HWCMDTEST_F(IGFX_GEN8_CORE, MidThreadPreemptionTests, WhenProgrammingPreemptionT alignedFree(buffer); } } + +HWTEST_F(MidThreadPreemptionTests, givenKernelWithRayTracingWhenGettingPreemptionFlagsThenMidThreadPreemptionIsNotDisabled) { + + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + + KernelDescriptor kernelDescriptor{}; + + kernelDescriptor.kernelAttributes.flags.hasRTCalls = true; + + auto flags = PreemptionHelper::createPreemptionLevelFlags(*device, &kernelDescriptor); + EXPECT_FALSE(flags.flags.disabledMidThreadPreemptionKernel); +} + +class MockHwInfoConfigForRtKernels : public HwInfoConfigHw { + public: + bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override { + return !midThreadPreemptionAllowedForRayTracing; + } + bool midThreadPreemptionAllowedForRayTracing = true; +}; + +HWTEST_F(MidThreadPreemptionTests, givenKernelWithRayTracingWhenGettingPreemptionFlagsThenMidThreadPreemptionIsEnabledBasedOnProductHelperCapability) { + RAIIHwInfoConfigFactory hwInfoConfigBackup{defaultHwInfo->platform.eProductFamily}; + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); + + KernelDescriptor kernelDescriptor{}; + + kernelDescriptor.kernelAttributes.flags.hasRTCalls = true; + auto &productHelper = static_cast(device->getRootDeviceEnvironment().getHelper()); + { + productHelper.midThreadPreemptionAllowedForRayTracing = true; + auto flags = PreemptionHelper::createPreemptionLevelFlags(*device, &kernelDescriptor); + EXPECT_FALSE(flags.flags.disabledMidThreadPreemptionKernel); + } + { + productHelper.midThreadPreemptionAllowedForRayTracing = false; + auto flags = PreemptionHelper::createPreemptionLevelFlags(*device, &kernelDescriptor); + EXPECT_TRUE(flags.flags.disabledMidThreadPreemptionKernel); + } +} \ No newline at end of file