Skip to content

Commit e644b09

Browse files
performance: override allocation caching on integrated platforms
Related-To: NEO-9421 Signed-off-by: Tomasz Biernacik <tomasz.biernacik@intel.com>
1 parent 8e251ed commit e644b09

File tree

3 files changed

+67
-9
lines changed

3 files changed

+67
-9
lines changed

shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
namespace NEO {
1111

12+
template <>
13+
bool ProductHelperHw<gfxProduct>::overrideAllocationCacheable(const AllocationData &allocationData) const {
14+
return allocationData.type == AllocationType::commandBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type);
15+
}
16+
1217
template <>
1318
std::optional<aub_stream::ProductFamily> ProductHelperHw<gfxProduct>::getAubStreamProductFamily() const {
1419
return aub_stream::ProductFamily::Ptl;

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,24 @@ LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC
130130
for (auto i = 0; i < static_cast<int>(AllocationType::count); ++i) {
131131
auto allocationType = static_cast<AllocationType>(i);
132132
allocationData.type = allocationType;
133-
if (allocationType == AllocationType::externalHostPtr ||
134-
allocationType == AllocationType::bufferHostMemory ||
135-
allocationType == AllocationType::mapAllocation ||
136-
allocationType == AllocationType::svmCpu ||
137-
allocationType == AllocationType::svmZeroCopy ||
138-
allocationType == AllocationType::internalHostMemory ||
139-
allocationType == AllocationType::commandBuffer ||
140-
allocationType == AllocationType::printfSurface) {
133+
switch (allocationData.type) {
134+
case AllocationType::commandBuffer:
141135
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
142-
} else {
136+
break;
137+
case AllocationType::externalHostPtr:
138+
case AllocationType::bufferHostMemory:
139+
case AllocationType::mapAllocation:
140+
case AllocationType::svmCpu:
141+
case AllocationType::svmZeroCopy:
142+
case AllocationType::internalHostMemory:
143+
case AllocationType::printfSurface:
144+
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
145+
EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
146+
break;
147+
default:
143148
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
149+
EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
150+
break;
144151
}
145152
}
146153
}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77

88
#include "shared/source/helpers/compiler_product_helper.h"
9+
#include "shared/source/memory_manager/allocation_properties.h"
910
#include "shared/source/memory_manager/allocation_type.h"
1011
#include "shared/source/os_interface/product_helper.h"
1112
#include "shared/source/xe3_core/hw_info_xe3_core.h"
13+
#include "shared/test/common/helpers/debug_manager_state_restore.h"
1214
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
1315
#include "shared/test/unit_test/os_interface/product_helper_tests.h"
1416

@@ -43,3 +45,47 @@ PTLTEST_F(PtlProductHelper, givenCompilerProductHelperWhenGetMidThreadPreemption
4345
PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) {
4446
EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper));
4547
}
48+
49+
PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) {
50+
AllocationData allocationData{};
51+
allocationData.type = AllocationType::commandBuffer;
52+
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
53+
54+
allocationData.type = AllocationType::buffer;
55+
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
56+
}
57+
58+
PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideCacheable) {
59+
DebugManagerStateRestore restorer;
60+
debugManager.flags.AllowDcFlush.set(1);
61+
62+
AllocationData allocationData{};
63+
allocationData.type = AllocationType::externalHostPtr;
64+
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
65+
66+
debugManager.flags.AllowDcFlush.set(0);
67+
68+
for (auto i = 0; i < static_cast<int>(AllocationType::count); ++i) {
69+
auto allocationType = static_cast<AllocationType>(i);
70+
allocationData.type = allocationType;
71+
switch (allocationData.type) {
72+
case AllocationType::commandBuffer:
73+
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
74+
break;
75+
case AllocationType::externalHostPtr:
76+
case AllocationType::bufferHostMemory:
77+
case AllocationType::mapAllocation:
78+
case AllocationType::svmCpu:
79+
case AllocationType::svmZeroCopy:
80+
case AllocationType::internalHostMemory:
81+
case AllocationType::printfSurface:
82+
EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData));
83+
EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
84+
break;
85+
default:
86+
EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData));
87+
EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type));
88+
break;
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)