From 9a5e619c424e0342e62ed9152b3c2ae8b88a8cd3 Mon Sep 17 00:00:00 2001 From: Dominik Dabek Date: Fri, 22 Jul 2022 08:15:16 +0000 Subject: [PATCH] Change DG2 l1 cache policy to WB With compiler LSC WAs this gives better performance. Related-To: NEO-7003 Signed-off-by: Dominik Dabek --- .../unit_tests/sources/module/CMakeLists.txt | 2 + .../unit_tests/sources/module/test_module.cpp | 2 +- .../unit_tests/xe_hpg_core/dg2/CMakeLists.txt | 3 +- .../xe_hpg_core/dg2/test_module_dg2.cpp | 31 +++++++++ .../xe_hpg_core/test_module_xe_hpg_core.cpp | 2 +- .../test/unit_test/program/program_tests.cpp | 2 +- .../program/xe_hpg_core/CMakeLists.txt | 13 ++++ .../program/xe_hpg_core/dg2/CMakeLists.txt | 16 +++++ .../xe_hpg_core/dg2/program_tests_dg2.cpp | 22 +++++++ .../dg2/test_cmds_programming_dg2.cpp | 66 +++++++++---------- .../test_cmds_programming_xe_hpg_core.cpp | 10 +-- shared/source/helpers/CMakeLists.txt | 1 + shared/source/helpers/cache_policy.cpp | 3 +- shared/source/helpers/cache_policy.h | 12 +--- shared/source/helpers/cache_policy_base.inl | 25 +++++++ .../helpers/cache_policy_bdw_and_later.inl | 1 + .../helpers/cache_policy_dg2_and_later.inl | 1 + .../source/xe_hpg_core/enable_xe_hpg_core.cpp | 2 +- .../test/common/mocks/mock_hw_info_config.cpp | 5 ++ .../unit_test/helpers/cache_policy_tests.cpp | 4 +- .../unit_test/helpers/test_hw_info_config.cpp | 2 +- .../dg2/cache_policy_tests_dg2.cpp | 22 +++++-- 22 files changed, 181 insertions(+), 66 deletions(-) create mode 100644 level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp create mode 100644 opencl/test/unit_test/program/xe_hpg_core/CMakeLists.txt create mode 100644 opencl/test/unit_test/program/xe_hpg_core/dg2/CMakeLists.txt create mode 100644 opencl/test/unit_test/program/xe_hpg_core/dg2/program_tests_dg2.cpp create mode 100644 shared/source/helpers/cache_policy_base.inl diff --git a/level_zero/core/test/unit_tests/sources/module/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/module/CMakeLists.txt index b48722a225..ca039099fc 100644 --- a/level_zero/core/test/unit_tests/sources/module/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/sources/module/CMakeLists.txt @@ -9,3 +9,5 @@ target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_module_2.cpp ) + +add_subdirectories() \ No newline at end of file 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 e784803598..383514333f 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 @@ -2318,7 +2318,7 @@ HWTEST2_F(ModuleTranslationUnitTest, givenDebugFlagSetToWbWhenGetInternalOptions EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=7 -cl-load-cache-default=4"), std::string::npos); } -HWTEST2_F(ModuleTranslationUnitTest, givenAtLeastDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { +HWTEST2_F(ModuleTranslationUnitTest, givenAtLeastXeHpgWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { auto pMockCompilerInterface = new MockCompilerInterface; auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()]; rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface); diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt index 95cc240a8c..ac797aa8f8 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/CMakeLists.txt @@ -7,9 +7,10 @@ if(TESTS_DG2) target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt - ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdlist_dg2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_cmdqueue_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_module_dg2.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test_sampler_dg2.cpp ) add_subdirectories() endif() diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp new file mode 100644 index 0000000000..0f6667e530 --- /dev/null +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_module_dg2.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe_hpg_core/hw_cmds_dg2.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.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 { + +using ModuleTranslationUnitTest = Test; + +HWTEST_EXCLUDE_PRODUCT(ModuleTranslationUnitTest, givenAtLeastXeHpgWhenGetInternalOptionsThenCorrectBuildOptionIsSet_IsAtLeastXeHpgCore, IGFX_XE_HPG_CORE); +DG2TEST_F(ModuleTranslationUnitTest, givenDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet) { + 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=7 -cl-load-cache-default=4"), std::string::npos); +} + +} // namespace ult +} // namespace L0 \ No newline at end of file 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 57417fa9fa..14b91e002c 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 @@ -53,7 +53,7 @@ HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteByPassBuild 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); + EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=7 -cl-load-cache-default=4"), std::string::npos); } } // namespace ult diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index d3dc99e329..23d615b007 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -1787,7 +1787,7 @@ HWTEST2_F(ProgramTests, givenDebugFlagSetToWbWhenGetInternalOptionsThenCorrectBu EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=7 -cl-load-cache-default=4")); } -HWTEST2_F(ProgramTests, givenAtLeastDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { +HWTEST2_F(ProgramTests, givenAtLeastXeHpgWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { MockProgram program(pContext, false, toClDeviceVector(*pClDevice)); auto internalOptions = program.getInternalOptions(); EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=2 -cl-load-cache-default=4")); diff --git a/opencl/test/unit_test/program/xe_hpg_core/CMakeLists.txt b/opencl/test/unit_test/program/xe_hpg_core/CMakeLists.txt new file mode 100644 index 0000000000..4fcec0cf2f --- /dev/null +++ b/opencl/test/unit_test/program/xe_hpg_core/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_XE_HPG_CORE) + set(IGDRCL_SRCS_tests_program_xe_hpg_core + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ) + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_program_xe_hpg_core}) + add_subdirectories() +endif() diff --git a/opencl/test/unit_test/program/xe_hpg_core/dg2/CMakeLists.txt b/opencl/test/unit_test/program/xe_hpg_core/dg2/CMakeLists.txt new file mode 100644 index 0000000000..68764bfc87 --- /dev/null +++ b/opencl/test/unit_test/program/xe_hpg_core/dg2/CMakeLists.txt @@ -0,0 +1,16 @@ +# +# Copyright (C) 2022 Intel Corporation +# +# SPDX-License-Identifier: MIT +# + +if(TESTS_DG2) + set(IGDRCL_SRCS_tests_program_dg2 + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/program_tests_dg2.cpp + ) + target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_program_dg2}) + +endif() + +add_subdirectories() diff --git a/opencl/test/unit_test/program/xe_hpg_core/dg2/program_tests_dg2.cpp b/opencl/test/unit_test/program/xe_hpg_core/dg2/program_tests_dg2.cpp new file mode 100644 index 0000000000..c9f45c98ce --- /dev/null +++ b/opencl/test/unit_test/program/xe_hpg_core/dg2/program_tests_dg2.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/xe_hpg_core/hw_cmds_dg2.h" +#include "shared/test/common/test_macros/header/per_product_test_definitions.h" +#include "shared/test/common/test_macros/test.h" + +#include "opencl/test/unit_test/mocks/mock_context.h" +#include "opencl/test/unit_test/mocks/mock_program.h" +#include "opencl/test/unit_test/program/program_tests.h" +using namespace NEO; + +HWTEST_EXCLUDE_PRODUCT(ProgramTests, givenAtLeastXeHpgWhenGetInternalOptionsThenCorrectBuildOptionIsSet_IsAtLeastXeHpgCore, IGFX_XE_HPG_CORE); +DG2TEST_F(ProgramTests, givenDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet) { + MockProgram program(pContext, false, toClDeviceVector(*pClDevice)); + auto internalOptions = program.getInternalOptions(); + EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=7 -cl-load-cache-default=4")); +} 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 396875670b..33f315ad3d 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 @@ -21,6 +21,7 @@ using namespace NEO; using CmdsProgrammingTestsDg2 = UltCommandStreamReceiverTest; +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenL3ToL1DebugFlagWhenStatelessMocsIsProgrammedThenItHasL1CachingOn, IGFX_XE_HPG_CORE); DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgrammedThenItHasL1CachingOn) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; @@ -37,13 +38,14 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); - auto actualL1CachePolocy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); + auto actualL1CachePolicy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); - const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); + const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB; + EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolicy); } DG2TEST_F(CmdsProgrammingTestsDg2, givenSpecificProductFamilyWhenAppendingSbaThenProgramWtL1CachePolicy) { + auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); AllocationProperties properties(pDevice->getRootDeviceIndex(), 1, AllocationType::BUFFER, pDevice->getDeviceBitfield()); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); @@ -56,11 +58,12 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenSpecificProductFamilyWhenAppendingSbaThe pDevice->getRootDeviceEnvironment().getGmmHelper(), false, MemoryCompressionState::NotApplicable, true, false, 1u); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, sbaCmd.getL1CachePolicyL1CacheControl()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, sbaCmd.getL1CachePolicyL1CacheControl()); memoryManager->freeGraphicsMemory(allocation); } +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenL1CachingOverrideWhenStateBaseAddressIsProgrammedThenItMatchesTheOverrideValue, IGFX_XE_HPG_CORE); DG2TEST_F(CmdsProgrammingTestsDg2, givenL1CachingOverrideWhenStateBaseAddressIsProgrammedThenItMatchesTheOverrideValue) { DebugManagerStateRestore restorer; DebugManager.flags.ForceStatelessL1CachingPolicy.set(0u); @@ -89,7 +92,8 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL1CachingOverrideWhenStateBaseAddressIsP memoryManager->freeGraphicsMemory(allocation); } -DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) { +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenXeHpgCoreWhenAppendingRssThenProgramWBPL1CachePolicy, IGFX_XE_HPG_CORE); +DG2TEST_F(CmdsProgrammingTestsDg2, givenDG2whenAppendingRssThenProgramWBL1CachePolicy) { auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); size_t allocationSize = MemoryConstants::pageSize; AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::BUFFER, pDevice->getDeviceBitfield()); @@ -116,39 +120,10 @@ DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) EncodeSurfaceState::encodeBuffer(args); - EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, rssCmd.getL1CachePolicyL1CacheControl()); -} - -DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferConstPolicy) { - MockContext context; - const auto size = MemoryConstants::pageSize; - const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize); - const auto flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY; - - auto retVal = CL_SUCCESS; - auto buffer = std::unique_ptr(Buffer::create( - &context, - flags, - size, - ptr, - retVal)); - EXPECT_EQ(CL_SUCCESS, retVal); - - typename FamilyType::RENDER_SURFACE_STATE surfaceState = {}; - buffer->setArgStateful(&surfaceState, false, false, false, false, context.getDevice(0)->getDevice(), false, false); - - const auto expectedMocs = context.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); - const auto actualMocs = surfaceState.getMemoryObjectControlState(); - EXPECT_EQ(expectedMocs, actualMocs); - - auto actualL1CachePolocy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); - - const uint8_t expectedL1CachePolicy = FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); - - alignedFree(ptr); + EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, rssCmd.getL1CachePolicyL1CacheControl()); } +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferConstPolicy, IGFX_XE_HPG_CORE); DG2TEST_F(CmdsProgrammingTestsDg2, givenDG2WithBSteppingWhenFlushingTaskThenAdditionalStateBaseAddressCommandIsPresent) { auto &hwInfo = *pDevice->getRootDeviceEnvironment().getMutableHardwareInfo(); const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily); @@ -168,3 +143,22 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenDG2WithBSteppingWhenFlushingTaskThenAddi stateBaseAddressItor = find(stateBaseAddressItor, cmdList.end()); EXPECT_NE(cmdList.end(), stateBaseAddressItor); } + +HWTEST_EXCLUDE_PRODUCT(CmdsProgrammingTestsXeHpgCore, givenSpecificProductFamilyWhenAppendingSbaThenProgramWBPL1CachePolicy, IGFX_XE_HPG_CORE); +DG2TEST_F(CmdsProgrammingTestsDg2, givenDG2WhenAppendingSbaThenProgramWBL1CachePolicy) { + auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); + AllocationProperties properties(pDevice->getRootDeviceIndex(), 1, AllocationType::BUFFER, pDevice->getDeviceBitfield()); + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); + + IndirectHeap indirectHeap(allocation, 1); + DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); + auto sbaCmd = FamilyType::cmdInitStateBaseAddress; + + StateBaseAddressHelper::appendStateBaseAddressParameters(&sbaCmd, &indirectHeap, true, 0, + pDevice->getRootDeviceEnvironment().getGmmHelper(), false, + MemoryCompressionState::NotApplicable, true, false, 1u); + + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, sbaCmd.getL1CachePolicyL1CacheControl()); + + memoryManager->freeGraphicsMemory(allocation); +} diff --git a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp index eced76acac..d255563b9f 100644 --- a/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp +++ b/opencl/test/unit_test/xe_hpg_core/test_cmds_programming_xe_hpg_core.cpp @@ -37,10 +37,10 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenL3ToL1DebugFlagWhenStatele auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); - auto actualL1CachePolocy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); + auto actualL1CachePolicy = static_cast(stateBaseAddress->getL1CachePolicyL1CacheControl()); const uint8_t expectedL1CachePolicy = 0; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); + EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolicy); } XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenSpecificProductFamilyWhenAppendingSbaThenProgramWBPL1CachePolicy) { @@ -89,7 +89,7 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenL1CachingOverrideWhenState memoryManager->freeGraphicsMemory(allocation); } -XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, whenAppendingRssThenProgramWBPL1CachePolicy) { +XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenXeHpgCoreWhenAppendingRssThenProgramWBPL1CachePolicy) { auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); size_t allocationSize = MemoryConstants::pageSize; AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::BUFFER, pDevice->getDeviceBitfield()); @@ -141,10 +141,10 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenAlignedCacheableReadOnlyBu const auto actualMocs = surfaceState.getMemoryObjectControlState(); EXPECT_EQ(expectedMocs, actualMocs); - auto actualL1CachePolocy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); + auto actualL1CachePolicy = static_cast(surfaceState.getL1CachePolicyL1CacheControl()); const uint8_t expectedL1CachePolicy = 0; - EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolocy); + EXPECT_EQ(expectedL1CachePolicy, actualL1CachePolicy); alignedFree(ptr); } diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index d120700ad7..0f117483a8 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -29,6 +29,7 @@ set(NEO_CORE_HELPERS ${CMAKE_CURRENT_SOURCE_DIR}/cache_flush.inl ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h + ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy_base.inl ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy_bdw_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/casts.h ${CMAKE_CURRENT_SOURCE_DIR}/common_types.h diff --git a/shared/source/helpers/cache_policy.cpp b/shared/source/helpers/cache_policy.cpp index d7bb74e958..6d7acdf97a 100644 --- a/shared/source/helpers/cache_policy.cpp +++ b/shared/source/helpers/cache_policy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -8,6 +8,7 @@ #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/aligned_memory.h" +#include "shared/source/helpers/cache_policy_base.inl" #include "shared/source/memory_manager/graphics_allocation.h" namespace NEO { diff --git a/shared/source/helpers/cache_policy.h b/shared/source/helpers/cache_policy.h index 4c684beb78..77073195d3 100644 --- a/shared/source/helpers/cache_policy.h +++ b/shared/source/helpers/cache_policy.h @@ -20,19 +20,11 @@ bool isL3Capable(const GraphicsAllocation &graphicsAllocation); template struct L1CachePolicyHelper { - static const char *getCachingPolicyOptions(); - static uint32_t getDefaultL1CachePolicy() { - return 0u; - } + static uint32_t getDefaultL1CachePolicy(); - static uint32_t getL1CachePolicy() { - if (DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get() != -1) { - return DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get(); - } - return L1CachePolicyHelper::getDefaultL1CachePolicy(); - } + static uint32_t getL1CachePolicy(); }; } // namespace NEO diff --git a/shared/source/helpers/cache_policy_base.inl b/shared/source/helpers/cache_policy_base.inl new file mode 100644 index 0000000000..6f15c91de1 --- /dev/null +++ b/shared/source/helpers/cache_policy_base.inl @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/cache_policy.h" + +namespace NEO { + +template +uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { + return 0u; +} + +template +uint32_t L1CachePolicyHelper::getL1CachePolicy() { + if (DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get() != -1) { + return DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get(); + } + return L1CachePolicyHelper::getDefaultL1CachePolicy(); +} + +} // namespace NEO diff --git a/shared/source/helpers/cache_policy_bdw_and_later.inl b/shared/source/helpers/cache_policy_bdw_and_later.inl index a51cc498fa..a2862ba735 100644 --- a/shared/source/helpers/cache_policy_bdw_and_later.inl +++ b/shared/source/helpers/cache_policy_bdw_and_later.inl @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/cache_policy.h" +#include "shared/source/helpers/cache_policy_base.inl" namespace NEO { diff --git a/shared/source/helpers/cache_policy_dg2_and_later.inl b/shared/source/helpers/cache_policy_dg2_and_later.inl index f858daa4e3..467550ab74 100644 --- a/shared/source/helpers/cache_policy_dg2_and_later.inl +++ b/shared/source/helpers/cache_policy_dg2_and_later.inl @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/cache_policy.h" +#include "shared/source/helpers/cache_policy_base.inl" #include "shared/source/helpers/hw_info.h" namespace NEO { 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 a103b3ca4c..9664c0f45c 100644 --- a/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/enable_xe_hpg_core.cpp @@ -20,7 +20,7 @@ namespace NEO { template <> uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { using GfxFamily = HwMapper::GfxFamily; - return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; + return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB; } template struct L1CachePolicyHelper; diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 5406637509..d1dd6c40ab 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -406,6 +406,11 @@ uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy() { return 0u; } +template <> +uint32_t L1CachePolicyHelper::getL1CachePolicy() { + return L1CachePolicyHelper::getDefaultL1CachePolicy(); +} + } // namespace NEO #include "shared/source/os_interface/hw_info_config.inl" diff --git a/shared/test/unit_test/helpers/cache_policy_tests.cpp b/shared/test/unit_test/helpers/cache_policy_tests.cpp index 3a5cd3ecf5..f7f621f2d4 100644 --- a/shared/test/unit_test/helpers/cache_policy_tests.cpp +++ b/shared/test/unit_test/helpers/cache_policy_tests.cpp @@ -16,12 +16,12 @@ HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAnd EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), 0u); } -HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { +HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { using GfxFamily = typename HwMapper::GfxFamily; EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } -HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2AndWriteBackPolicyWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { +HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndWriteBackPolicyWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { DebugManagerStateRestore restorer; DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); 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 bd8a94b9bc..c6d4016df0 100644 --- a/shared/test/unit_test/helpers/test_hw_info_config.cpp +++ b/shared/test/unit_test/helpers/test_hw_info_config.cpp @@ -107,7 +107,7 @@ HWTEST2_F(HwInfoConfigTest, givenAtMostXeHPWhenGetCachingPolicyOptionsThenReturn EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(), nullptr); } -HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption, IsAtLeastXeHpgCore) { +HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption, IsAtLeastXeHpgCore) { auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4"; EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); 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 index 38ae18881f..8dc84961b7 100644 --- 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 @@ -6,6 +6,7 @@ */ #include "shared/source/helpers/cache_policy.h" +#include "shared/source/os_interface/hw_info_config.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" @@ -14,13 +15,22 @@ #include "shared/test/unit_test/os_interface/hw_info_config_tests.h" using namespace NEO; - -DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbpPolicy) { +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue_IsAtLeastXeHpgCore, IGFX_XE_HPG_CORE); +DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbPolicy) { using GfxFamily = typename HwMapper::GfxFamily; - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); } +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass_IsAtLeastXeHpgCore, IGFX_XE_HPG_CORE); +DG2TEST_F(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass) { + auto hwInfo = *defaultHwInfo; + auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); + + EXPECT_EQ(hwInfoConfig->getL1CachePolicy(), FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); +} + +HWTEST_EXCLUDE_PRODUCT(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption_IsAtLeastXeHpgCore, IGFX_XE_HPG_CORE); 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 + const char *expectedStr = "-cl-store-cache-default=7 -cl-load-cache-default=4"; + EXPECT_EQ(memcmp(L1CachePolicyHelper::getCachingPolicyOptions(), expectedStr, strlen(expectedStr)), 0); +}