Add template structs for L1 cache policy helper

Related-To: NEO-7003

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2022-07-14 10:37:55 +00:00
committed by Compute-Runtime-Automation
parent 8905fb0174
commit 9203f8787b
13 changed files with 73 additions and 4 deletions

View File

@ -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

View File

@ -39,7 +39,7 @@ DG2TEST_F(CmdsProgrammingTestsDg2, givenL3ToL1DebugFlagWhenStatelessMocsIsProgra
auto actualL1CachePolocy = static_cast<uint8_t>(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<uint8_t>(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);

View File

@ -16,14 +16,17 @@
namespace NEO {
#ifdef SUPPORT_ICLLP
template struct L1CachePolicyHelper<IGFX_ICELAKE_LP>;
static EnableGfxProductHw<IGFX_ICELAKE_LP> enableGfxProductHwICLLP;
static EnableCompilerHwInfoConfig<IGFX_ICELAKE_LP> enableCompilerHwInfoConfigICLLP;
#endif
#ifdef SUPPORT_LKF
template struct L1CachePolicyHelper<IGFX_LAKEFIELD>;
static EnableGfxProductHw<IGFX_LAKEFIELD> enableGfxProductHwLKF;
static EnableCompilerHwInfoConfig<IGFX_LAKEFIELD> enableCompilerHwInfoConfigLKF;
#endif
#ifdef SUPPORT_EHL
template struct L1CachePolicyHelper<IGFX_ELKHARTLAKE>;
static EnableGfxProductHw<IGFX_ELKHARTLAKE> enableGfxProductHwEHL;
static EnableCompilerHwInfoConfig<IGFX_ELKHARTLAKE> enableCompilerHwInfoConfigEHL;
#endif

View File

@ -16,28 +16,34 @@
namespace NEO {
#ifdef SUPPORT_TGLLP
template struct L1CachePolicyHelper<IGFX_TIGERLAKE_LP>;
static EnableGfxProductHw<IGFX_TIGERLAKE_LP> enableGfxProductHwTGLLP;
static EnableCompilerHwInfoConfig<IGFX_TIGERLAKE_LP> enableCompilerHwInfoConfigTGLLP;
#endif
#ifdef SUPPORT_DG1
template struct L1CachePolicyHelper<IGFX_DG1>;
static EnableGfxProductHw<IGFX_DG1> enableGfxProductHwDG1;
static EnableCompilerHwInfoConfig<IGFX_DG1> enableCompilerHwInfoConfigDG1;
#endif
#ifdef SUPPORT_RKL
template struct L1CachePolicyHelper<IGFX_ROCKETLAKE>;
static EnableGfxProductHw<IGFX_ROCKETLAKE> enableGfxProductHwRKL;
#include "shared/source/gen12lp/compiler_hw_info_config_rkl.inl"
static EnableCompilerHwInfoConfig<IGFX_ROCKETLAKE> enableCompilerHwInfoConfigRKL;
#endif
#ifdef SUPPORT_ADLS
template struct L1CachePolicyHelper<IGFX_ALDERLAKE_S>;
static EnableGfxProductHw<IGFX_ALDERLAKE_S> enableGfxProductHwADLS;
static EnableCompilerHwInfoConfig<IGFX_ALDERLAKE_S> enableCompilerHwInfoConfigADLS;
#endif
#ifdef SUPPORT_ADLP
template struct L1CachePolicyHelper<IGFX_ALDERLAKE_P>;
static EnableGfxProductHw<IGFX_ALDERLAKE_P> enableGfxProductHwADLP;
static EnableCompilerHwInfoConfig<IGFX_ALDERLAKE_P> enableCompilerHwInfoConfigADLP;
#endif
#ifdef SUPPORT_ADLN
template struct L1CachePolicyHelper<IGFX_ALDERLAKE_N>;
static EnableGfxProductHw<IGFX_ALDERLAKE_N> enableGfxProductHwADLN;
static EnableCompilerHwInfoConfig<IGFX_ALDERLAKE_N> enableCompilerHwInfoConfigADLN;
#endif

View File

@ -16,6 +16,7 @@
namespace NEO {
#ifdef SUPPORT_BDW
template struct L1CachePolicyHelper<IGFX_BROADWELL>;
static EnableGfxProductHw<IGFX_BROADWELL> enableGfxProductHwBDW;
#include "shared/source/gen8/compiler_hw_info_config_bdw.inl"

View File

@ -16,22 +16,27 @@
namespace NEO {
#ifdef SUPPORT_BXT
template struct L1CachePolicyHelper<IGFX_BROXTON>;
static EnableGfxProductHw<IGFX_BROXTON> enableGfxProductHwBXT;
static EnableCompilerHwInfoConfig<IGFX_BROXTON> enableCompilerHwInfoConfigBXT;
#endif
#ifdef SUPPORT_CFL
template struct L1CachePolicyHelper<IGFX_COFFEELAKE>;
static EnableGfxProductHw<IGFX_COFFEELAKE> enableGfxProductHwCFL;
static EnableCompilerHwInfoConfig<IGFX_COFFEELAKE> enableCompilerHwInfoConfigCFL;
#endif
#ifdef SUPPORT_GLK
template struct L1CachePolicyHelper<IGFX_GEMINILAKE>;
static EnableGfxProductHw<IGFX_GEMINILAKE> enableGfxProductHwGLK;
static EnableCompilerHwInfoConfig<IGFX_GEMINILAKE> enableCompilerHwInfoConfigGLK;
#endif
#ifdef SUPPORT_KBL
template struct L1CachePolicyHelper<IGFX_KABYLAKE>;
static EnableGfxProductHw<IGFX_KABYLAKE> enableGfxProductHwKBL;
static EnableCompilerHwInfoConfig<IGFX_KABYLAKE> enableCompilerHwInfoConfigKBL;
#endif
#ifdef SUPPORT_SKL
template struct L1CachePolicyHelper<IGFX_SKYLAKE>;
static EnableGfxProductHw<IGFX_SKYLAKE> enableGfxProductHwSKL;
static EnableCompilerHwInfoConfig<IGFX_SKYLAKE> enableCompilerHwInfoConfigSKL;
#endif

View File

@ -24,7 +24,7 @@ struct L1CachePolicyHelper {
static const char *getCachingPolicyOptions();
static uint32_t getDefaultL1CachePolicy() {
return 0;
return 0u;
}
static uint32_t getL1CachePolicy() {

View File

@ -16,6 +16,7 @@
namespace NEO {
#ifdef SUPPORT_XE_HP_SDV
template struct L1CachePolicyHelper<IGFX_XE_HP_SDV>;
static EnableGfxProductHw<IGFX_XE_HP_SDV> enableGfxProductHwXEHP;
static EnableCompilerHwInfoConfig<IGFX_XE_HP_SDV> enableCompilerHwInfoConfigXEHP;
#endif

View File

@ -19,6 +19,7 @@ namespace NEO {
static EnableGfxProductHw<IGFX_PVC> enableGfxProductHwPVC;
#include "shared/source/xe_hpc_core/compiler_hw_info_config_pvc.inl"
template struct L1CachePolicyHelper<IGFX_PVC>;
static EnableCompilerHwInfoConfig<IGFX_PVC> enableCompilerHwInfoConfigPVC;
#endif

View File

@ -22,6 +22,7 @@ uint32_t L1CachePolicyHelper<IGFX_DG2>::getDefaultL1CachePolicy() {
return GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP;
}
template struct L1CachePolicyHelper<IGFX_DG2>;
static EnableGfxProductHw<IGFX_DG2> enableGfxProductHwDG2;
static EnableCompilerHwInfoConfig<IGFX_DG2> enableCompilerHwInfoConfigDG2;
#endif

View File

@ -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<IGFX_UNKNOWN>::getHostMemCapabilitiesValue() {
return 0;
}
template <>
const char *L1CachePolicyHelper<IGFX_UNKNOWN>::getCachingPolicyOptions() {
return nullptr;
}
template <>
uint32_t L1CachePolicyHelper<IGFX_UNKNOWN>::getDefaultL1CachePolicy() {
return 0u;
}
} // namespace NEO
#include "shared/source/os_interface/hw_info_config.inl"
template class NEO::HwInfoConfigHw<IGFX_UNKNOWN>;
template struct NEO::L1CachePolicyHelper<IGFX_UNKNOWN>;

View File

@ -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()

View File

@ -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<IGFX_DG2>::GfxFamily;
EXPECT_EQ(L1CachePolicyHelper<IGFX_DG2>::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<IGFX_DG2>::getCachingPolicyOptions(), expectedStr, strlen(expectedStr)));
}