mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Change-Id: I7067bc2bc74f92518a33ccb9f9dce9b57cc28637 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
39 lines
1.5 KiB
C++
39 lines
1.5 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"
|
|
#include "runtime/os_interface/os_context.h"
|
|
|
|
namespace OCLRT {
|
|
|
|
DeferrableAllocationDeletion::DeferrableAllocationDeletion(MemoryManager &memoryManager, GraphicsAllocation &graphicsAllocation) : memoryManager(memoryManager),
|
|
graphicsAllocation(graphicsAllocation) {}
|
|
bool DeferrableAllocationDeletion::apply() {
|
|
if (graphicsAllocation.isUsed()) {
|
|
|
|
for (auto &deviceCsrs : memoryManager.getCommandStreamReceivers()) {
|
|
for (auto &csr : deviceCsrs) {
|
|
auto contextId = csr->getOsContext().getContextId();
|
|
if (graphicsAllocation.isUsedByContext(contextId)) {
|
|
auto currentContextTaskCount = *csr->getTagAddress();
|
|
if (graphicsAllocation.getTaskCount(contextId) <= currentContextTaskCount) {
|
|
graphicsAllocation.resetTaskCount(contextId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (graphicsAllocation.isUsed()) {
|
|
return false;
|
|
}
|
|
}
|
|
memoryManager.freeGraphicsMemory(&graphicsAllocation);
|
|
return true;
|
|
}
|
|
} // namespace OCLRT
|