Respect ForceAllResourcesUncached flag

Respect debug flag ForceAllResourcesUncached even when
Override L1 Policy flags are also set

Related-To: NEO-7003

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2022-08-12 12:23:39 +00:00
committed by Compute-Runtime-Automation
parent 025c3dd7a1
commit aa3a4765b9
17 changed files with 194 additions and 21 deletions

View File

@@ -2280,7 +2280,20 @@ HWTEST2_F(ModuleTranslationUnitTest, givenDebugFlagSetToWbWhenGetInternalOptions
EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("-cl-store-cache-default=7 -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);
} }
HWTEST2_F(ModuleTranslationUnitTest, givenAtLeastDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { HWTEST2_F(ModuleTranslationUnitTest, givenDebugFlagSetForceAllResourcesUncachedWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
DebugManager.flags.ForceAllResourcesUncached.set(true);
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=1 -cl-load-cache-default=1"), std::string::npos);
}
HWTEST2_F(ModuleTranslationUnitTest, givenAtLeastXeHpgCoreWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) {
auto pMockCompilerInterface = new MockCompilerInterface; auto pMockCompilerInterface = new MockCompilerInterface;
auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()]; auto &rootDeviceEnvironment = this->neoDevice->executionEnvironment->rootDeviceEnvironments[this->neoDevice->getRootDeviceIndex()];
rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface); rootDeviceEnvironment->compilerInterface.reset(pMockCompilerInterface);

View File

@@ -1760,7 +1760,16 @@ HWTEST2_F(ProgramTests, givenDebugFlagSetToWbWhenGetInternalOptionsThenCorrectBu
EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=7 -cl-load-cache-default=4")); EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=7 -cl-load-cache-default=4"));
} }
HWTEST2_F(ProgramTests, givenAtLeastDG2WhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) { HWTEST2_F(ProgramTests, givenDebugFlagSetForceAllResourcesUncachedWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
DebugManager.flags.ForceAllResourcesUncached.set(true);
MockProgram program(pContext, false, toClDeviceVector(*pClDevice));
auto internalOptions = program.getInternalOptions();
EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=1 -cl-load-cache-default=1"));
}
HWTEST2_F(ProgramTests, givenAtLeastXeHpgCoreWhenGetInternalOptionsThenCorrectBuildOptionIsSet, IsAtLeastXeHpgCore) {
MockProgram program(pContext, false, toClDeviceVector(*pClDevice)); MockProgram program(pContext, false, toClDeviceVector(*pClDevice));
auto internalOptions = program.getInternalOptions(); auto internalOptions = program.getInternalOptions();
EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=2 -cl-load-cache-default=4")); EXPECT_TRUE(CompilerOptions::contains(internalOptions, "-cl-store-cache-default=2 -cl-load-cache-default=4"));

View File

@@ -110,7 +110,13 @@ XE_HPC_CORETEST_F(CmdsProgrammingTestsXeHpcCore, givenL1CachingOverrideWhenState
EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(1u); DebugManager.flags.ForceStatelessL1CachingPolicy.set(2u);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);
EXPECT_EQ(2u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true); StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);

View File

@@ -110,7 +110,13 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL1CachingOverrideWhenStateBaseAddressIsP
EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(1u); DebugManager.flags.ForceStatelessL1CachingPolicy.set(2u);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);
EXPECT_EQ(2u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true); StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);

View File

@@ -110,7 +110,13 @@ XE_HPG_CORETEST_F(CmdsProgrammingTestsXeHpgCore, givenL1CachingOverrideWhenState
EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(0u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(1u); DebugManager.flags.ForceStatelessL1CachingPolicy.set(2u);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);
EXPECT_EQ(2u, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true); StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);

View File

@@ -19,7 +19,8 @@ void EncodeSurfaceState<Family>::encodeExtraCacheSettings(R_SURFACE_STATE *surfa
auto cachePolicy = static_cast<L1_CACHE_POLICY>(hwInfoConfig->getL1CachePolicy()); auto cachePolicy = static_cast<L1_CACHE_POLICY>(hwInfoConfig->getL1CachePolicy());
surfaceState->setL1CachePolicyL1CacheControl(cachePolicy); surfaceState->setL1CachePolicyL1CacheControl(cachePolicy);
if (DebugManager.flags.OverrideL1CacheControlInSurfaceState.get() != -1) { if (DebugManager.flags.OverrideL1CacheControlInSurfaceState.get() != -1 &&
DebugManager.flags.ForceAllResourcesUncached.get() == false) {
surfaceState->setL1CachePolicyL1CacheControl(static_cast<L1_CACHE_POLICY>(DebugManager.flags.OverrideL1CacheControlInSurfaceState.get())); surfaceState->setL1CachePolicyL1CacheControl(static_cast<L1_CACHE_POLICY>(DebugManager.flags.OverrideL1CacheControlInSurfaceState.get()));
} }
} }

