From a72213943e0965775c099f598bdb0b3a42f84845 Mon Sep 17 00:00:00 2001 From: Dominik Dabek Date: Thu, 8 Sep 2022 11:11:31 +0000 Subject: [PATCH] Change DG2 l1 cache policy to WB With compiler LSC WAs this gives better performance. If debugger is active, policy will not be changed ie. will be WBP. Related-To: NEO-7003 Signed-off-by: Dominik Dabek --- .../xe_hpg_core/dg2/test_cmdqueue_dg2.cpp | 2 +- .../unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp | 2 +- .../xe_hpg_core/test_module_xe_hpg_core.cpp | 4 ++-- .../xe_hpg_core/dg2/test_cmds_programming_dg2.cpp | 8 ++++---- shared/source/xe_hpg_core/enable_xe_hpg_core.cpp | 5 ++++- .../unit_test/encoders/test_encode_states_dg2.cpp | 2 +- .../xe_hpg_core/dg2/cache_policy_tests_dg2.cpp | 14 +++++++++----- .../unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp | 2 +- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp index 51a73be725..1f90c3695f 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp @@ -62,7 +62,7 @@ HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenProgramStateBaseAddressCa ASSERT_NE(cmdList.end(), sbaItor); auto cmdSba = genCmdCast(*sbaItor); - EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmdSba->getL1CachePolicyL1CacheControl()); + EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, cmdSba->getL1CachePolicyL1CacheControl()); } { const_cast(device->getDeviceInfo()).debuggerActive = true; diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp index 58bf06ea85..89a1f7e2a5 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_kernel_dg2.cpp @@ -48,7 +48,7 @@ HWTEST2_F(KernelTestDG2, givenKernelImpWhenSetBufferSurfaceStateCalledThenProgra auto argInfo = kernelImp->getImmutableData()->getDescriptor().payloadMappings.explicitArgs[argIndex].as(); auto surfaceStateAddressRaw = ptrOffset(kernelImp->getSurfaceStateHeapData(), argInfo.bindful); auto surfaceStateAddress = reinterpret_cast(const_cast(surfaceStateAddressRaw)); - EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, surfaceStateAddress->getL1CachePolicyL1CacheControl()); + EXPECT_EQ(RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, surfaceStateAddress->getL1CachePolicyL1CacheControl()); const_cast(device->getDeviceInfo()).debuggerActive = true; kernelImp->setBufferSurfaceState(argIndex, devicePtr, gpuAlloc); 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..d7ac7228c3 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 @@ -46,14 +46,14 @@ HWTEST2_F(KernelPropertyTest, givenKernelExtendedPropertiesStructureWhenKernelPr EXPECT_FALSE(kernelExtendedProperties.fp64Flags & FP_ATOMIC_EXT_FLAG_LOCAL_MIN_MAX); } -HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteByPassBuildOptionIsSet, IsDG2) { +HWTEST2_F(KernelPropertyTest, givenDG2WhenGetInternalOptionsThenWriteBackBuildOptionIsSet, 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); + 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/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp b/opencl/test/unit_test/xe_hpg_core/dg2/test_cmds_programming_dg2.cpp index cbe3652dcf..1a7a19b7b7 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 @@ -37,7 +37,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra auto stateBaseAddress = static_cast(hwParserCsr.cmdStateBaseAddress); - EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); } DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagAndDebuggerActiveWhenStatelessMocsIsProgrammedThenItHasCorrectL1CachingOn) { @@ -60,7 +60,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagAndDebuggerActiveWhenStat EXPECT_EQ(stateBaseAddress->getL1CachePolicyL1CacheControl(), STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } -DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) { +DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBL1CachePolicyUnlessDebuggerIsActive) { auto memoryManager = pDevice->getExecutionEnvironment()->memoryManager.get(); size_t allocationSize = MemoryConstants::pageSize; AllocationProperties properties(pDevice->getRootDeviceIndex(), allocationSize, AllocationType::BUFFER, pDevice->getDeviceBitfield()); @@ -86,7 +86,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, whenAppendingRssThenProgramWBPL1CachePolicy) args.areMultipleSubDevicesInContext = true; EncodeSurfaceState::encodeBuffer(args); - EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP, rssCmd.getL1CachePolicyL1CacheControl()); + EXPECT_EQ(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB, rssCmd.getL1CachePolicyL1CacheControl()); args.isDebuggerActive = true; EncodeSurfaceState::encodeBuffer(args); @@ -115,7 +115,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenAlignedCacheableReadOnlyBufferThenChoseO const auto actualMocs = surfaceState.getMemoryObjectControlState(); EXPECT_EQ(expectedMocs, actualMocs); - EXPECT_EQ(surfaceState.getL1CachePolicyL1CacheControl(), FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WBP); + EXPECT_EQ(surfaceState.getL1CachePolicyL1CacheControl(), FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WB); alignedFree(ptr); } 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 6082655548..2a4af55bc4 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,10 @@ namespace NEO { template <> uint32_t L1CachePolicyHelper::getDefaultL1CachePolicy(bool isDebuggerActive) { using GfxFamily = HwMapper::GfxFamily; - return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP; + if (isDebuggerActive) { + 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/unit_test/encoders/test_encode_states_dg2.cpp b/shared/test/unit_test/encoders/test_encode_states_dg2.cpp index 566271131e..1c68c2f802 100644 --- a/shared/test/unit_test/encoders/test_encode_states_dg2.cpp +++ b/shared/test/unit_test/encoders/test_encode_states_dg2.cpp @@ -37,7 +37,7 @@ HWTEST2_F(CommandEncodeStatesDG2Test, givenCommandContainerWhenSetStateBaseAddre auto cmd = genCmdCast(*itorCmd); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmd->getL1CachePolicyL1CacheControl()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, cmd->getL1CachePolicyL1CacheControl()); } HWTEST2_F(CommandEncodeStatesDG2Test, givenCommandContainerAndDebuggerActiveWhenSetStateBaseAddressCalledThenCachePolicyIsWBP, IsDG2) { 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 e8d611d383..9a119194b2 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 @@ -17,13 +17,17 @@ using namespace NEO; DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetL1CachePolicyThenReturnWbPolicyUnlessDebuggerIsActive) { using GfxFamily = typename HwMapper::GfxFamily; - EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); + EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(false), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB); EXPECT_EQ(L1CachePolicyHelper::getL1CachePolicy(true), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); } DG2TEST_F(HwInfoConfigTest, givenDG2WhenGetCachingPolicyOptionsThenReturnCorrectValue) { - const char *writeByPassPolicyOptions = "-cl-store-cache-default=2 -cl-load-cache-default=4"; - - EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(false), writeByPassPolicyOptions, strlen(writeByPassPolicyOptions))); - EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(true), writeByPassPolicyOptions, strlen(writeByPassPolicyOptions))); + { + const char *writeBackPolicyOptions = "-cl-store-cache-default=7 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(false), writeBackPolicyOptions, strlen(writeBackPolicyOptions))); + } + { + const char *writeByPassPolicyOptions = "-cl-store-cache-default=2 -cl-load-cache-default=4"; + EXPECT_EQ(0, memcmp(L1CachePolicyHelper::getCachingPolicyOptions(true), writeByPassPolicyOptions, strlen(writeByPassPolicyOptions))); + } } \ No newline at end of file diff --git a/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp b/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp index 5687210211..1699036e79 100644 --- a/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp +++ b/shared/test/unit_test/xe_hpg_core/dg2/test_encode_dg2.cpp @@ -78,7 +78,7 @@ DG2TEST_F(Dg2SbaTest, givenSpecificProductFamilyWhenAppendingSbaThenProgramCorre false // isDebuggerActive }; StateBaseAddressHelper::appendStateBaseAddressParameters(args, true); - EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, sbaCmd.getL1CachePolicyL1CacheControl()); + EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, sbaCmd.getL1CachePolicyL1CacheControl()); args.isDebuggerActive = true; StateBaseAddressHelper::appendStateBaseAddressParameters(args, true);