Skip to content

Commit 5f22e9e

Browse files
fix: don't set Cacheable on xe_hp and later
Related-To: NEO-7194 Signed-off-by: Cencelewska, Katarzyna <[email protected]>
1 parent 813f928 commit 5f22e9e

File tree

9 files changed

+39
-10
lines changed

9 files changed

+39
-10
lines changed

opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,10 +1853,11 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor
18531853
memoryManager64k.freeGraphicsMemory(galloc);
18541854
}
18551855

1856-
TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThan64kbThenGraphicsAllocationsHas64kbAlignedUnderlyingSize) {
1856+
HWTEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocationIsCreatedWithSizeSmallerThan64kbThenGraphicsAllocationsHas64kbAlignedUnderlyingSize) {
18571857
DebugManagerStateRestore dbgRestore;
18581858
wddm->init();
18591859
DebugManager.flags.Enable64kbpages.set(true);
1860+
DebugManager.flags.EnableCpuCacheForResources.set(0);
18601861
MockWddmMemoryManager memoryManager(true, false, *executionEnvironment);
18611862
AllocationData allocationData;
18621863
allocationData.size = 1u;
@@ -1866,7 +1867,8 @@ TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocation
18661867
EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation->getUnderlyingBufferSize());
18671868
EXPECT_NE(0llu, graphicsAllocation->getGpuAddress());
18681869
EXPECT_NE(nullptr, graphicsAllocation->getUnderlyingBuffer());
1869-
EXPECT_TRUE(graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable);
1870+
auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getHelper<GfxCoreHelper>();
1871+
EXPECT_EQ(gfxCoreHelper.isCachingOnCpuAvailable(), graphicsAllocation->getDefaultGmm()->resourceParams.Flags.Info.Cacheable);
18701872

18711873
memoryManager.freeGraphicsMemory(graphicsAllocation);
18721874
}

shared/source/gmm_helper/cache_settings_helper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "shared/source/gmm_helper/cache_settings_helper.h"
99

1010
#include "shared/source/debug_settings/debug_settings_manager.h"
11+
#include "shared/source/helpers/gfx_core_helper.h"
1112
#include "shared/source/helpers/hw_info.h"
1213
#include "shared/source/memory_manager/allocation_type.h"
1314
#include "shared/source/os_interface/product_helper.h"
@@ -28,11 +29,12 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType
2829
}
2930
}
3031

31-
bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType) {
32+
bool CacheSettingsHelper::isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const GfxCoreHelper &gfxCoreHelper) {
33+
bool isCachingOnCpuAvailable = gfxCoreHelper.isCachingOnCpuAvailable();
3234
if (DebugManager.flags.EnableCpuCacheForResources.get()) {
33-
return !CacheSettingsHelper::isUncachedType(gmmResourceUsageType);
35+
isCachingOnCpuAvailable = true;
3436
}
35-
return false;
37+
return isCachingOnCpuAvailable && !CacheSettingsHelper::isUncachedType(gmmResourceUsageType);
3638
}
3739

3840
GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) {

shared/source/gmm_helper/cache_settings_helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace NEO {
1616
enum class AllocationType;
1717
struct HardwareInfo;
1818
class ProductHelper;
19+
class GfxCoreHelper;
1920

2021
struct CacheSettingsHelper {
2122
static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper);
@@ -26,7 +27,7 @@ struct CacheSettingsHelper {
2627
(gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
2728
}
2829

29-
static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType);
30+
static bool isResourceCacheableOnCpu(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType, const GfxCoreHelper &gfxCoreHelper);
3031

3132
protected:
3233
static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper);

shared/source/gmm_helper/gmm.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Gmm::Gmm(GmmHelper *gmmHelper, const void *alignedPtr, size_t alignedSize, size_
3939

4040
resourceParams.Usage = gmmResourceUsage;
4141
resourceParams.Flags.Info.Linear = 1;
42-
resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage);
42+
auto &gfxCoreHelper = gmmHelper->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
43+
resourceParams.Flags.Info.Cacheable = CacheSettingsHelper::isResourceCacheableOnCpu(gmmResourceUsage, gfxCoreHelper);
4344
resourceParams.Flags.Gpu.Texture = 1;
4445

4546
if (alignedPtr) {

shared/source/helpers/gfx_core_helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class GfxCoreHelper {
171171
virtual bool isTimestampShiftRequired() const = 0;
172172
virtual bool isRelaxedOrderingSupported() const = 0;
173173
static bool isWorkaroundRequired(uint32_t lowestSteppingWithBug, uint32_t steppingWithFix, const HardwareInfo &hwInfo, const ProductHelper &productHelper);
174-
174+
virtual bool isCachingOnCpuAvailable() const = 0;
175175
virtual ~GfxCoreHelper() = default;
176176

177177
protected:
@@ -386,6 +386,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
386386
bool isChipsetUniqueUUIDSupported() const override;
387387
bool isTimestampShiftRequired() const override;
388388
bool isRelaxedOrderingSupported() const override;
389+
bool isCachingOnCpuAvailable() const override;
389390

390391
~GfxCoreHelperHw() override = default;
391392

shared/source/helpers/gfx_core_helper_base.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,9 @@ template <typename GfxFamily>
695695
uint32_t GfxCoreHelperHw<GfxFamily>::getMinimalGrfSize() const {
696696
return 128u;
697697
}
698+
699+
template <typename GfxFamily>
700+
bool GfxCoreHelperHw<GfxFamily>::isCachingOnCpuAvailable() const {
701+
return true;
702+
}
698703
} // namespace NEO

shared/source/helpers/gfx_core_helper_xehp_and_later.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,9 @@ bool GfxCoreHelperHw<Family>::isChipsetUniqueUUIDSupported() const {
232232
return true;
233233
}
234234

235+
template <>
236+
bool GfxCoreHelperHw<Family>::isCachingOnCpuAvailable() const {
237+
return false;
238+
}
239+
235240
} // namespace NEO

shared/test/unit_test/gmm_helper/gmm_tests.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "shared/source/gmm_helper/gmm.h"
99
#include "shared/source/gmm_helper/gmm_helper.h"
10+
#include "shared/source/helpers/gfx_core_helper.h"
1011
#include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h"
1112
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1213
#include "shared/test/common/mocks/mock_execution_environment.h"
@@ -28,16 +29,17 @@ TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCa
2829
}
2930
}
3031

31-
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCacheForResourcesNotSetThenFlagCachcableIsAlwaysFalse) {
32+
TEST_F(GmmTests, givenResourceUsageTypesCacheableWhenCreateGmmAndFlagEnableCpuCacheForResourcesNotSetThenFlagCachcableIsRelatedToValueFromHelperIsCachingOnCpuAvailable) {
3233
DebugManagerStateRestore restore;
3334
DebugManager.flags.EnableCpuCacheForResources.set(0);
3435
StorageInfo storageInfo{};
36+
auto &gfxCoreHelper = getGmmHelper()->getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
3537
for (auto resourceUsageType : {GMM_RESOURCE_USAGE_OCL_IMAGE,
3638
GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER,
3739
GMM_RESOURCE_USAGE_OCL_BUFFER_CONST,
3840
GMM_RESOURCE_USAGE_OCL_BUFFER}) {
3941
auto gmm = std::make_unique<Gmm>(getGmmHelper(), nullptr, 0, 0, resourceUsageType, false, storageInfo, false);
40-
EXPECT_FALSE(gmm->resourceParams.Flags.Info.Cacheable);
42+
EXPECT_EQ(gfxCoreHelper.isCachingOnCpuAvailable(), gmm->resourceParams.Flags.Info.Cacheable);
4143
}
4244
}
4345

shared/test/unit_test/helpers/gfx_core_helper_tests.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,3 +1585,13 @@ HWTEST_F(GfxCoreHelperTest, givenNumGrfAndSimdSizeWhenAdjustingMaxWorkGroupSizeT
15851585
numGrfRequired = GrfConfig::DefaultGrfNumber;
15861586
EXPECT_EQ(defaultMaxGroupSize, gfxCoreHelper.adjustMaxWorkGroupSize(numGrfRequired, simdSize, defaultMaxGroupSize));
15871587
}
1588+
1589+
HWTEST2_F(GfxCoreHelperTest, givenAtLeastXeHpWhenCheckIsCachingOnCpuAvailableThenAlwaysFalse, IsAtLeastXeHpCore) {
1590+
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
1591+
EXPECT_FALSE(gfxCoreHelper.isCachingOnCpuAvailable());
1592+
}
1593+
1594+
HWTEST2_F(GfxCoreHelperTest, givenAtMostGen12lpWhenCheckIsCachingOnCpuAvailableThenAlwaysTrue, IsAtMostGen12lp) {
1595+
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
1596+
EXPECT_TRUE(gfxCoreHelper.isCachingOnCpuAvailable());
1597+
}

0 commit comments

Comments
 (0)