View File

@@ -29,6 +29,7 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/cache_flush.inl ${CMAKE_CURRENT_SOURCE_DIR}/cache_flush.inl
${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cache_policy.h ${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}/cache_policy_bdw_and_later.inl
${CMAKE_CURRENT_SOURCE_DIR}/casts.h ${CMAKE_CURRENT_SOURCE_DIR}/casts.h
${CMAKE_CURRENT_SOURCE_DIR}/common_types.h ${CMAKE_CURRENT_SOURCE_DIR}/common_types.h

View File

@@ -23,16 +23,11 @@ struct L1CachePolicyHelper {
static const char *getCachingPolicyOptions(); static const char *getCachingPolicyOptions();
static uint32_t getDefaultL1CachePolicy() { static uint32_t getDefaultL1CachePolicy();
return 0u;
}
static uint32_t getL1CachePolicy() { static uint32_t getUncachedL1CachePolicy();
if (DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get() != -1) {
return DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get(); static uint32_t getL1CachePolicy();
}
return L1CachePolicyHelper<gfxProduct>::getDefaultL1CachePolicy();
}
}; };
} // namespace NEO } // namespace NEO

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/xe_hpg_core/hw_cmds.h"
namespace NEO {
template <PRODUCT_FAMILY gfxProduct>
uint32_t L1CachePolicyHelper<gfxProduct>::getL1CachePolicy() {
if (DebugManager.flags.ForceAllResourcesUncached.get()) {
return L1CachePolicyHelper<gfxProduct>::getUncachedL1CachePolicy();
}
if (DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get() != -1) {
return DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.get();
}
return L1CachePolicyHelper<gfxProduct>::getDefaultL1CachePolicy();
}
} // namespace NEO

View File

@@ -6,6 +6,7 @@
*/ */
#include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/cache_policy_base.inl"
namespace NEO { namespace NEO {
@@ -14,4 +15,14 @@ const char *L1CachePolicyHelper<gfxProduct>::getCachingPolicyOptions() {
return nullptr; return nullptr;
} }
template <PRODUCT_FAMILY gfxProduct>
uint32_t L1CachePolicyHelper<gfxProduct>::getDefaultL1CachePolicy() {
return 0u;
}
template <PRODUCT_FAMILY gfxProduct>
uint32_t L1CachePolicyHelper<gfxProduct>::getUncachedL1CachePolicy() {
return 1u;
}
} // namespace NEO } // namespace NEO

View File

@@ -6,6 +6,7 @@
*/ */
#include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/cache_policy_base.inl"
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
namespace NEO { namespace NEO {
@@ -16,15 +17,30 @@ const char *L1CachePolicyHelper<gfxProduct>::getCachingPolicyOptions() {
static constexpr const char *writeBackCachingPolicy = "-cl-store-cache-default=7 -cl-load-cache-default=4"; static constexpr const char *writeBackCachingPolicy = "-cl-store-cache-default=7 -cl-load-cache-default=4";
static constexpr const char *writeByPassCachingPolicy = "-cl-store-cache-default=2 -cl-load-cache-default=4"; static constexpr const char *writeByPassCachingPolicy = "-cl-store-cache-default=2 -cl-load-cache-default=4";
static constexpr const char *uncachedCachingPolicy = "-cl-store-cache-default=1 -cl-load-cache-default=1";
switch (L1CachePolicyHelper<gfxProduct>::getL1CachePolicy()) { switch (L1CachePolicyHelper<gfxProduct>::getL1CachePolicy()) {
case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP: case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP:
return writeByPassCachingPolicy; return writeByPassCachingPolicy;
case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB: case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB:
return writeBackCachingPolicy; return writeBackCachingPolicy;
case GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC:
return uncachedCachingPolicy;
default: default:
return nullptr; return nullptr;
} }
} }
template <PRODUCT_FAMILY gfxProduct>
uint32_t L1CachePolicyHelper<gfxProduct>::getDefaultL1CachePolicy() {
using GfxFamily = typename HwMapper<gfxProduct>::GfxFamily;
return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP;
}
template <PRODUCT_FAMILY gfxProduct>
uint32_t L1CachePolicyHelper<gfxProduct>::getUncachedL1CachePolicy() {
using GfxFamily = typename HwMapper<gfxProduct>::GfxFamily;
return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC;
}
} // namespace NEO } // namespace NEO

View File

