From 9203f8787b7bbbe69d77d82d6a18e1cb9e17d8d6 Mon Sep 17 00:00:00 2001 From: Szymon Morek Date: Thu, 14 Jul 2022 10:37:55 +0000 Subject: [PATCH] Add template structs for L1 cache policy helper Related-To: NEO-7003 Signed-off-by: Szymon Morek --- .../xe_hpg_core/test_module_xe_hpg_core.cpp | 11 ++++++++ .../dg2/test_cmds_programming_dg2.cpp | 6 ++--- shared/source/gen11/enable_gen11.cpp | 3 +++ shared/source/gen12lp/enable_gen12lp.cpp | 6 +++++ shared/source/gen8/enable_gen8.cpp | 1 + shared/source/gen9/enable_gen9.cpp | 5 ++++ shared/source/helpers/cache_policy.h | 2 +- .../source/xe_hp_core/enable_xe_hp_core.cpp | 1 + .../source/xe_hpc_core/enable_xe_hpc_core.cpp | 1 + .../source/xe_hpg_core/enable_xe_hpg_core.cpp | 1 + .../test/common/mocks/mock_hw_info_config.cpp | 13 ++++++++++ .../unit_test/xe_hpg_core/dg2/CMakeLists.txt | 1 + .../dg2/cache_policy_tests_dg2.cpp | 26 +++++++++++++++++++ 13 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp index c7b71a37a1..57417fa9fa 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/test_module_xe_hpg_core.cpp @@ -9,6 +9,7 @@ #include "shared/test/common/test_macros/hw_test.h" #include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_module.h" namespace L0 { namespace ult { @@ -45,5 +46,15 @@ HWTEST2_F(KernelPropertyTest, givenKernelExtendedPropertiesStructureWhenKernelPr EXPECT_FALSE(kernelExtendedProperties.fp64Flags & FP_ATOMIC_EXT_FLAG_LOCAL_MIN_MAX); } +HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteByPassBuildOptionIsSet, IsDG2) { + 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); + EXPECT_TRUE(ret); + EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=2 -cl-load-cache-default=4"), std::string::npos); +} + } // namespace ult } // namespace L0 diff --git a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp index b705c5558f..396875670b 100644 --- a/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp +++ b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp @@ -39,7 +39,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra auto actualL1CachePolocy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); - const uint8_t expectedL1CachePolicy = 0; + const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); } @@ -89,7 +89,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL1CachingOverrideWhenStateBaseAddressIsP memoryManager->freeGraphicsMemory(allocation); } -DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWtL1CachePolicy) { +DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) { auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); size_t allocationSize = MemoryConstants::pageSize; AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::BUFFER, pDevice->getDeviceBitfield()); @@ -143,7 +143,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferThenChoseO auto actualL1CachePolocy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); - const uint8_t expectedL1CachePolicy = 0; + const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); alignedFree(ptr); diff --git a/shared/source/gen11/enable_gen11.cpp b/shared/source/gen11/enable_gen11.cpp index a64f7458bc..cda687407b 100644 --- a/shared/source/gen11/enable_gen11.cpp +++ b/shared/source/gen11/enable_gen11.cpp @@ -16,14 +16,17 @@ namespace NEO { #ifdef SUPPORT_ICLLP +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwICLLP; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigICLLP; #endif #ifdef SUPPORT_LKF +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwLKF; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigLKF; #endif #ifdef SUPPORT_EHL +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwEHL; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigEHL; #endif diff --git a/shared/source/gen12lp/enable_gen12lp.cpp b/shared/source/gen12lp/enable_gen12lp.cpp index ebde21b717..f01bceb0c6 100644 --- a/shared/source/gen12lp/enable_gen12lp.cpp +++ b/shared/source/gen12lp/enable_gen12lp.cpp @@ -16,28 +16,34 @@ namespace NEO { #ifdef SUPPORT_TGLLP +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwTGLLP; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigTGLLP; #endif #ifdef SUPPORT_DG1 +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwDG1; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigDG1; #endif #ifdef SUPPORT_RKL +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwRKL; #include "shared/source/gen12lp/compiler_hw_info_config_rkl.inl" static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigRKL; #endif #ifdef SUPPORT_ADLS +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwADLS; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigADLS; #endif #ifdef SUPPORT_ADLP +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwADLP; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigADLP; #endif #ifdef SUPPORT_ADLN +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwADLN; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigADLN; #endif diff --git a/shared/source/gen8/enable_gen8.cpp b/shared/source/gen8/enable_gen8.cpp index 555a611162..7db4c488c6 100644 --- a/shared/source/gen8/enable_gen8.cpp +++ b/shared/source/gen8/enable_gen8.cpp @@ -16,6 +16,7 @@ namespace NEO { #ifdef SUPPORT_BDW +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwBDW; #include "shared/source/gen8/compiler_hw_info_config_bdw.inl" diff --git a/shared/source/gen9/enable_gen9.cpp b/shared/source/gen9/enable_gen9.cpp index d78ed807ab..5a9548546b 100644 --- a/shared/source/gen9/enable_gen9.cpp +++ b/shared/source/gen9/enable_gen9.cpp @@ -16,22 +16,27 @@ namespace NEO { #ifdef SUPPORT_BXT +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwBXT; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigBXT; #endif #ifdef SUPPORT_CFL +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwCFL; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigCFL; #endif #ifdef SUPPORT_GLK +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwGLK; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigGLK; #endif #ifdef SUPPORT_KBL +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwKBL; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigKBL; #endif #ifdef SUPPORT_SKL +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwSKL; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigSKL; #endif diff --git a/shared/source/helpers/cache_policy.h b/shared/source/helpers/cache_policy.h index 3f613dfd23..4c684beb78 100644 --- a/shared/source/helpers/cache_policy.h +++ b/shared/source/helpers/cache_policy.h @@ -24,7 +24,7 @@ struct L1CachePolicyHelper { static const char *getCachingPolicyOptions(); static uint32_t getDefaultL1CachePolicy() { - return 0; + return 0u; } static uint32_t getL1CachePolicy() { 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 56294067d2..19179188ed 100644 --- a/shared/source/xe_hp_core/enable_xe_hp_core.cpp +++ b/shared/source/xe_hp_core/enable_xe_hp_core.cpp @@ -16,6 +16,7 @@ namespace NEO { #ifdef SUPPORT_XE_HP_SDV +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwXEHP; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigXEHP; #endif diff --git a/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp b/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp index 5c91dd9d38..418fb27840 100644 --- a/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/enable_xe_hpc_core.cpp @@ -19,6 +19,7 @@ namespace NEO { static EnableGfxProductHw enableGfxProductHwPVC; #include "shared/source/xe_hpc_core/compiler_hw_info_config_pvc.inl" +template struct L1CachePolicyHelper; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigPVC; #endif 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 8c02637122..41712cb9fe 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -22,6 +22,7 @@ uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; } +template struct L1CachePolicyHelper; static EnableGfxProductHw enableGfxProductHwDG2; static EnableCompilerHwInfoConfig enableCompilerHwInfoConfigDG2; #endif diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 1969422788..2031addd5e 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/aub_mem_dump/aub_mem_dump.h" +#include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/constants.h" #include "shared/source/os_interface/hw_info_config.h" @@ -389,8 +390,20 @@ template <> uint64_t HwInfoConfigHw::getHostMemCapabilitiesValue() { return 0; } + +template <> +const char *L1CachePolicyHelper::getCachingPolicyOptions() { + return nullptr; +} + +template <> +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { + return 0u; +} + } // namespace NEO #include "shared/source/os_interface/hw_info_config.inl" template class NEO::HwInfoConfigHw; +template struct NEO::L1CachePolicyHelper; diff --git a/shared/test/unit_test/xe_hpg_core/dg2/CMakeLists.txt b/shared/test/unit_test/xe_hpg_core/dg2/CMakeLists.txt index fefb5a66c0..33332825b6 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/CMakeLists.txt +++ b/shared/test/unit_test/xe_hpg_core/dg2/CMakeLists.txt @@ -14,6 +14,7 @@ if(TESTS_DG2) ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tests_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/product_config_helper_tests_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy_tests_dg2 ) add_subdirectories() endif() diff --git a/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp new file mode 100644 index 0000000000..38ae18881f --- /dev/null +++ b/shared/test/unit_test/xe_hpg_core/dg2/cache_policy_tests_dg2.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_policy.h" +#include "shared/source/xe_hpg_core/hw_cmds_dg2.h" +#include "shared/test/common/helpers/debug_manager_state_restore.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" +#include "shared/test/unit_test/helpers/gtest_helpers.h" +#include "shared/test/unit_test/os_interface/hw_info_config_tests.h" + +using namespace NEO; + +DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbpPolicy) { + using GfxFamily = typename HwMapper::GfxFamily; + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); +} + +DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetCachingPolicyOptionsThenReturnCorrectValue) { + const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); +} \ No newline at end of file