Do not reuse mem obj's allocation

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-07-13 15:05:42 +00:00
committed by Compute-Runtime-Automation
parent 69269b9aed
commit 4ac6e09117
14 changed files with 55 additions and 32 deletions

View File

@@ -14,9 +14,7 @@
namespace NEO {
InternalAllocationStorage::InternalAllocationStorage(CommandStreamReceiver &commandStreamReceiver)
: commandStreamReceiver(commandStreamReceiver),
temporaryAllocations(TEMPORARY_ALLOCATION),
allocationsForReuse(REUSABLE_ALLOCATION){};
: commandStreamReceiver(commandStreamReceiver){};
void InternalAllocationStorage::storeAllocation(std::unique_ptr<GraphicsAllocation> &&gfxAllocation, uint32_t allocationUsage) {
uint32_t taskCount = gfxAllocation->getTaskCount(commandStreamReceiver.getOsContext().getContextId());
@@ -34,13 +32,17 @@ void InternalAllocationStorage::storeAllocationWithTaskCount(std::unique_ptr<Gra
return;
}
}
auto &allocationsList = (allocationUsage == TEMPORARY_ALLOCATION) ? temporaryAllocations : allocationsForReuse;
auto &allocationsList = allocationLists[allocationUsage];
gfxAllocation->updateTaskCount(taskCount, commandStreamReceiver.getOsContext().getContextId());
allocationsList.pushTailOne(*gfxAllocation.release());
}
void InternalAllocationStorage::cleanAllocationList(uint32_t waitTaskCount, uint32_t allocationUsage) {
freeAllocationsList(waitTaskCount, (allocationUsage == TEMPORARY_ALLOCATION) ? temporaryAllocations : allocationsForReuse);
freeAllocationsList(waitTaskCount, allocationLists[allocationUsage]);
if (allocationUsage == TEMPORARY_ALLOCATION) {
freeAllocationsList(waitTaskCount, allocationLists[DEFERRED_DEALLOCATION]);
}
}
void InternalAllocationStorage::freeAllocationsList(uint32_t waitTaskCount, AllocationsList &allocationsList) {
@@ -66,12 +68,12 @@ void InternalAllocationStorage::freeAllocationsList(uint32_t waitTaskCount, Allo
}
std::unique_ptr<GraphicsAllocation> InternalAllocationStorage::obtainReusableAllocation(size_t requiredSize, AllocationType allocationType) {
auto allocation = allocationsForReuse.detachAllocation(requiredSize, nullptr, &commandStreamReceiver, allocationType);
auto allocation = allocationLists[REUSABLE_ALLOCATION].detachAllocation(requiredSize, nullptr, &commandStreamReceiver, allocationType);
return allocation;
}
std::unique_ptr<GraphicsAllocation> InternalAllocationStorage::obtainTemporaryAllocationWithPtr(size_t requiredSize, const void *requiredPtr, AllocationType allocationType) {
auto allocation = temporaryAllocations.detachAllocation(requiredSize, requiredPtr, &commandStreamReceiver, allocationType);
auto allocation = allocationLists[TEMPORARY_ALLOCATION].detachAllocation(requiredSize, requiredPtr, &commandStreamReceiver, allocationType);
return allocation;
}