refactor: Add dc flush mitigation infrastructure
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
parent
8322495b53
commit
1cba900ad9
|
@ -195,7 +195,8 @@ bool inline copyHostPointer(Buffer *buffer,
|
|||
auto memory = buffer->getGraphicsAllocation(rootDeviceIndex);
|
||||
auto isCompressionEnabled = memory->isCompressionEnabled();
|
||||
const bool isLocalMemory = !MemoryPoolHelper::isSystemMemoryPool(memory->getMemoryPool());
|
||||
const bool gpuCopyRequired = isCompressionEnabled || isLocalMemory || productHelper.isDcFlushMitigated();
|
||||
const bool isGpuCopyRequiredForDcFlushMitigation = productHelper.isDcFlushMitigated() && memory->getAllocationType() != AllocationType::bufferHostMemory;
|
||||
const bool gpuCopyRequired = isCompressionEnabled || isLocalMemory || isGpuCopyRequiredForDcFlushMitigation;
|
||||
if (gpuCopyRequired) {
|
||||
auto &hwInfo = device.getHardwareInfo();
|
||||
|
||||
|
@ -210,7 +211,7 @@ bool inline copyHostPointer(Buffer *buffer,
|
|||
isCompressionEnabled == false &&
|
||||
productHelper.getLocalMemoryAccessMode(hwInfo) != LocalMemoryAccessMode::cpuAccessDisallowed &&
|
||||
isLockable &&
|
||||
!productHelper.isDcFlushMitigated();
|
||||
!isGpuCopyRequiredForDcFlushMitigation;
|
||||
|
||||
if (debugManager.flags.CopyHostPtrOnCpu.get() != -1) {
|
||||
copyOnCpuAllowed = debugManager.flags.CopyHostPtrOnCpu.get() == 1;
|
||||
|
@ -223,7 +224,7 @@ bool inline copyHostPointer(Buffer *buffer,
|
|||
} else {
|
||||
auto blitMemoryToAllocationResult = BlitOperationResult::unsupported;
|
||||
|
||||
if (productHelper.isBlitterFullySupported(hwInfo) && (isLocalMemory || productHelper.isDcFlushMitigated())) {
|
||||
if (productHelper.isBlitterFullySupported(hwInfo) && (isLocalMemory || isGpuCopyRequiredForDcFlushMitigation)) {
|
||||
blitMemoryToAllocationResult = BlitHelperFunctions::blitMemoryToAllocation(device, memory, buffer->getOffset(), hostPtr, {size, 1, 1});
|
||||
}
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenSrcCompressedBuffer
|
|||
template <uint32_t numTiles, bool testLocalMemory>
|
||||
template <typename FamilyType>
|
||||
void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenCompressedBufferWhenAuxTranslationCalledThenResolveAndCompressImpl() {
|
||||
if (this->context->getDevice(0u)->areSharedSystemAllocationsAllowed() || !compressionSupported()) {
|
||||
if (this->context->getDevice(0u)->areSharedSystemAllocationsAllowed() || !compressionSupported() || this->context->getDevice(0u)->getProductHelper().isDcFlushMitigated()) {
|
||||
// no support for scenarios where stateless is mixed with blitter compression
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
|
|
@ -212,6 +212,9 @@ struct PerformanceHintEnqueueMapTest : public PerformanceHintEnqueueTest,
|
|||
|
||||
void SetUp() override {
|
||||
PerformanceHintEnqueueTest::SetUp();
|
||||
if (context->getDevice(0)->getRootDeviceEnvironment().getProductHelper().isDcFlushMitigated()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
|
|
@ -1893,6 +1893,10 @@ HWTEST_F(BufferCreateTests, givenClMemCopyHostPointerPassedToBufferCreateWhenAll
|
|||
auto memoryManager = new MockMemoryManager(true, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
|
||||
if (executionEnvironment->rootDeviceEnvironments[0]->getProductHelper().isDcFlushMitigated()) {
|
||||
debugManager.flags.AllowDcFlush.set(1);
|
||||
}
|
||||
|
||||
MockClDevice device(new MockDevice(executionEnvironment, mockRootDeviceIndex));
|
||||
ASSERT_TRUE(device.createEngines());
|
||||
DeviceFactory::prepareDeviceEnvironments(*device.getExecutionEnvironment());
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
* Copyright (C) 2021-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -115,6 +115,10 @@ HWTEST2_F(PvcAndLaterBufferTests, givenCompressedBufferInSystemAndBlitterSupport
|
|||
auto pDevice = deviceFactory.rootDevices[0];
|
||||
auto pMockContext = std::make_unique<MockContext>(pDevice);
|
||||
|
||||
if (pDevice->getProductHelper().isDcFlushMitigated()) {
|
||||
debugManager.flags.AllowDcFlush.set(1);
|
||||
}
|
||||
|
||||
static_cast<MockMemoryManager *>(pDevice->getExecutionEnvironment()->memoryManager.get())->enable64kbpages[0] = true;
|
||||
static_cast<MockMemoryManager *>(pDevice->getExecutionEnvironment()->memoryManager.get())->localMemorySupported[0] = false;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2022-2023 Intel Corporation
|
||||
* Copyright (C) 2022-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -152,6 +152,10 @@ HWTEST_F(BufferCreateWindowsTests, givenClMemCopyHostPointerPassedToBufferCreate
|
|||
auto memoryManager = new MockMemoryManager(true, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
|
||||
if (executionEnvironment->rootDeviceEnvironments[0]->getProductHelper().isDcFlushMitigated()) {
|
||||
debugManager.flags.AllowDcFlush.set(1);
|
||||
}
|
||||
|
||||
MockClDevice device(new MockDevice(executionEnvironment, mockRootDeviceIndex));
|
||||
ASSERT_TRUE(device.createEngines());
|
||||
DeviceFactory::prepareDeviceEnvironments(*device.getExecutionEnvironment());
|
||||
|
|
|
@ -131,6 +131,7 @@ class ProductHelper {
|
|||
virtual bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isDcFlushAllowed() const = 0;
|
||||
virtual bool isDcFlushMitigated() const = 0;
|
||||
virtual bool mitigateDcFlush() const = 0;
|
||||
virtual bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const = 0;
|
||||
virtual bool overrideCacheableForDcFlushMitigation(AllocationType allocationType) const = 0;
|
||||
virtual uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const = 0;
|
||||
|
|
|
@ -394,7 +394,7 @@ bool ProductHelperHw<gfxProduct>::isDisableScratchPagesSupported() const {
|
|||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isDcFlushAllowed() const {
|
||||
using GfxProduct = typename HwMapper<gfxProduct>::GfxProduct;
|
||||
bool dcFlushAllowed = GfxProduct::isDcFlushAllowed;
|
||||
bool dcFlushAllowed = GfxProduct::isDcFlushAllowed && !this->mitigateDcFlush();
|
||||
|
||||
if (debugManager.flags.AllowDcFlush.get() != -1) {
|
||||
dcFlushAllowed = debugManager.flags.AllowDcFlush.get();
|
||||
|
@ -403,6 +403,11 @@ bool ProductHelperHw<gfxProduct>::isDcFlushAllowed() const {
|
|||
return dcFlushAllowed;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::mitigateDcFlush() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isDcFlushMitigated() const {
|
||||
using GfxProduct = typename HwMapper<gfxProduct>::GfxProduct;
|
||||
|
|
|
@ -76,6 +76,7 @@ class ProductHelperHw : public ProductHelper {
|
|||
bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const override;
|
||||
bool isDcFlushAllowed() const override;
|
||||
bool isDcFlushMitigated() const override;
|
||||
bool mitigateDcFlush() const override;
|
||||
bool overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const override;
|
||||
bool overrideCacheableForDcFlushMitigation(AllocationType allocationType) const override;
|
||||
uint32_t computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const override;
|
||||
|
|
|
@ -281,6 +281,11 @@ bool ProductHelperHw<IGFX_UNKNOWN>::isDcFlushMitigated() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<IGFX_UNKNOWN>::mitigateDcFlush() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<IGFX_UNKNOWN>::overridePatAndUsageForDcFlushMitigation(AllocationType allocationType) const {
|
||||
return false;
|
||||
|
|
|
@ -682,6 +682,11 @@ TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedThenSetThisHwInfoToGmmHelper) {
|
|||
TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) {
|
||||
MockExecutionEnvironment mockExecutionEnvironment{};
|
||||
const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<ProductHelper>();
|
||||
|
||||
if (productHelper.isDcFlushMitigated()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(AllocationType::count); i++) {
|
||||
auto allocationType = static_cast<AllocationType>(i);
|
||||
auto uncachedGmmUsageType = productHelper.isNewCoherencyModelSupported() ? GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC : GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED;
|
||||
|
@ -880,6 +885,10 @@ TEST(GmmTest, givenUncachedDebugFlagMaskSetWhenAskingForUsageTypeThenReturnUncac
|
|||
MockExecutionEnvironment mockExecutionEnvironment{};
|
||||
const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<ProductHelper>();
|
||||
|
||||
if (productHelper.isDcFlushMitigated()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
constexpr int64_t bufferMask = 1 << (static_cast<int64_t>(AllocationType::buffer) - 1);
|
||||
constexpr int64_t imageMask = 1 << (static_cast<int64_t>(AllocationType::image) - 1);
|
||||
|
||||
|
|
|
@ -311,10 +311,12 @@ HWTEST_F(ProductHelperTest, givenVariousValuesWhenGettingAubStreamSteppingFromHw
|
|||
|
||||
HWTEST_F(ProductHelperTest, givenDcFlushMitigationWhenOverridePatAndUsageForDcFlushMitigationThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restorer;
|
||||
if (!productHelper->isDcFlushMitigated()) {
|
||||
for (auto i = 0; i < static_cast<int>(AllocationType::count); ++i) {
|
||||
auto allocationType = static_cast<AllocationType>(i);
|
||||
EXPECT_FALSE(productHelper->overridePatAndUsageForDcFlushMitigation(allocationType));
|
||||
}
|
||||
}
|
||||
debugManager.flags.AllowDcFlush.set(0);
|
||||
for (auto i = 0; i < static_cast<int>(AllocationType::count); ++i) {
|
||||
auto allocationType = static_cast<AllocationType>(i);
|
||||
|
|
|
@ -2856,7 +2856,11 @@ HWTEST_F(WddmMemoryManagerTest, givenInternalHeapOrLinearStreamTypeWhenAllocatin
|
|||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
if (rootDeviceEnvironment->getProductHelper().isDcFlushMitigated()) {
|
||||
EXPECT_TRUE(allocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED);
|
||||
} else {
|
||||
EXPECT_TRUE(allocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
@ -2868,7 +2872,11 @@ HWTEST_F(WddmMemoryManagerTest, givenInternalHeapOrLinearStreamTypeWhenAllocatin
|
|||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
if (rootDeviceEnvironment->getProductHelper().isDcFlushMitigated()) {
|
||||
EXPECT_TRUE(allocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED);
|
||||
} else {
|
||||
EXPECT_TRUE(allocation->getDefaultGmm()->resourceParams.Usage == GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue