From e644b09433c1d77dd62275c44041ba3a2f562869 Mon Sep 17 00:00:00 2001 From: Tomasz Biernacik Date: Thu, 6 Mar 2025 14:20:14 +0000 Subject: [PATCH] performance: override allocation caching on integrated platforms Related-To: NEO-9421 Signed-off-by: Tomasz Biernacik --- .../ptl/os_agnostic_product_helper_ptl.inl | 5 ++ .../lnl/product_helper_tests_lnl.cpp | 25 ++++++---- .../xe3_core/ptl/product_helper_tests_ptl.cpp | 46 +++++++++++++++++++ 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl b/shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl index eea467397f..0c68776f45 100644 --- a/shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl +++ b/shared/source/xe3_core/ptl/os_agnostic_product_helper_ptl.inl @@ -9,6 +9,11 @@ namespace NEO { +template <> +bool ProductHelperHw::overrideAllocationCacheable(const AllocationData &allocationData) const { + return allocationData.type == AllocationType::commandBuffer || this->overrideCacheableForDcFlushMitigation(allocationData.type); +} + template <> std::optional ProductHelperHw::getAubStreamProductFamily() const { return aub_stream::ProductFamily::Ptl; diff --git a/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp index 9ff4a5d56c..54a267bbf1 100644 --- a/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp +++ b/shared/test/unit_test/xe2_hpg_core/lnl/product_helper_tests_lnl.cpp @@ -130,17 +130,24 @@ LNLTEST_F(LnlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideC for (auto i = 0; i < static_cast(AllocationType::count); ++i) { auto allocationType = static_cast(i); allocationData.type = allocationType; - if (allocationType == AllocationType::externalHostPtr || - allocationType == AllocationType::bufferHostMemory || - allocationType == AllocationType::mapAllocation || - allocationType == AllocationType::svmCpu || - allocationType == AllocationType::svmZeroCopy || - allocationType == AllocationType::internalHostMemory || - allocationType == AllocationType::commandBuffer || - allocationType == AllocationType::printfSurface) { + switch (allocationData.type) { + case AllocationType::commandBuffer: EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); - } else { + break; + case AllocationType::externalHostPtr: + case AllocationType::bufferHostMemory: + case AllocationType::mapAllocation: + case AllocationType::svmCpu: + case AllocationType::svmZeroCopy: + case AllocationType::internalHostMemory: + case AllocationType::printfSurface: + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type)); + break; + default: EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); + EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type)); + break; } } } diff --git a/shared/test/unit_test/xe3_core/ptl/product_helper_tests_ptl.cpp b/shared/test/unit_test/xe3_core/ptl/product_helper_tests_ptl.cpp index 2bc8381551..4639ddd843 100644 --- a/shared/test/unit_test/xe3_core/ptl/product_helper_tests_ptl.cpp +++ b/shared/test/unit_test/xe3_core/ptl/product_helper_tests_ptl.cpp @@ -6,9 +6,11 @@ */ #include "shared/source/helpers/compiler_product_helper.h" +#include "shared/source/memory_manager/allocation_properties.h" #include "shared/source/memory_manager/allocation_type.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/xe3_core/hw_info_xe3_core.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/unit_test/os_interface/product_helper_tests.h" @@ -43,3 +45,47 @@ PTLTEST_F(PtlProductHelper, givenCompilerProductHelperWhenGetMidThreadPreemption PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) { EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper)); } + +PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckOverrideAllocationCacheableThenTrueIsReturnedForCommandBuffer) { + AllocationData allocationData{}; + allocationData.type = AllocationType::commandBuffer; + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + + allocationData.type = AllocationType::buffer; + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); +} + +PTLTEST_F(PtlProductHelper, givenExternalHostPtrWhenMitigateDcFlushThenOverrideCacheable) { + DebugManagerStateRestore restorer; + debugManager.flags.AllowDcFlush.set(1); + + AllocationData allocationData{}; + allocationData.type = AllocationType::externalHostPtr; + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); + + debugManager.flags.AllowDcFlush.set(0); + + for (auto i = 0; i < static_cast(AllocationType::count); ++i) { + auto allocationType = static_cast(i); + allocationData.type = allocationType; + switch (allocationData.type) { + case AllocationType::commandBuffer: + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + break; + case AllocationType::externalHostPtr: + case AllocationType::bufferHostMemory: + case AllocationType::mapAllocation: + case AllocationType::svmCpu: + case AllocationType::svmZeroCopy: + case AllocationType::internalHostMemory: + case AllocationType::printfSurface: + EXPECT_TRUE(productHelper->overrideAllocationCacheable(allocationData)); + EXPECT_TRUE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type)); + break; + default: + EXPECT_FALSE(productHelper->overrideAllocationCacheable(allocationData)); + EXPECT_FALSE(productHelper->overrideCacheableForDcFlushMitigation(allocationData.type)); + break; + } + } +}