Files
compute-runtime/shared/test/unit_test/helpers/cache_policy_tests.cpp
Warchulski, Jaroslaw 5ec9de90ee Cleanup includes 52
Cleaned up files:
level_zero/core/source/driver/driver.h
level_zero/tools/source/sysman/fabric_port/windows/os_fabric_port_imp.h
level_zero/tools/source/sysman/pci/os_pci.h
shared/source/debug_settings/debug_settings_manager.h
shared/source/gmm_helper/page_table_mngr.h
shared/source/gmm_helper/windows/gmm_memory_base.h
shared/source/kernel/kernel_arg_metadata.h
shared/test/common/libult/linux/drm_mock.h
shared/test/unit_test/fixtures/command_container_fixture.h
shared/test/unit_test/fixtures/product_config_fixture.h
shared/test/unit_test/helpers/simd_helper_tests_pvc_and_later.inl
shared/test/unit_test/os_interface/hw_info_config_tests.h

Related-To: NEO-5548

Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
2023-02-13 11:39:34 +01:00

74 lines
4.0 KiB
C++

/*
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/cache_policy.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/test_macros/test.h"
#include "shared/test/unit_test/os_interface/hw_info_config_tests.h"
using namespace NEO;
HWTEST2_F(ProductHelperTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAndGetDefaultL1CachePolicyThenReturnZero, IsAtMostXeHpCore) {
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), 0u);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), 0u);
}
HWTEST2_F(ProductHelperTest, givenL1CachePolicyHelperWhenUnsupportedL1PoliciesAndGetUncached1CachePolicyThenReturnOne, IsAtMostXeHpCore) {
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getUncachedL1CachePolicy(), 1u);
}
HWTEST2_F(ProductHelperTest, givenAtLeastXeHpgCoreWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
using GfxFamily = typename HwMapper<productFamily>::GfxFamily;
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP);
}
HWTEST2_F(ProductHelperTest, givenAtLeastXeHpgCoreWhenGetUncached1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
using GfxFamily = typename HwMapper<productFamily>::GfxFamily;
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getUncachedL1CachePolicy(), GfxFamily::STATE_BASE_ADDRESS::L1_CACHE_POLICY_UC);
}
HWTEST2_F(ProductHelperTest, givenAtLeastXeHpgCoreAndWriteBackPolicyWhenGetL1CachePolicyThenReturnCorrectValue, IsAtLeastXeHpgCore) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
const char *expectedStr = "-cl-store-cache-default=7 -cl-load-cache-default=4";
EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(false), expectedStr, strlen(expectedStr)));
EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(true), expectedStr, strlen(expectedStr)));
}
HWTEST2_F(ProductHelperTest, 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(false), expectedStr, strlen(expectedStr)));
EXPECT_EQ(0, memcmp(L1CachePolicyHelper<productFamily>::getCachingPolicyOptions(true), expectedStr, strlen(expectedStr)));
}
HWTEST2_F(ProductHelperTest, givenL1CachePolicyHelperWhenDebugFlagSetAndGetL1CachePolicyThenReturnCorrectValue, MatchAny) {
DebugManagerStateRestore restorer;
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(0);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), 0u);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), 0u);
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(2);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), 2u);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), 2u);
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(3);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), 3u);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), 3u);
DebugManager.flags.OverrideL1CachePolicyInSurfaceStateAndStateless.set(4);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(false), 4u);
EXPECT_EQ(L1CachePolicyHelper<productFamily>::getL1CachePolicy(true), 4u);
}