|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #include "shared/source/helpers/compiler_product_helper.h" |
| 9 | +#include "shared/source/memory_manager/allocation_properties.h" |
9 | 10 | #include "shared/source/memory_manager/allocation_type.h" |
10 | 11 | #include "shared/source/os_interface/product_helper.h" |
11 | 12 | #include "shared/source/xe3_core/hw_info_xe3_core.h" |
| 13 | +#include "shared/test/common/helpers/debug_manager_state_restore.h" |
12 | 14 | #include "shared/test/common/test_macros/header/per_product_test_definitions.h" |
13 | 15 | #include "shared/test/unit_test/os_interface/product_helper_tests.h" |
14 | 16 |
|
@@ -43,3 +45,47 @@ PTLTEST_F(PtlProductHelper, givenCompilerProductHelperWhenGetMidThreadPreemption |
43 | 45 | PTLTEST_F(PtlProductHelper, givenProductHelperWhenCheckDirectSubmissionSupportedThenTrueIsReturned) { |
44 | 46 | EXPECT_TRUE(productHelper->isDirectSubmissionSupported(releaseHelper)); |
45 | 47 | } |
| 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