Improve checkGpuUsageAndDestroy method to work with multiple CSRs

Change-Id: I7b8325116c90151c6339f95a81880c467e81748f
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-12-10 13:17:52 +01:00
committed by sys_ocldev
parent 2fec06007d
commit c905dad62f
4 changed files with 48 additions and 7 deletions

View File

@@ -137,11 +137,24 @@ void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
//if not in use destroy in place
//if in use pass to temporary allocation list that is cleaned on blocking calls
void MemoryManager::checkGpuUsageAndDestroyGraphicsAllocations(GraphicsAllocation *gfxAllocation) {
if (!gfxAllocation->isUsed() || gfxAllocation->getTaskCount(defaultEngineIndex) <= *getCommandStreamReceivers()[0][defaultEngineIndex]->getTagAddress()) {
if (!gfxAllocation->isUsed()) {
freeGraphicsMemory(gfxAllocation);
} else {
getCommandStreamReceivers()[0][defaultEngineIndex]->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(gfxAllocation), TEMPORARY_ALLOCATION);
return;
}
for (auto &csr : getCommandStreamReceivers()[0]) {
if (csr) {
auto osContextId = csr->getOsContext().getContextId();
auto allocationTaskCount = gfxAllocation->getTaskCount(osContextId);
if (gfxAllocation->isUsedByContext(osContextId) &&
allocationTaskCount > *csr->getTagAddress()) {
csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(gfxAllocation), TEMPORARY_ALLOCATION);
return;
}
}
}
freeGraphicsMemory(gfxAllocation);
}
void MemoryManager::waitForDeletions() {