Files
compute-runtime/runtime/memory_manager/deferrable_allocation_deletion.cpp
Mateusz Jablonski d961bd8354 Implement deferrable allocation deletion
Change-Id: I5e99d1bbb920619f63b71573335dc76f19c796a6
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2018-11-23 11:28:52 +01:00

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