@@ -11,7 +11,8 @@ void StateBaseAddressHelper<GfxFamily>::appendExtraCacheSettings(STATE_BASE_ADDR
auto cachePolicy = hwInfoConfig->getL1CachePolicy(); auto cachePolicy = hwInfoConfig->getL1CachePolicy();
stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast<typename STATE_BASE_ADDRESS::L1_CACHE_POLICY>(cachePolicy)); stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast<typename STATE_BASE_ADDRESS::L1_CACHE_POLICY>(cachePolicy));
if (DebugManager.flags.ForceStatelessL1CachingPolicy.get() != -1) { if (DebugManager.flags.ForceStatelessL1CachingPolicy.get() != -1 &&
DebugManager.flags.ForceAllResourcesUncached.get() == false) {
stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast<typename STATE_BASE_ADDRESS::L1_CACHE_POLICY>(DebugManager.flags.ForceStatelessL1CachingPolicy.get())); stateBaseAddress->setL1CachePolicyL1CacheControl(static_cast<typename STATE_BASE_ADDRESS::L1_CACHE_POLICY>(DebugManager.flags.ForceStatelessL1CachingPolicy.get()));
} }
} }

View File

@@ -411,6 +411,16 @@ bool HwInfoConfigHw<IGFX_UNKNOWN>::isPrefetcherDisablingInDirectSubmissionRequir
return true; return true;
} }
template <>
uint32_t L1CachePolicyHelper<IGFX_UNKNOWN>::getL1CachePolicy() {
return L1CachePolicyHelper<IGFX_UNKNOWN>::getDefaultL1CachePolicy();
}
template <>
uint32_t L1CachePolicyHelper<IGFX_UNKNOWN>::getUncachedL1CachePolicy() {
return 1u;
}
} // namespace NEO } // namespace NEO
#include "shared/source/os_interface/hw_info_config.inl" #include "shared/source/os_interface/hw_info_config.inl"

View File

