Reuse command buffers in L0 command queue

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-12-09 14:09:54 +00:00
committed by Compute-Runtime-Automation
parent dd3c59f46d
commit b2f286fc4a
4 changed files with 33 additions and 7 deletions

View File

@@ -178,8 +178,18 @@ ze_result_t CommandQueueImp::CommandBufferManager::initialize(Device *device, si
false,
device->getNEODevice()->getDeviceBitfield()};
buffers[BUFFER_ALLOCATION::FIRST] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
buffers[BUFFER_ALLOCATION::SECOND] = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
auto firstBuffer = device->obtainReusableAllocation(alignedSize, NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER);
if (!firstBuffer) {
firstBuffer = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
}
auto secondBuffer = device->obtainReusableAllocation(alignedSize, NEO::GraphicsAllocation::AllocationType::COMMAND_BUFFER);
if (!secondBuffer) {
secondBuffer = device->getNEODevice()->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
}
buffers[BUFFER_ALLOCATION::FIRST] = firstBuffer;
buffers[BUFFER_ALLOCATION::SECOND] = secondBuffer;
if (!buffers[BUFFER_ALLOCATION::FIRST] || !buffers[BUFFER_ALLOCATION::SECOND]) {
return ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY;
@@ -192,13 +202,13 @@ ze_result_t CommandQueueImp::CommandBufferManager::initialize(Device *device, si
return ZE_RESULT_SUCCESS;
}
void CommandQueueImp::CommandBufferManager::destroy(NEO::MemoryManager *memoryManager) {
void CommandQueueImp::CommandBufferManager::destroy(Device *device) {
if (buffers[BUFFER_ALLOCATION::FIRST]) {
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::FIRST]);
device->storeReusableAllocation(*buffers[BUFFER_ALLOCATION::FIRST]);
buffers[BUFFER_ALLOCATION::FIRST] = nullptr;
}
if (buffers[BUFFER_ALLOCATION::SECOND]) {
memoryManager->freeGraphicsMemory(buffers[BUFFER_ALLOCATION::SECOND]);
device->storeReusableAllocation(*buffers[BUFFER_ALLOCATION::SECOND]);
buffers[BUFFER_ALLOCATION::SECOND] = nullptr;
}
}