From cfc673b77ce26dea3b54950f90586d7b1475f428 Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Tue, 5 Oct 2021 13:14:08 +0000 Subject: [PATCH] Add compilerHwInfoConfig Signed-off-by: Kamil Kopryk Related-To: NEO-6237 --- .../unit_test/helpers/hw_helper_tests.cpp | 13 ----- .../mock/mock_offline_compiler.h | 1 - .../offline_compiler_tests.cpp | 14 ----- shared/offline_compiler/source/CMakeLists.txt | 3 ++ .../source/extra_settings.cpp | 4 -- .../source/offline_compiler.cpp | 6 ++- .../source/offline_compiler.h | 1 - .../source/compiler_interface/CMakeLists.txt | 1 - .../compiler_extra_settings.cpp | 16 ------ .../compiler_interface/compiler_interface.cpp | 3 +- .../compiler_interface/compiler_interface.h | 2 - shared/source/gen11/enable_gen11.cpp | 4 ++ shared/source/gen12lp/enable_gen12lp.cpp | 6 +++ shared/source/gen8/enable_gen8.cpp | 2 + shared/source/gen9/enable_gen9.cpp | 8 ++- shared/source/helpers/CMakeLists.txt | 3 ++ .../helpers/compiler_hw_info_config.cpp | 14 +++++ .../source/helpers/compiler_hw_info_config.h | 53 +++++++++++++++++++ .../compiler_hw_info_config_bdw_and_later.inl | 19 +++++++ shared/source/helpers/hw_helper.h | 3 -- shared/source/helpers/hw_helper_base.inl | 5 -- .../os_interface/linux/hw_info_config_drm.cpp | 4 +- .../windows/hw_info_config_wddm.cpp | 5 +- .../source/xe_hp_core/enable_xe_hp_core.cpp | 2 + .../common/mocks/mock_compiler_interface.h | 1 - .../compiler_interface_tests.cpp | 10 ---- shared/test/unit_test/helpers/CMakeLists.txt | 1 + .../helpers/compiler_hw_info_config_tests.cpp | 25 +++++++++ 28 files changed, 152 insertions(+), 77 deletions(-) delete mode 100644 shared/source/compiler_interface/compiler_extra_settings.cpp create mode 100644 shared/source/helpers/compiler_hw_info_config.cpp create mode 100644 shared/source/helpers/compiler_hw_info_config.h create mode 100644 shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl create mode 100644 shared/test/unit_test/helpers/compiler_hw_info_config_tests.cpp diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 087c8a8f7f..38f40d83bf 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -1015,19 +1015,6 @@ HWTEST2_F(HwHelperTest, givenDefaultHwHelperHwWhenGettingIsBlitCopyRequiredForLo EXPECT_FALSE(helper.isBlitCopyRequiredForLocalMemory(*defaultHwInfo, graphicsAllocation)); } -HWTEST_F(HwHelperTest, whenIsMidThreadPreemptionSupportedIsCalledThenCorrectResultIsReturned) { - auto hwInfo = *defaultHwInfo; - const auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); - - hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt = true; - auto midThreadPreemptionSupported = hwHelper.isMidThreadPreemptionSupported(hwInfo); - EXPECT_TRUE(midThreadPreemptionSupported); - - hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt = false; - midThreadPreemptionSupported = hwHelper.isMidThreadPreemptionSupported(hwInfo); - EXPECT_FALSE(midThreadPreemptionSupported); -} - HWCMDTEST_F(IGFX_GEN8_CORE, HwHelperTest, WhenIsFusedEuDispatchEnabledIsCalledThenFalseIsReturned) { if (hardwareInfo.platform.eRenderCoreFamily == IGFX_GEN12LP_CORE) { GTEST_SKIP(); diff --git a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h index fade69f136..8294ee1b81 100644 --- a/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h +++ b/opencl/test/unit_test/offline_compiler/mock/mock_offline_compiler.h @@ -31,7 +31,6 @@ class MockOfflineCompiler : public OfflineCompiler { using OfflineCompiler::internalOptions; using OfflineCompiler::irBinary; using OfflineCompiler::irBinarySize; - using OfflineCompiler::isMidThreadPreemptionSupported; using OfflineCompiler::isSpirV; using OfflineCompiler::options; using OfflineCompiler::outputDirectory; diff --git a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp index 4507e69b3f..0f6c2f0b9c 100644 --- a/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp +++ b/opencl/test/unit_test/offline_compiler/offline_compiler_tests.cpp @@ -1036,20 +1036,6 @@ TEST(OfflineCompilerTest, givenDefaultOfflineCompilerObjectWhenNoOptionsAreChang EXPECT_FALSE(mockOfflineCompiler->inputFileSpirV); } -TEST(OfflineCompilerTest, whenIsMidThreadPreemptionSupportedIsCalledThenCorrectResultIsReturned) { - MockOfflineCompiler offlineCompiler; - - if (!hardwarePrefix[IGFX_SKYLAKE]) { - GTEST_SKIP(); - } - offlineCompiler.getHardwareInfo("skl"); - offlineCompiler.hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt = false; - EXPECT_FALSE(offlineCompiler.isMidThreadPreemptionSupported(offlineCompiler.hwInfo)); - - offlineCompiler.hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt = true; - EXPECT_TRUE(offlineCompiler.isMidThreadPreemptionSupported(offlineCompiler.hwInfo)); -} - TEST(OfflineCompilerTest, givenIntermediateRepresentationInputWhenBuildSourceCodeIsCalledThenProperTranslationContextIsUsed) { MockOfflineCompiler mockOfflineCompiler; std::vector argv = { diff --git a/shared/offline_compiler/source/CMakeLists.txt b/shared/offline_compiler/source/CMakeLists.txt index e5262f5b59..04f84e5fe0 100644 --- a/shared/offline_compiler/source/CMakeLists.txt +++ b/shared/offline_compiler/source/CMakeLists.txt @@ -27,6 +27,9 @@ set(CLOC_LIB_SRCS_LIB ${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}devices_additional.inl ${NEO_SHARED_DIRECTORY}/dll/devices/devices_base.inl ${NEO_SHARED_DIRECTORY}/helpers/abort.cpp + ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config.h + ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config.cpp + ${NEO_SHARED_DIRECTORY}/helpers/compiler_hw_info_config_bdw_and_later.inl ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.cpp ${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.h ${NEO_SHARED_DIRECTORY}/helpers/debug_helpers.cpp diff --git a/shared/offline_compiler/source/extra_settings.cpp b/shared/offline_compiler/source/extra_settings.cpp index 68b4d901dd..a52b0e78f9 100644 --- a/shared/offline_compiler/source/extra_settings.cpp +++ b/shared/offline_compiler/source/extra_settings.cpp @@ -17,8 +17,4 @@ void OfflineCompiler::resolveExtraSettings() { } } -bool OfflineCompiler::isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) { - return hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt; -} - } // namespace NEO diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index 88c8af265b..3ba7b1c779 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -14,6 +14,7 @@ #include "shared/source/device_binary_format/device_binary_formats.h" #include "shared/source/device_binary_format/elf/elf_encoder.h" #include "shared/source/device_binary_format/elf/ocl_elf.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/compiler_options_parser.h" #include "shared/source/helpers/debug_helpers.h" #include "shared/source/helpers/file_io.h" @@ -609,7 +610,10 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector & igcFeWa.get()->SetFtrGTX(hwInfo.featureTable.ftrGTX); igcFeWa.get()->SetFtr5Slice(hwInfo.featureTable.ftr5Slice); - igcFeWa.get()->SetFtrGpGpuMidThreadLevelPreempt(isMidThreadPreemptionSupported(hwInfo)); + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily); + if (compilerHwInfoConfig) { + igcFeWa.get()->SetFtrGpGpuMidThreadLevelPreempt(compilerHwInfoConfig->isMidThreadPreemptionSupported(hwInfo)); + } igcFeWa.get()->SetFtrIoMmuPageFaulting(hwInfo.featureTable.ftrIoMmuPageFaulting); igcFeWa.get()->SetFtrWddm2Svm(hwInfo.featureTable.ftrWddm2Svm); igcFeWa.get()->SetFtrPooledEuEnabled(hwInfo.featureTable.ftrPooledEuEnabled); diff --git a/shared/offline_compiler/source/offline_compiler.h b/shared/offline_compiler/source/offline_compiler.h index 11c089cf9b..2ea1cb91ca 100644 --- a/shared/offline_compiler/source/offline_compiler.h +++ b/shared/offline_compiler/source/offline_compiler.h @@ -96,7 +96,6 @@ class OfflineCompiler { int parseCommandLine(size_t numArgs, const std::vector &allArgs); void setStatelessToStatefullBufferOffsetFlag(); void resolveExtraSettings(); - bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo); void parseDebugSettings(); void storeBinary(char *&pDst, size_t &dstSize, const void *pSrc, const size_t srcSize); MOCKABLE_VIRTUAL int buildSourceCode(); diff --git a/shared/source/compiler_interface/CMakeLists.txt b/shared/source/compiler_interface/CMakeLists.txt index 4aa61a5683..8237e235a1 100644 --- a/shared/source/compiler_interface/CMakeLists.txt +++ b/shared/source/compiler_interface/CMakeLists.txt @@ -13,7 +13,6 @@ set(NEO_CORE_COMPILER_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.inl ${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/default_cache_config.h - ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}compiler_extra_settings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/intermediate_representations.h ${CMAKE_CURRENT_SOURCE_DIR}/linker.h ${CMAKE_CURRENT_SOURCE_DIR}/linker.inl diff --git a/shared/source/compiler_interface/compiler_extra_settings.cpp b/shared/source/compiler_interface/compiler_extra_settings.cpp deleted file mode 100644 index 098a29e179..0000000000 --- a/shared/source/compiler_interface/compiler_extra_settings.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2021 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/source/compiler_interface/compiler_interface.h" - -namespace NEO { - -bool CompilerInterface::isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) { - return hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt; -} - -} // namespace NEO diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index 252bf5766d..43f9991dc1 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -11,6 +11,7 @@ #include "shared/source/compiler_interface/compiler_interface.inl" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/device/device.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/os_interface/os_inc_base.h" @@ -452,7 +453,7 @@ IGC::IgcOclDeviceCtxTagOCL *CompilerInterface::getIgcDeviceCtx(const Device &dev igcFeWa.get()->SetFtrGTX(device.getHardwareInfo().featureTable.ftrGTX); igcFeWa.get()->SetFtr5Slice(device.getHardwareInfo().featureTable.ftr5Slice); - igcFeWa.get()->SetFtrGpGpuMidThreadLevelPreempt(isMidThreadPreemptionSupported(device.getHardwareInfo())); + igcFeWa.get()->SetFtrGpGpuMidThreadLevelPreempt(CompilerHwInfoConfig::get(hwInfo->platform.eProductFamily)->isMidThreadPreemptionSupported(*hwInfo)); igcFeWa.get()->SetFtrIoMmuPageFaulting(device.getHardwareInfo().featureTable.ftrIoMmuPageFaulting); igcFeWa.get()->SetFtrWddm2Svm(device.getHardwareInfo().featureTable.ftrWddm2Svm); igcFeWa.get()->SetFtrPooledEuEnabled(device.getHardwareInfo().featureTable.ftrPooledEuEnabled); diff --git a/shared/source/compiler_interface/compiler_interface.h b/shared/source/compiler_interface/compiler_interface.h index 0c86b60eda..9b351ae1e9 100644 --- a/shared/source/compiler_interface/compiler_interface.h +++ b/shared/source/compiler_interface/compiler_interface.h @@ -183,7 +183,5 @@ class CompilerInterface { bool requiresIgc = (IGC::CodeType::oclC != translationSrc) || ((IGC::CodeType::spirV != translationDst) && (IGC::CodeType::llvmBc != translationDst) && (IGC::CodeType::llvmLl != translationDst)); return (isFclAvailable() || (false == requiresFcl)) && (isIgcAvailable() || (false == requiresIgc)); } - - bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo); }; } // namespace NEO diff --git a/shared/source/gen11/enable_gen11.cpp b/shared/source/gen11/enable_gen11.cpp index 34c782e265..4b4a76aa92 100644 --- a/shared/source/gen11/enable_gen11.cpp +++ b/shared/source/gen11/enable_gen11.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen11/hw_cmds.h" +#include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "opencl/source/helpers/enable_product.inl" @@ -14,12 +15,15 @@ namespace NEO { #ifdef SUPPORT_ICLLP static EnableGfxProductHw enableGfxProductHwICLLP; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigICLLP; #endif #ifdef SUPPORT_LKF static EnableGfxProductHw enableGfxProductHwLKF; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigLKF; #endif #ifdef SUPPORT_EHL static EnableGfxProductHw enableGfxProductHwEHL; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigEHL; #endif } // namespace NEO diff --git a/shared/source/gen12lp/enable_gen12lp.cpp b/shared/source/gen12lp/enable_gen12lp.cpp index 00a3613095..1d8eced245 100644 --- a/shared/source/gen12lp/enable_gen12lp.cpp +++ b/shared/source/gen12lp/enable_gen12lp.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen12lp/hw_cmds.h" +#include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "opencl/source/helpers/enable_product.inl" @@ -14,17 +15,22 @@ namespace NEO { #ifdef SUPPORT_TGLLP static EnableGfxProductHw enableGfxProductHwTGLLP; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigTGLLP; #endif #ifdef SUPPORT_DG1 static EnableGfxProductHw enableGfxProductHwDG1; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigDG1; #endif #ifdef SUPPORT_RKL static EnableGfxProductHw enableGfxProductHwRKL; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigRKL; #endif #ifdef SUPPORT_ADLS static EnableGfxProductHw enableGfxProductHwADLS; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigADLS; #endif #ifdef SUPPORT_ADLP static EnableGfxProductHw enableGfxProductHwADLP; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigADLP; #endif } // namespace NEO diff --git a/shared/source/gen8/enable_gen8.cpp b/shared/source/gen8/enable_gen8.cpp index 7924d3f47c..b0250ca56b 100644 --- a/shared/source/gen8/enable_gen8.cpp +++ b/shared/source/gen8/enable_gen8.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen8/hw_cmds.h" +#include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "opencl/source/helpers/enable_product.inl" @@ -14,6 +15,7 @@ namespace NEO { #ifdef SUPPORT_BDW static EnableGfxProductHw enableGfxProductHwBDW; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigBDW; #endif } // namespace NEO diff --git a/shared/source/gen9/enable_gen9.cpp b/shared/source/gen9/enable_gen9.cpp index 3a3bd3595a..da3123c303 100644 --- a/shared/source/gen9/enable_gen9.cpp +++ b/shared/source/gen9/enable_gen9.cpp @@ -1,11 +1,12 @@ /* - * Copyright (C) 2018-2020 Intel Corporation + * Copyright (C) 2018-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/gen9/hw_cmds.h" +#include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "opencl/source/helpers/enable_product.inl" @@ -14,18 +15,23 @@ namespace NEO { #ifdef SUPPORT_BXT static EnableGfxProductHw enableGfxProductHwBXT; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigBXT; #endif #ifdef SUPPORT_CFL static EnableGfxProductHw enableGfxProductHwCFL; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigCFL; #endif #ifdef SUPPORT_GLK static EnableGfxProductHw enableGfxProductHwGLK; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigGLK; #endif #ifdef SUPPORT_KBL static EnableGfxProductHw enableGfxProductHwKBL; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigKBL; #endif #ifdef SUPPORT_SKL static EnableGfxProductHw enableGfxProductHwSKL; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigSKL; #endif } // namespace NEO diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index 358afc75df..28140435b7 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -27,6 +27,9 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h ${CMAKE_CURRENT_SOURCE_DIR}/common_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.h + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config_bdw_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/compiler_options_parser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/compiler_options_parser.h ${CMAKE_CURRENT_SOURCE_DIR}/completion_stamp.cpp diff --git a/shared/source/helpers/compiler_hw_info_config.cpp b/shared/source/helpers/compiler_hw_info_config.cpp new file mode 100644 index 0000000000..191a55e0c6 --- /dev/null +++ b/shared/source/helpers/compiler_hw_info_config.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_hw_info_config.h" + +namespace NEO { + +CompilerHwInfoConfig *CompilerHwInfoConfigFactory[IGFX_MAX_PRODUCT] = {}; + +} // namespace NEO diff --git a/shared/source/helpers/compiler_hw_info_config.h b/shared/source/helpers/compiler_hw_info_config.h new file mode 100644 index 0000000000..dd451b396e --- /dev/null +++ b/shared/source/helpers/compiler_hw_info_config.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/helpers/hw_info.h" + +#include "igfxfmid.h" + +namespace NEO { + +class CompilerHwInfoConfig; +struct HardwareInfo; +extern CompilerHwInfoConfig *CompilerHwInfoConfigFactory[IGFX_MAX_PRODUCT]; + +class CompilerHwInfoConfig { + public: + static CompilerHwInfoConfig *get(PRODUCT_FAMILY product) { + return CompilerHwInfoConfigFactory[product]; + } + + virtual bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const = 0; +}; + +template +class CompilerHwInfoConfigHw : public CompilerHwInfoConfig { + public: + static CompilerHwInfoConfig *get() { + static CompilerHwInfoConfigHw instance; + return &instance; + } + + bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const override; + + protected: + CompilerHwInfoConfigHw() = default; +}; + +template +struct EnableCompilerHwInfoConfig { + typedef typename HwMapper::GfxProduct GfxProduct; + + EnableCompilerHwInfoConfig() { + CompilerHwInfoConfig *pCompilerHwInfoConfig = CompilerHwInfoConfigHw::get(); + CompilerHwInfoConfigFactory[gfxProduct] = pCompilerHwInfoConfig; + } +}; + +} // namespace NEO diff --git a/shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl b/shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl new file mode 100644 index 0000000000..ea6c3238cb --- /dev/null +++ b/shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/helpers/compiler_hw_info_config.h" +#include "shared/source/helpers/hw_info.h" + +namespace NEO { +template +bool CompilerHwInfoConfigHw::isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const { + return hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt; +} + +} // namespace NEO diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index c2b80c12a0..56852b41d5 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -127,7 +127,6 @@ class HwHelper { virtual uint32_t getPlanarYuvMaxHeight() const = 0; virtual bool isBlitterForImagesSupported(const HardwareInfo &hwInfo) const = 0; virtual size_t getPreemptionAllocationAlignment() const = 0; - virtual bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const = 0; virtual std::unique_ptr createTimestampPacketAllocator(const std::vector &rootDeviceIndices, MemoryManager *memoryManager, size_t initialTagCount, CommandStreamReceiverType csrType, DeviceBitfield deviceBitfield) const = 0; @@ -360,8 +359,6 @@ class HwHelperHw : public HwHelper { bool additionalPipeControlArgsRequired() const override; - bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const override; - bool isEngineTypeRemappingToHwSpecificRequired() const override; bool isSipKernelAsHexadecimalArrayPreferred() const override; diff --git a/shared/source/helpers/hw_helper_base.inl b/shared/source/helpers/hw_helper_base.inl index 11800af6bb..ee3abcd4f7 100644 --- a/shared/source/helpers/hw_helper_base.inl +++ b/shared/source/helpers/hw_helper_base.inl @@ -608,11 +608,6 @@ bool HwHelperHw::isEngineTypeRemappingToHwSpecificRequired() const { return false; } -template -bool HwHelperHw::isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const { - return static_cast(hwInfo.featureTable.ftrGpGpuMidThreadLevelPreempt); -} - template bool HwHelperHw::isSipKernelAsHexadecimalArrayPreferred() const { return false; diff --git a/shared/source/os_interface/linux/hw_info_config_drm.cpp b/shared/source/os_interface/linux/hw_info_config_drm.cpp index 35de5ff8fd..b183925352 100644 --- a/shared/source/os_interface/linux/hw_info_config_drm.cpp +++ b/shared/source/os_interface/linux/hw_info_config_drm.cpp @@ -7,6 +7,7 @@ #include "shared/source/command_stream/preemption.h" #include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_info.h" @@ -175,8 +176,9 @@ int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo drm->checkNonPersistentContextsSupport(); drm->checkPreemptionSupport(); bool preemption = drm->isPreemptionSupported(); + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(outHwInfo->platform.eProductFamily); PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable, - hwHelper.isMidThreadPreemptionSupported(*outHwInfo) && preemption, + compilerHwInfoConfig->isMidThreadPreemptionSupported(*outHwInfo) && preemption, static_cast(outHwInfo->featureTable.ftrGpGpuThreadGroupLevelPreempt) && preemption, static_cast(outHwInfo->featureTable.ftrGpGpuMidBatchPreempt) && preemption); diff --git a/shared/source/os_interface/windows/hw_info_config_wddm.cpp b/shared/source/os_interface/windows/hw_info_config_wddm.cpp index 01207a5e0d..bb555c05dd 100644 --- a/shared/source/os_interface/windows/hw_info_config_wddm.cpp +++ b/shared/source/os_interface/windows/hw_info_config_wddm.cpp @@ -7,6 +7,7 @@ #include "shared/source/command_stream/preemption.h" #include "shared/source/debug_settings/debug_settings_manager.h" +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/hw_info.h" @@ -19,7 +20,7 @@ namespace NEO { int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) { auto &hwHelper = HwHelper::get(outHwInfo->platform.eRenderCoreFamily); auto &hwInfoConfig = *HwInfoConfig::get(outHwInfo->platform.eProductFamily); - + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(outHwInfo->platform.eProductFamily); outHwInfo->capabilityTable.ftrSvm = outHwInfo->featureTable.ftrSVM; hwHelper.adjustDefaultEngineType(outHwInfo); @@ -29,7 +30,7 @@ int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo outHwInfo->capabilityTable.ftrSupportsCoherency &= inHwInfo->featureTable.ftrL3IACoherency; PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable, - hwHelper.isMidThreadPreemptionSupported(*outHwInfo), + compilerHwInfoConfig->isMidThreadPreemptionSupported(*outHwInfo), static_cast(outHwInfo->featureTable.ftrGpGpuThreadGroupLevelPreempt), static_cast(outHwInfo->featureTable.ftrGpGpuMidBatchPreempt)); diff --git a/shared/source/xe_hp_core/enable_xe_hp_core.cpp b/shared/source/xe_hp_core/enable_xe_hp_core.cpp index acb9954de2..7a24d9caad 100644 --- a/shared/source/xe_hp_core/enable_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/enable_xe_hp_core.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_hw_info_config_bdw_and_later.inl" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/xe_hp_core/hw_cmds.h" @@ -14,5 +15,6 @@ namespace NEO { #ifdef SUPPORT_XE_HP_SDV static EnableGfxProductHw enableGfxProductHwXEHP; +static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigXEHP; #endif } // namespace NEO diff --git a/shared/test/common/mocks/mock_compiler_interface.h b/shared/test/common/mocks/mock_compiler_interface.h index f433c5bde0..3287bb8bca 100644 --- a/shared/test/common/mocks/mock_compiler_interface.h +++ b/shared/test/common/mocks/mock_compiler_interface.h @@ -25,7 +25,6 @@ class MockCompilerInterface : public CompilerInterface { using CompilerInterface::isCompilerAvailable; using CompilerInterface::isFclAvailable; using CompilerInterface::isIgcAvailable; - using CompilerInterface::isMidThreadPreemptionSupported; using CompilerInterface::fclMain; using CompilerInterface::igcMain; diff --git a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp index a78dabd58e..0f9c9a07f4 100644 --- a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp @@ -1163,16 +1163,6 @@ TEST_F(CompilerInterfaceTest, GivenRequestForNewFclTranslationCtxWhenInterfaceVe setFclDebugVars(prevDebugVars); } -HWTEST_F(CompilerInterfaceTest, whenIsMidThreadPreemptionSupportedIsCalledThenCorrectResultIsReturned) { - auto device = this->pDevice; - auto &hwInfo = *device->getRootDeviceEnvironment().getMutableHardwareInfo(); - UnitTestHelper::setExtraMidThreadPreemptionFlag(hwInfo, false); - EXPECT_FALSE(pCompilerInterface->isMidThreadPreemptionSupported(hwInfo)); - - UnitTestHelper::setExtraMidThreadPreemptionFlag(hwInfo, true); - EXPECT_TRUE(pCompilerInterface->isMidThreadPreemptionSupported(hwInfo)); -} - struct SpecConstantsTranslationCtxMock { bool returnFalse = false; diff --git a/shared/test/unit_test/helpers/CMakeLists.txt b/shared/test/unit_test/helpers/CMakeLists.txt index 8b316aec9f..a02cca5060 100644 --- a/shared/test/unit_test/helpers/CMakeLists.txt +++ b/shared/test/unit_test/helpers/CMakeLists.txt @@ -9,6 +9,7 @@ set(IGDRCL_SRCS_tests_helpers ${CMAKE_CURRENT_SOURCE_DIR}/array_count_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basic_math_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/bit_helpers_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/compiler_hw_info_config_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/debug_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/deferred_deleter_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers_tests.cpp diff --git a/shared/test/unit_test/helpers/compiler_hw_info_config_tests.cpp b/shared/test/unit_test/helpers/compiler_hw_info_config_tests.cpp new file mode 100644 index 0000000000..c111e6aef9 --- /dev/null +++ b/shared/test/unit_test/helpers/compiler_hw_info_config_tests.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/compiler_hw_info_config.h" +#include "shared/test/common/fixtures/device_fixture.h" +#include "shared/test/common/helpers/unit_test_helper.h" + +#include "test.h" + +using namespace NEO; + +using CompilerHwInfoConfigFixture = Test; + +HWTEST_F(CompilerHwInfoConfigFixture, WhenIsMidThreadPreemptionIsSupportedIsCalledThenCorrectResultIsReturned) { + auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); + UnitTestHelper::setExtraMidThreadPreemptionFlag(hwInfo, false); + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily); + EXPECT_FALSE(compilerHwInfoConfig->isMidThreadPreemptionSupported(hwInfo)); + UnitTestHelper::setExtraMidThreadPreemptionFlag(hwInfo, true); + EXPECT_TRUE(compilerHwInfoConfig->isMidThreadPreemptionSupported(hwInfo)); +}