diff --git a/level_zero/core/source/module/module_imp.cpp b/level_zero/core/source/module/module_imp.cpp index 5c788f63f1..c1409f391c 100644 --- a/level_zero/core/source/module/module_imp.cpp +++ b/level_zero/core/source/module/module_imp.cpp @@ -137,6 +137,7 @@ std::string ModuleTranslationUnit::generateCompilerOptions(const char *buildOpti internalOptions = NEO::CompilerOptions::concatenate(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired); } + NEO::CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); return internalOptions; } diff --git a/level_zero/core/test/unit_tests/sources/module/test_module.cpp b/level_zero/core/test/unit_tests/sources/module/test_module.cpp index 5af61636da..fd81dc7c0b 100644 --- a/level_zero/core/test/unit_tests/sources/module/test_module.cpp +++ b/level_zero/core/test/unit_tests/sources/module/test_module.cpp @@ -2289,6 +2289,23 @@ HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOpti EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos); } +HWTEST_F(ModuleTranslationUnitTest, givenInternalOptionsThenLSCCachePolicyIsSet) { + auto pMockCompilerInterface = new MockCompilerInterface; + auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()]; + rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface); + MockModuleTranslationUnit moduleTu(this->device); + auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr); + const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + EXPECT_TRUE(ret); + auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(); + if (expectedPolicy != nullptr) { + EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find(expectedPolicy), std::string::npos); + } else { + EXPECT_EQ(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default"), std::string::npos); + EXPECT_EQ(pMockCompilerInterface->inputInternalOptions.find("-cl-load-cache-default"), std::string::npos); + } +} + HWTEST_F(ModuleTranslationUnitTest, givenForceToStatelessRequiredWhenBuildingModuleThen4GbBuffersAreRequired) { auto mockCompilerInterface = new MockCompilerInterface; auto &rootDeviceEnvironment = neoDevice->executionEnvironment->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]; diff --git a/opencl/source/program/program.cpp b/opencl/source/program/program.cpp index 4fb715d03f..ceb2c2129e 100644 --- a/opencl/source/program/program.cpp +++ b/opencl/source/program/program.cpp @@ -105,7 +105,7 @@ std::string Program::getInternalOptions() const { } CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::preserveVec3Type); - + CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); return internalOptions; } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 7453dc7b67..479597616d 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1739,6 +1739,19 @@ TEST_F(ProgramTests, GivenStatelessToStatefulIsDisabledWhenProgramIsCreatedThenG EXPECT_TRUE(CompilerOptions::contains(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired)); } +TEST_F(ProgramTests, whenGetInternalOptionsThenLSCPolicyIsSet) { + MockProgram program(pContext, false, toClDeviceVector(*pClDevice)); + auto internalOptions = program.getInternalOptions(); + const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + auto expectedPolicy = compilerHwInfoConfig.getCachingPolicyOptions(); + if (expectedPolicy != nullptr) { + EXPECT_TRUE(CompilerOptions::contains(internalOptions, expectedPolicy)); + } else { + EXPECT_FALSE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default")); + EXPECT_FALSE(CompilerOptions::contains(internalOptions, "-cl-load-cache-default")); + } +} + TEST_F(ProgramTests, WhenCreatingProgramThenBindlessIsEnabledOnlyIfDebugFlagIsEnabled) { using namespace testing; DebugManagerStateRestore restorer; diff --git a/shared/offline_compiler/source/offline_compiler.cpp b/shared/offline_compiler/source/offline_compiler.cpp index a88763ffe1..2e33494757 100644 --- a/shared/offline_compiler/source/offline_compiler.cpp +++ b/shared/offline_compiler/source/offline_compiler.cpp @@ -692,6 +692,7 @@ void OfflineCompiler::appendExtraInternalOptions(std::string &internalOptions) { if (compilerHwInfoConfig.isForceEmuInt32DivRemSPRequired()) { CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::forceEmuInt32DivRemSP); } + CompilerOptions::concatenateAppend(internalOptions, compilerHwInfoConfig.getCachingPolicyOptions()); } void OfflineCompiler::parseDebugSettings() { diff --git a/shared/source/helpers/compiler_hw_info_config.h b/shared/source/helpers/compiler_hw_info_config.h index a205fc7c4e..bfbb5858f3 100644 --- a/shared/source/helpers/compiler_hw_info_config.h +++ b/shared/source/helpers/compiler_hw_info_config.h @@ -30,6 +30,7 @@ class CompilerHwInfoConfig { virtual bool isForceToStatelessRequired() const = 0; virtual void adjustHwInfoForIgc(HardwareInfo &hwInfo) const = 0; virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const = 0; + virtual const char *getCachingPolicyOptions() const = 0; }; template @@ -46,6 +47,7 @@ class CompilerHwInfoConfigHw : public CompilerHwInfoConfig { bool isForceToStatelessRequired() const override; void adjustHwInfoForIgc(HardwareInfo &hwInfo) const override; void setProductConfigForHwInfo(HardwareInfo &hwInfo, AheadOfTimeConfig config) const override; + const char *getCachingPolicyOptions() const override; protected: CompilerHwInfoConfigHw() = default; diff --git a/shared/source/helpers/compiler_hw_info_config_base.inl b/shared/source/helpers/compiler_hw_info_config_base.inl index 082b967feb..a959557d20 100644 --- a/shared/source/helpers/compiler_hw_info_config_base.inl +++ b/shared/source/helpers/compiler_hw_info_config_base.inl @@ -24,4 +24,9 @@ template void CompilerHwInfoConfigHw::adjustHwInfoForIgc(HardwareInfo &hwInfo) const { } +template +const char *CompilerHwInfoConfigHw::getCachingPolicyOptions() const { + return nullptr; +}; + } // namespace NEO diff --git a/shared/source/xe_hpg_core/compiler_hw_info_config_dg2.inl b/shared/source/xe_hpg_core/compiler_hw_info_config_dg2.inl new file mode 100644 index 0000000000..d41fb8a774 --- /dev/null +++ b/shared/source/xe_hpg_core/compiler_hw_info_config_dg2.inl @@ -0,0 +1,12 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +template <> +const char *CompilerHwInfoConfigHw::getCachingPolicyOptions() const { + static constexpr const char *cachingPolicy = "-cl-store-cache-default=7 -cl-load-cache-default=4"; + return cachingPolicy; +}; diff --git a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp index d1f8ed0973..fb7358c767 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -15,6 +15,8 @@ namespace NEO { #ifdef SUPPORT_DG2 static EnableGfxProductHw enableGfxProductHwDG2; + +#include "shared/source/xe_hpg_core/compiler_hw_info_config_dg2.inl" static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigDG2; #endif } // namespace NEO diff --git a/shared/test/common/xe_hpg_core/dg2/test_hw_info_config_dg2.cpp b/shared/test/common/xe_hpg_core/dg2/test_hw_info_config_dg2.cpp index be725bac81..81f50e5274 100644 --- a/shared/test/common/xe_hpg_core/dg2/test_hw_info_config_dg2.cpp +++ b/shared/test/common/xe_hpg_core/dg2/test_hw_info_config_dg2.cpp @@ -5,6 +5,7 @@ * */ +#include "shared/source/helpers/compiler_hw_info_config.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/test/common/fixtures/device_fixture.h" #include "shared/test/common/test_macros/test.h" @@ -15,6 +16,7 @@ using TestDg2HwInfoConfig = Test; HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingIsAdditionalStateBaseAddressWARequiredThenFalseIsReturned, IGFX_DG2); HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTestWindows, givenHardwareInfoWhenCallingIsMaxThreadsForWorkgroupWARequiredThenFalseIsReturned, IGFX_DG2); +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenCompilerHwInfoConfigWhengetCachingPolicyOptionsThenReturnNullptr, IGFX_DG2); DG2TEST_F(TestDg2HwInfoConfig, givenDG2WithCSteppingThenAdditionalStateBaseAddressWAIsNotRequired) { const auto &hwInfoConfig = *HwInfoConfig::get(productFamily); @@ -66,4 +68,11 @@ DG2TEST_F(TestDg2HwInfoConfig, givenDG2HwInfoConfigWhenCheckDirectSubmissionSupp auto hwInfo = *defaultHwInfo; const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); EXPECT_TRUE(hwInfoConfig.isDirectSubmissionSupported(hwInfo)); +} + +DG2TEST_F(TestDg2HwInfoConfig, givenDG2CompilerHwInfoConfigWhengetCachingPolicyOptionsThenReturnCorrectPolicies) { + auto hwInfo = *defaultHwInfo; + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily); + const char *expectedStr = "-cl-store-cache-default=7 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); } \ No newline at end of file diff --git a/shared/test/unit_test/helpers/test_hw_info_config.cpp b/shared/test/unit_test/helpers/test_hw_info_config.cpp index ee06709f93..225f06fd25 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -104,4 +104,9 @@ HWTEST2_F(HwInfoConfigTest, givenAotConfigWhenSetHwInfoRevisionIdThenCorrectValu HWTEST_F(HwInfoConfigTest, givenHwInfoConfigWhenIsAdjustWalkOrderAvailableCallThenFalseReturn) { const auto &hwInfoConfig = *HwInfoConfig::get(defaultHwInfo->platform.eProductFamily); EXPECT_FALSE(hwInfoConfig.isAdjustWalkOrderAvailable(*defaultHwInfo)); +} + +HWTEST_F(HwInfoConfigTest, givenCompilerHwInfoConfigWhengetCachingPolicyOptionsThenReturnNullptr) { + auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); + EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(), nullptr); } \ No newline at end of file