mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
feature: pvc, cpu copy in program init
Use cpu copy for globals surface when allocated through svm, allocation not set as lockable but locking allocation succeeds. Related-To: NEO-7796 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b9828b543e
commit
4c891e80a5
@@ -149,6 +149,7 @@ class ProductHelper {
|
||||
virtual bool isBcsReportWaRequired(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBlitSplitEnqueueWARequired(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const = 0;
|
||||
virtual bool isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation, bool lockingSucceeded) const = 0;
|
||||
virtual bool isInitDeviceWithFirstSubmissionRequired(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isImplicitScalingSupported(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const = 0;
|
||||
|
||||
@@ -485,7 +485,7 @@ bool ProductHelperHw<gfxProduct>::isBlitSplitEnqueueWARequired(const HardwareInf
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const {
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation, bool lockingSucceeded) const {
|
||||
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
|
||||
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
|
||||
return allocation.isAllocatedInLocalMemoryPool() &&
|
||||
@@ -493,6 +493,11 @@ bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDev
|
||||
!allocation.isAllocationLockable());
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const {
|
||||
return this->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, allocation, false);
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
bool ProductHelperHw<gfxProduct>::isInitDeviceWithFirstSubmissionRequired(const HardwareInfo &hwInfo) const {
|
||||
return false;
|
||||
|
||||
@@ -101,6 +101,7 @@ class ProductHelperHw : public ProductHelper {
|
||||
bool allowMemoryPrefetch(const HardwareInfo &hwInfo) const override;
|
||||
bool isBcsReportWaRequired(const HardwareInfo &hwInfo) const override;
|
||||
bool isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const override;
|
||||
bool isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation, bool lockingSucceeded) const override;
|
||||
bool isImplicitScalingSupported(const HardwareInfo &hwInfo) const override;
|
||||
bool isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const override;
|
||||
bool isUnlockingLockedPtrNecessary(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
@@ -29,7 +29,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
if (linkerInput != nullptr) {
|
||||
globalsAreExported = constant ? linkerInput->getTraits().exportsGlobalConstants : linkerInput->getTraits().exportsGlobalVariables;
|
||||
}
|
||||
|
||||
bool lockingSucceeded = false;
|
||||
if (globalsAreExported && (svmAllocManager != nullptr)) {
|
||||
RootDeviceIndicesContainer rootDeviceIndices;
|
||||
rootDeviceIndices.push_back(rootDeviceIndex);
|
||||
@@ -45,6 +45,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
auto usmAlloc = svmAllocManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(usmAlloc == nullptr);
|
||||
gpuAllocation = usmAlloc->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
|
||||
lockingSucceeded = device.getMemoryManager()->lockResource(gpuAllocation) != nullptr;
|
||||
} else {
|
||||
auto allocationType = constant ? AllocationType::CONSTANT_SURFACE : AllocationType::GLOBAL_SURFACE;
|
||||
gpuAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex,
|
||||
@@ -64,7 +65,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
bool isOnlyBssData = (totalSize == zeroInitSize);
|
||||
if (false == isOnlyBssData) {
|
||||
auto initSize = totalSize - zeroInitSize;
|
||||
auto success = MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *gpuAllocation),
|
||||
auto success = MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *gpuAllocation, lockingSucceeded),
|
||||
device, gpuAllocation, 0, initData, initSize);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ bool ProductHelperHw<gfxProduct>::isBcsReportWaRequired(const HardwareInfo &hwIn
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const {
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation, bool lockingSucceeded) const {
|
||||
if (!allocation.isAllocatedInLocalMemoryPool()) {
|
||||
return false;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDev
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!allocation.isAllocationLockable()) {
|
||||
if (!allocation.isAllocationLockable() && !lockingSucceeded) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -166,6 +166,11 @@ bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDev
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<gfxProduct>::isBlitCopyRequiredForLocalMemory(const RootDeviceEnvironment &rootDeviceEnvironment, const GraphicsAllocation &allocation) const {
|
||||
return this->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, allocation, false);
|
||||
}
|
||||
|
||||
template <>
|
||||
bool ProductHelperHw<gfxProduct>::isTlbFlushRequired() const {
|
||||
return false;
|
||||
|
||||
@@ -433,18 +433,24 @@ HWTEST_F(ProductHelperTest, givenLockableAllocationWhenGettingIsBlitCopyRequired
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(1);
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(3);
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
pInHwInfo.capabilityTable.blitterOperationsSupported = false;
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
pInHwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
}
|
||||
|
||||
HWTEST_F(ProductHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) {
|
||||
@@ -473,18 +479,24 @@ HWTEST_F(ProductHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequi
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(1);
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(3);
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = false;
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper->isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
}
|
||||
|
||||
HWTEST2_F(ProductHelperTest, givenProductHelperWhenGettingIsBlitCopyRequiredForLocalMemoryThenFalseIsReturned, IsAtMostGen11) {
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/test_macros/header/per_product_test_definitions.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
@@ -540,3 +542,49 @@ PVCTEST_F(EngineNodeHelperPvcTests, givenNonTile0AccessWhenGettingIsBlitCopyRequ
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
}
|
||||
}
|
||||
|
||||
PVCTEST_F(EngineNodeHelperPvcTests, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned) {
|
||||
DebugManagerStateRestore restore{};
|
||||
auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment();
|
||||
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
|
||||
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
MockGraphicsAllocation graphicsAllocation;
|
||||
graphicsAllocation.setAllocationType(AllocationType::SVM_GPU);
|
||||
EXPECT_FALSE(GraphicsAllocation::isLockable(graphicsAllocation.getAllocationType()));
|
||||
graphicsAllocation.overrideMemoryPool(MemoryPool::LocalMemory);
|
||||
|
||||
MockExecutionEnvironment executionEnvironment(&hwInfo);
|
||||
executionEnvironment.initGmm();
|
||||
executionEnvironment.prepareRootDeviceEnvironments(1);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
|
||||
|
||||
MockGmm mockGmm(gmmHelper, nullptr, 100, 100, GMM_RESOURCE_USAGE_OCL_BUFFER, false, {}, true);
|
||||
mockGmm.resourceParams.Flags.Info.NotLockable = true;
|
||||
graphicsAllocation.setDefaultGmm(&mockGmm);
|
||||
|
||||
auto &productHelper = getHelper<ProductHelper>();
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(0);
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(1);
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(3);
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = false;
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_TRUE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
|
||||
graphicsAllocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation));
|
||||
EXPECT_FALSE(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, graphicsAllocation, true));
|
||||
}
|
||||
@@ -8,5 +8,6 @@
|
||||
#include "shared/test/common/test_macros/hw_test_base.h"
|
||||
|
||||
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenAskedIfIsBlitSplitEnqueueWARequiredThenReturnFalse, IGFX_PVC);
|
||||
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenNotLockableAllocationWhenGettingIsBlitCopyRequiredForLocalMemoryThenCorrectValuesAreReturned, IGFX_PVC);
|
||||
HWTEST_EXCLUDE_PRODUCT(BlitTests, GivenCpuAccessToLocalMemoryWhenGettingMaxBlitSizeThenValuesAreOverriden_BlitPlatforms, IGFX_PVC);
|
||||
HWTEST_EXCLUDE_PRODUCT(GfxCoreHelperTest, GivenCooperativeEngineSupportedAndNotUsedWhenAdjustMaxWorkGroupCountIsCalledThenSmallerValueIsReturned, IGFX_PVC);
|
||||
|
||||
Reference in New Issue
Block a user