Skip to content

Commit 8363740

Browse files
performance: Cache timestamps on CPU
Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent c90f3fc commit 8363740

File tree

13 files changed

+35
-33
lines changed

13 files changed

+35
-33
lines changed

shared/source/os_interface/linux/drm_memory_manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ inline std::unique_ptr<Gmm> DrmMemoryManager::makeGmmIfSingleHandle(const Alloca
19801980
gmmRequirements.allowLargePages = true;
19811981
gmmRequirements.preferCompressed = allocationData.flags.preferCompressed;
19821982

1983-
if (productHelper.overrideAllocationCacheable(allocationData)) {
1983+
if (productHelper.overrideAllocationCpuCacheable(allocationData)) {
19841984
gmmRequirements.overriderCacheable.enableOverride = true;
19851985
gmmRequirements.overriderCacheable.value = true;
19861986
}

shared/source/os_interface/product_helper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class ProductHelper {
196196
virtual uint32_t getMaxNumSamplers() const = 0;
197197
virtual uint32_t getCommandBuffersPreallocatedPerCommandQueue() const = 0;
198198
virtual uint32_t getInternalHeapsPreallocated() const = 0;
199-
virtual bool overrideAllocationCacheable(const AllocationData &allocationData) const = 0;
199+
virtual bool overrideAllocationCpuCacheable(const AllocationData &allocationData) const = 0;
200200
virtual bool is2MBLocalMemAlignmentEnabled() const = 0;
201201

202202
virtual bool getFrontEndPropertyScratchSizeSupport() const = 0;

shared/source/os_interface/product_helper.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ uint64_t ProductHelperHw<gfxProduct>::getDeviceMemoryMaxBandWidthInBytesPerSecon
219219
}
220220

221221
template <PRODUCT_FAMILY gfxProduct>
222-
bool ProductHelperHw<gfxProduct>::overrideAllocationCacheable(const AllocationData &allocationData) const {
222+
bool ProductHelperHw<gfxProduct>::overrideAllocationCpuCacheable(const AllocationData &allocationData) const {
223223
return false;
224224
}
225225

shared/source/os_interface/product_helper_hw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class ProductHelperHw : public ProductHelper {
137137
uint32_t getMaxNumSamplers() const override;
138138
uint32_t getCommandBuffersPreallocatedPerCommandQueue() const override;
139139
uint32_t getInternalHeapsPreallocated() const override;
140-
bool overrideAllocationCacheable(const AllocationData &allocationData) const override;
140+
bool overrideAllocationCpuCacheable(const AllocationData &allocationData) const override;
141141
bool is2MBLocalMemAlignmentEnabled() const override;
142142

143143
bool getFrontEndPropertyScratchSizeSupport() const override;

shared/source/os_interface/windows/wddm_memory_manager.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC
234234
GmmRequirements gmmRequirements{};
235235
gmmRequirements.allowLargePages = allowLargePages;
236236
gmmRequirements.preferCompressed = allocationData.flags.preferCompressed;
237-
if (productHelper.overrideAllocationCacheable(allocationData)) {
237+
if (productHelper.overrideAllocationCpuCacheable(allocationData)) {
238238
gmmRequirements.overriderCacheable.enableOverride = true;
239239
gmmRequirements.overriderCacheable.value = true;
240240
}
@@ -464,7 +464,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co
464464
GmmRequirements gmmRequirements{};
465465
gmmRequirements.allowLargePages = true;
466466
gmmRequirements.preferCompressed = false;
467-
if (productHelper.overrideAllocationCacheable(allocationData)) {
467+
if (productHelper.overrideAllocationCpuCacheable(allocationData)) {
468468
gmmRequirements.overriderCacheable.enableOverride = true;
469469
gmmRequirements.overriderCacheable.value = true;
470470
}

shared/source/xe2_hpg_core/lnl/os_agnostic_product_helper_lnl.inl

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
namespace NEO {
1313

1414
template <>
15-
bool ProductHelperHw<gfxProduct>::overrideAllocationCacheable(const AllocationData &allocationData) const {
16-
return allocationData.type == AllocationType::commandBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type);
15+
bool ProductHelperHw<gfxProduct>::overrideAllocationCpuCacheable(const AllocationData &allocationData) const {
16+
return allocationData.type == AllocationType::commandBuffer || allocationData.type == AllocationType::timestampPacketTagBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type);
1717
}
1818

1919
template <>

shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
namespace NEO {
1111

1212
template <>
13-
bool ProductHelperHw<gfxProduct>::overrideAllocationCacheable(const AllocationData &allocationData) const {
14-
return allocationData.type == AllocationType::commandBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type);
13+
bool ProductHelperHw<gfxProduct>::overrideAllocationCpuCacheable(const AllocationData &allocationData) const {
14+
return allocationData.type == AllocationType::commandBuffer || allocationData.type == AllocationType::timestampPacketTagBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type);
1515
}
1616

1717
template <>

shared/source/xe_hpg_core/xe_lpg/os_agnostic_product_helper_xe_lpg.inl

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool ProductHelperHw<gfxProduct>::isDeviceUsmPoolAllocatorSupported() const {
7373
}
7474

7575
template <>
76-
bool ProductHelperHw<gfxProduct>::overrideAllocationCacheable(const AllocationData &allocationData) const {
76+
bool ProductHelperHw<gfxProduct>::overrideAllocationCpuCacheable(const AllocationData &allocationData) const {
7777
return allocationData.type == AllocationType::commandBuffer;
7878
}
7979

shared/test/common/mocks/mock_product_helper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct MockProductHelper : ProductHelperHw<IGFX_UNKNOWN> {
1717
MockProductHelper() = default;
1818

1919
ADDMETHOD_CONST_NOBASE(is48bResourceNeededForRayTracing, bool, true, ());
20-
ADDMETHOD_CONST_NOBASE(overrideAllocationCacheable, bool, false, (const AllocationData &allocationData));
20+
ADDMETHOD_CONST_NOBASE(overrideAllocationCpuCacheable, bool, false, (const AllocationData &allocationData));
2121
ADDMETHOD_NOBASE(configureHwInfoWddm, int, 0, (const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment));
2222
ADDMETHOD_CONST_NOBASE(supportReadOnlyAllocations, bool, false, ());
2323
ADDMETHOD_CONST_NOBASE(isBlitCopyRequiredForLocalMemory, bool, true, (const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation));

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2024 Intel Corporation
2+
* Copyright (C) 2022-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -142,11 +142,11 @@ TEST_F(WddmMemoryManagerTests, GivenNotCompressedAndNotLockableAllocationTypeWhe
142142
memoryManager->freeGraphicsMemory(graphicsAllocation);
143143
}
144144

145-
TEST_F(WddmMemoryManagerTests, GivenOverrideAllocationCacheableWhenAllocateUsingKmdAndMapToCpuVaThenOverrideAllocationCacheable) {
145+
TEST_F(WddmMemoryManagerTests, GivenoverrideAllocationCpuCacheableWhenAllocateUsingKmdAndMapToCpuVaThenoverrideAllocationCpuCacheable) {
146146
NEO::AllocationData allocData = {};
147147
allocData.type = NEO::AllocationType::commandBuffer;
148148
auto mockProductHelper = std::make_unique<MockProductHelper>();
149-
mockProductHelper->overrideAllocationCacheableResult = true;
149+
mockProductHelper->overrideAllocationCpuCacheableResult = true;
150150
executionEnvironment->rootDeviceEnvironments[0]->productHelper.reset(mockProductHelper.release());
151151

152152
memoryManager->callBaseAllocateGraphicsMemoryUsingKmdAndMapItToCpuVA = true;

shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ LNLTEST_F(LnlProductHelper, givenProductHelperWhenCallIsCachingOnCpuAvailableThe
108108
EXPECT_FALSE(productHelper->isCachingOnCpuAvailable());
109109
}
110110

111-
LNLTEST_F(LnlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) {
111+
LNLTEST_F(LnlProductHelper, givenProductHelperWhenCheckoverrideAllocationCpuCacheableThenTrueIsReturnedForCommandBuffer) {
112112
AllocationData allocationData{};
113113
allocationData.type = AllocationType::commandBuffer;
114-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
114+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
115115

116116
allocationData.type = AllocationType::buffer;
117-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
117+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
118118
}
119119

120120
LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideCacheable) {
@@ -123,7 +123,7 @@ LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
123123

124124
AllocationData allocationData{};
125125
allocationData.type = AllocationType::externalHostPtr;
126-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
126+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
127127

128128
debugManager.flags.AllowDcFlush.set(0);
129129

@@ -132,7 +132,8 @@ LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
132132
allocationData.type = allocationType;
133133
switch (allocationData.type) {
134134
case AllocationType::commandBuffer:
135-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
135+
case AllocationType::timestampPacketTagBuffer:
136+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
136137
break;
137138
case AllocationType::externalHostPtr:
138139
case AllocationType::bufferHostMemory:
@@ -141,11 +142,11 @@ LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
141142
case AllocationType::svmZeroCopy:
142143
case AllocationType::internalHostMemory:
143144
case AllocationType::printfSurface:
144-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
145+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
145146
EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
146147
break;
147148
default:
148-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
149+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
149150
EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
150151
break;
151152
}

shared/test/unit_test/xe3_core/ptl/product_helper_tests_ptl.cpp

+8-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckDirectSubmissionSupported
4646
EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper));
4747
}
4848

49-
PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) {
49+
PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckoverrideAllocationCpuCacheableThenTrueIsReturnedForCommandBuffer) {
5050
AllocationData allocationData{};
5151
allocationData.type = AllocationType::commandBuffer;
52-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
52+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
5353

5454
allocationData.type = AllocationType::buffer;
55-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
55+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
5656
}
5757

5858
PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideCacheable) {
@@ -61,7 +61,7 @@ PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
6161

6262
AllocationData allocationData{};
6363
allocationData.type = AllocationType::externalHostPtr;
64-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
64+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
6565

6666
debugManager.flags.AllowDcFlush.set(0);
6767

@@ -70,7 +70,8 @@ PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
7070
allocationData.type = allocationType;
7171
switch (allocationData.type) {
7272
case AllocationType::commandBuffer:
73-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
73+
case AllocationType::timestampPacketTagBuffer:
74+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
7475
break;
7576
case AllocationType::externalHostPtr:
7677
case AllocationType::bufferHostMemory:
@@ -79,11 +80,11 @@ PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
7980
case AllocationType::svmZeroCopy:
8081
case AllocationType::internalHostMemory:
8182
case AllocationType::printfSurface:
82-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
83+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
8384
EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
8485
break;
8586
default:
86-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
87+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
8788
EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
8889
break;
8990
}

shared/test/unit_test/xe_hpg_core/mtl/product_helper_tests_mtl.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2024 Intel Corporation
2+
* Copyright (C) 2022-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -72,11 +72,11 @@ MTLTEST_F(MtlProductHelper, givenMtlWithoutHwIpVersionInHwInfoWhenGettingIpVersi
7272
EXPECT_EQ(compilerProductHelper->getDefaultHwIpVersion(), compilerProductHelper->getHwIpVersion(hwInfo));
7373
}
7474

75-
MTLTEST_F(MtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) {
75+
MTLTEST_F(MtlProductHelper, givenProductHelperWhenCheckoverrideAllocationCpuCacheableThenTrueIsReturnedForCommandBuffer) {
7676
AllocationData allocationData{};
7777
allocationData.type = AllocationType::commandBuffer;
78-
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
78+
EXPECT_TRUE(productHelper->overrideAllocationCpuCacheable(allocationData));
7979

8080
allocationData.type = AllocationType::buffer;
81-
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
81+
EXPECT_FALSE(productHelper->overrideAllocationCpuCacheable(allocationData));
8282
}

0 commit comments

Comments
 (0)