mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Change-Id: I5e99d1bbb920619f63b71573335dc76f19c796a6 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
/*
|
|
* Copyright (C) 2018 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
|
#include "runtime/memory_manager/deferrable_allocation_deletion.h"
|
|
#include "runtime/memory_manager/memory_manager.h"
|
|
|
|
namespace OCLRT {
|
|
|
|
DeferrableAllocationDeletion::DeferrableAllocationDeletion(MemoryManager &memoryManager, GraphicsAllocation &graphicsAllocation) : memoryManager(memoryManager),
|
|
graphicsAllocation(graphicsAllocation) {}
|
|
void DeferrableAllocationDeletion::apply() {
|
|
while (graphicsAllocation.isUsed()) {
|
|
|
|
for (auto contextId = 0u; contextId < memoryManager.getOsContextCount(); contextId++) {
|
|
if (graphicsAllocation.isUsedByContext(contextId)) {
|
|
auto currentContextTaskCount = *memoryManager.getCommandStreamReceiver(contextId)->getTagAddress();
|
|
if (graphicsAllocation.getTaskCount(contextId) <= currentContextTaskCount) {
|
|
graphicsAllocation.resetTaskCount(contextId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
memoryManager.freeGraphicsMemory(&graphicsAllocation);
|
|
}
|
|
} // namespace OCLRT
|