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.
Make sure gfx allocations is unlocked after copy.

Related-To: NEO-7796

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek
2023-03-30 15:48:02 +00:00
committed by Compute-Runtime-Automation
parent 4e6995bc4c
commit 77d70fd4a7
9 changed files with 86 additions and 5 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,9 +65,12 @@ 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);
if (lockingSucceeded) {
gpuAllocation->unlock();
}
}
return gpuAllocation;
}

View File

@@ -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;