mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
Create commandContainer encoders
Change-Id: I2f27c4de6af9ebbc0210bc5e08bbfa9cb6beec0e Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
278efbdfe6
commit
00f667723f
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "core/command_container/cmdcontainer.h"
|
||||
|
||||
#include "core/command_container/command_encoder.h"
|
||||
#include "core/command_stream/linear_stream.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/helpers/heap_helper.h"
|
||||
@@ -15,8 +16,6 @@
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
CommandContainer::~CommandContainer() {
|
||||
@@ -34,7 +33,11 @@ CommandContainer::~CommandContainer() {
|
||||
for (auto allocationIndirectHeap : allocationIndirectHeaps) {
|
||||
heapHelper->storeHeapAllocation(allocationIndirectHeap);
|
||||
}
|
||||
|
||||
for (auto deallocation : deallocationContainer) {
|
||||
if (((deallocation->getAllocationType() == GraphicsAllocation::AllocationType::INTERNAL_HEAP) || (deallocation->getAllocationType() == GraphicsAllocation::AllocationType::LINEAR_STREAM))) {
|
||||
getHeapHelper()->storeHeapAllocation(deallocation);
|
||||
}
|
||||
}
|
||||
residencyContainer.clear();
|
||||
deallocationContainer.clear();
|
||||
}
|
||||
@@ -49,13 +52,13 @@ bool CommandContainer::initialize(Device *device) {
|
||||
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u));
|
||||
|
||||
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
|
||||
NEO::AllocationProperties properties{0u,
|
||||
true /* allocateMemory*/,
|
||||
alignedSize,
|
||||
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
|
||||
false,
|
||||
{}};
|
||||
AllocationProperties properties{0u,
|
||||
true /* allocateMemory*/,
|
||||
alignedSize,
|
||||
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
|
||||
false,
|
||||
{}};
|
||||
|
||||
auto cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
UNRECOVERABLE_IF(!cmdBufferAllocation);
|
||||
@@ -80,10 +83,13 @@ bool CommandContainer::initialize(Device *device) {
|
||||
|
||||
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0);
|
||||
|
||||
iddBlock = nullptr;
|
||||
nextIddInBlock = numIddsPerBlock;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandContainer::addToResidencyContainer(NEO::GraphicsAllocation *alloc) {
|
||||
void CommandContainer::addToResidencyContainer(GraphicsAllocation *alloc) {
|
||||
if (alloc == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -118,7 +124,31 @@ void CommandContainer::reset() {
|
||||
}
|
||||
}
|
||||
|
||||
IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(NEO::HeapType heapType, size_t sizeRequired, size_t alignment) {
|
||||
void *CommandContainer::getHeapSpaceAllowGrow(HeapType heapType,
|
||||
size_t size) {
|
||||
auto indirectHeap = getIndirectHeap(heapType);
|
||||
|
||||
if (indirectHeap->getAvailableSpace() < size) {
|
||||
size_t newSize = indirectHeap->getUsed() + indirectHeap->getAvailableSpace();
|
||||
newSize *= 2;
|
||||
newSize = std::max(newSize, indirectHeap->getAvailableSpace() + size);
|
||||
newSize = alignUp(newSize, MemoryConstants::pageSize);
|
||||
auto oldAlloc = getIndirectHeapAllocation(heapType);
|
||||
auto newAlloc = getHeapHelper()->getHeapAllocation(heapType, newSize, MemoryConstants::pageSize, device->getRootDeviceIndex());
|
||||
UNRECOVERABLE_IF(!oldAlloc);
|
||||
UNRECOVERABLE_IF(!newAlloc);
|
||||
indirectHeap->replaceGraphicsAllocation(newAlloc);
|
||||
indirectHeap->replaceBuffer(newAlloc->getUnderlyingBuffer(),
|
||||
newAlloc->getUnderlyingBufferSize());
|
||||
getResidencyContainer().push_back(newAlloc);
|
||||
getDeallocationContainer().push_back(oldAlloc);
|
||||
setIndirectHeapAllocation(heapType, newAlloc);
|
||||
setHeapDirty(heapType);
|
||||
}
|
||||
return indirectHeap->getSpace(size);
|
||||
}
|
||||
|
||||
IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType heapType, size_t sizeRequired, size_t alignment) {
|
||||
auto indirectHeap = getIndirectHeap(heapType);
|
||||
auto sizeRequested = sizeRequired;
|
||||
|
||||
@@ -129,9 +159,9 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(NEO::HeapTyp
|
||||
|
||||
if (indirectHeap->getAvailableSpace() < sizeRequested) {
|
||||
size_t newSize = indirectHeap->getUsed() + indirectHeap->getAvailableSpace();
|
||||
newSize = alignUp(newSize, 4096U);
|
||||
newSize = alignUp(newSize, MemoryConstants::pageSize);
|
||||
auto oldAlloc = getIndirectHeapAllocation(heapType);
|
||||
auto newAlloc = getHeapHelper()->getHeapAllocation(heapType, newSize, 4096u, device->getRootDeviceIndex());
|
||||
auto newAlloc = getHeapHelper()->getHeapAllocation(heapType, newSize, MemoryConstants::pageSize, device->getRootDeviceIndex());
|
||||
UNRECOVERABLE_IF(!oldAlloc);
|
||||
UNRECOVERABLE_IF(!newAlloc);
|
||||
indirectHeap->replaceGraphicsAllocation(newAlloc);
|
||||
@@ -151,13 +181,13 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(NEO::HeapTyp
|
||||
|
||||
void CommandContainer::allocateNextCommandBuffer() {
|
||||
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
|
||||
NEO::AllocationProperties properties{0u,
|
||||
true /* allocateMemory*/,
|
||||
alignedSize,
|
||||
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
|
||||
false,
|
||||
{}};
|
||||
AllocationProperties properties{0u,
|
||||
true /* allocateMemory*/,
|
||||
alignedSize,
|
||||
GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
(device->getNumAvailableDevices() > 1u) /* multiOsContextCapable */,
|
||||
false,
|
||||
{}};
|
||||
|
||||
auto cmdBufferAllocation = device->getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
||||
UNRECOVERABLE_IF(!cmdBufferAllocation);
|
||||
|
||||
Reference in New Issue
Block a user