@@ -45,5 +45,11 @@ HWTEST2_F(CommandEncoderXeHpgCorePlusTests, givenSpecifiedL1CacheControlWhenAppe
EncodeSurfaceState<FamilyType>::encodeBuffer(args); EncodeSurfaceState<FamilyType>::encodeBuffer(args);
EXPECT_EQ(static_cast<uint32_t>(l1CacheControl), rssCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(static_cast<uint32_t>(l1CacheControl), rssCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
EncodeSurfaceState<FamilyType>::encodeBuffer(args);
EXPECT_EQ(static_cast<uint32_t>(FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_UC), rssCmd.getL1CachePolicyL1CacheControl());
memoryManager->freeGraphicsMemory(allocation); memoryManager->freeGraphicsMemory(allocation);
} }

View File

@@ -16,12 +16,21 @@ HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAnd
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(), 0u); EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(), 0u);
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAndGetUncached1CachePolicyThenReturnOne, IsAtMostXeHpCore) {
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getUncachedL1CachePolicy(), 1u);
}
HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
using GfxFamily = typename HwMapper<productFamily>::GfxFamily; using GfxFamily = typename HwMapper<productFamily>::GfxFamily;
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP); EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP);
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2AndWriteBackPolicyWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetUncached1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
using GfxFamily = typename HwMapper<productFamily>::GfxFamily;
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getUncachedL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC);
}
HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndWriteBackPolicyWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
@@ -29,6 +38,15 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2AndWriteBackPolicyWhenGetL1CachePolic
EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndForceAllResourcesUncachedWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.ForceAllResourcesUncached.set(true);
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4);
const char *expectedStr = "-cl-store-cache-default=1 -cl-load-cache-default=1";
EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
}
HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenDebugFlagSetAndGetL1CachePolicyThenReturnCorrectValue, MatchAny) { HWTEST2_F(HwInfoConfigTest, givenL1CachePolicyHelperWhenDebugFlagSetAndGetL1CachePolicyThenReturnCorrectValue, MatchAny) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;

View File

@@ -284,6 +284,7 @@ HWTEST2_F(SBATest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSetti
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress; auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress;
auto expectedStateBaseAddress = FamilyType::cmdInitStateBaseAddress; auto expectedStateBaseAddress = FamilyType::cmdInitStateBaseAddress;
DebugManagerStateRestore restore;
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS))); EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
@@ -291,6 +292,35 @@ HWTEST2_F(SBATest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSetti
DebugManager.flags.ForceStatelessL1CachingPolicy.set(2); DebugManager.flags.ForceStatelessL1CachingPolicy.set(2);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo); StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS))); EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(0, memcmp(&stateBaseAddress, &expectedStateBaseAddress, sizeof(STATE_BASE_ADDRESS)));
}
HWTEST2_F(SBATest, givenStateBaseAddressAndDebugFlagSetWhenAppendExtraCacheSettingsThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) {
using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS;
auto stateBaseAddress = FamilyType::cmdInitStateBaseAddress;
DebugManagerStateRestore restore;
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, stateBaseAddress.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(2);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, stateBaseAddress.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(3);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WT, stateBaseAddress.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceStatelessL1CachingPolicy.set(4);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, stateBaseAddress.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendExtraCacheSettings(&stateBaseAddress, &hardwareInfo);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, stateBaseAddress.getL1CachePolicyL1CacheControl());
} }
HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) { HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePolicy, IsAtLeastXeHpgCore) {
@@ -331,10 +361,15 @@ HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingSbaThenProgramCorrectL1CachePol
}; };
for (const auto &input : testInputs) { for (const auto &input : testInputs) {
DebugManagerStateRestore restore;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true); StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);
EXPECT_EQ(input.cachePolicy, sbaCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(input.cachePolicy, sbaCmd.getL1CachePolicyL1CacheControl());
DebugManager.flags.ForceAllResourcesUncached.set(true);
StateBaseAddressHelper<FamilyType>::appendStateBaseAddressParameters(args, true);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, sbaCmd.getL1CachePolicyL1CacheControl());
} }
memoryManager->freeGraphicsMemory(allocation); memoryManager->freeGraphicsMemory(allocation);
} }
@@ -370,6 +405,7 @@ HWTEST2_F(SBATest, givenDebugFlagSetWhenAppendingRssThenProgramCorrectL1CachePol
{4, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WS}}; {4, FamilyType::RENDER_SURFACE_STATE::L1_CACHE_POLICY_WS}};
for (const auto &input : testInputs) { for (const auto &input : testInputs) {
DebugManagerStateRestore restore;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(input.option);
EncodeSurfaceState<FamilyType>::encodeBuffer(args); EncodeSurfaceState<FamilyType>::encodeBuffer(args);
EXPECT_EQ(input.cachePolicy, rssCmd.getL1CachePolicyL1CacheControl()); EXPECT_EQ(input.cachePolicy, rssCmd.getL1CachePolicyL1CacheControl());

View File

@@ -107,13 +107,13 @@ HWTEST2_F(HwInfoConfigTest, givenAtMostXeHPWhenGetCachingPolicyOptionsThenReturn
EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(), nullptr); EXPECT_EQ(compilerHwInfoConfig->getCachingPolicyOptions(), nullptr);
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteByPassPolicyOption, IsAtLeastXeHpgCore) {
auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4"; const char *expectedStr = "-cl-store-cache-default=2 -cl-load-cache-default=4";
EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetCachingPolicyOptionsThenReturnWriteBackPolicyOption, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreWhenGetCachingPolicyOptionsThenReturnWriteBackPolicyOption, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
@@ -122,9 +122,19 @@ HWTEST2_F(HwInfoConfigTest, givenAtLeastDG2WhenGetCachingPolicyOptionsThenReturn
EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr))); EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
} }
HWTEST2_F(HwInfoConfigTest, givenAtLeastXeHpgCoreAndDebugFlagSetForceAllResourcesUncachedWhenGetCachingPolicyOptionsThenReturnUncachedPolicyOption, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
DebugManager.flags.ForceAllResourcesUncached.set(true);
auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
const char *expectedStr = "-cl-store-cache-default=1 -cl-load-cache-default=1";
EXPECT_EQ(0, memcmp(compilerHwInfoConfig->getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
}
HWTEST2_F(HwInfoConfigTest, givenCachePolicyWithoutCorrespondingBuildOptionWhenGetCachingPolicyOptionsThenReturnNullptr, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenCachePolicyWithoutCorrespondingBuildOptionWhenGetCachingPolicyOptionsThenReturnNullptr, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(1); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(5);
auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily); auto compilerHwInfoConfig = CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
EXPECT_EQ(nullptr, compilerHwInfoConfig->getCachingPolicyOptions()); EXPECT_EQ(nullptr, compilerHwInfoConfig->getCachingPolicyOptions());
@@ -146,6 +156,9 @@ HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigAndDebugFlagWhenGetL1CachePolicyThe
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4); DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, hwInfoConfig->getL1CachePolicy()); EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WS, hwInfoConfig->getL1CachePolicy());
DebugManager.flags.ForceAllResourcesUncached.set(true);
EXPECT_EQ(FamilyType::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC, hwInfoConfig->getL1CachePolicy());
} }
HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass, IsAtLeastXeHpgCore) { HWTEST2_F(HwInfoConfigTest, givenHwInfoConfigWhenGetL1CachePolicyThenReturnWriteByPass, IsAtLeastXeHpgCore) {