performance: Ensure hostptrs removed before creating new one

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2024-09-18 12:32:23 +00:00
committed by Compute-Runtime-Automation
parent ebc19b4a70
commit ac1d203555
14 changed files with 94 additions and 63 deletions

View File

@@ -198,7 +198,7 @@ void *MemoryManager::allocateSystemMemory(size_t size, size_t alignment) {
GraphicsAllocation *MemoryManager::allocateGraphicsMemoryWithHostPtr(const AllocationData &allocationData) {
if (deferredDeleter) {
deferredDeleter->drain(true);
deferredDeleter->drain(true, false);
}
GraphicsAllocation *graphicsAllocation = nullptr;
auto osStorage = hostPtrManager->prepareOsStorageForAllocation(*this, allocationData.size, allocationData.hostPtr, allocationData.rootDeviceIndex);
@@ -315,7 +315,7 @@ void MemoryManager::checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocatio
if (gfxAllocation->isUsed()) {
if (gfxAllocation->isUsedByManyOsContexts()) {
multiContextResourceDestructor->deferDeletion(new DeferrableAllocationDeletion{*this, *gfxAllocation});
multiContextResourceDestructor->drain(false);
multiContextResourceDestructor->drain(false, false);
return;
}
for (auto &engine : getRegisteredEngines(gfxAllocation->getRootDeviceIndex())) {
@@ -345,7 +345,7 @@ bool MemoryManager::isLimitedRange(uint32_t rootDeviceIndex) {
void MemoryManager::waitForDeletions() {
if (deferredDeleter) {
deferredDeleter->drain(false);
deferredDeleter->drain(false, false);
}
deferredDeleter.reset(nullptr);
}
@@ -737,6 +737,12 @@ bool MemoryManager::mapAuxGpuVA(GraphicsAllocation *graphicsAllocation) {
}
GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &allocationData) {
if (allocationData.type == AllocationType::externalHostPtr &&
allocationData.hostPtr &&
this->getDeferredDeleter()) {
this->getDeferredDeleter()->drain(true, true);
}
if (allocationData.type == AllocationType::image || allocationData.type == AllocationType::sharedResourceCopy) {
UNRECOVERABLE_IF(allocationData.imgInfo == nullptr);
return allocateGraphicsMemoryForImage(allocationData);