mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Refactor heaps
- Remove GENERAL_STATE - Change allocation types - IOH can be utilized as 4GB heap Change-Id: I1c2a7bc284217a26d740b504bf92834d39f3ace2 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
18779537bb
commit
7b18a919e7
@@ -64,18 +64,15 @@ bool CommandContainer::initialize(Device *device) {
|
||||
commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
|
||||
|
||||
addToResidencyContainer(cmdBufferAllocation);
|
||||
size_t heapSize = 65536u;
|
||||
constexpr size_t heapSize = 65536u;
|
||||
|
||||
for (auto &allocationIndirectHeap : allocationIndirectHeaps) {
|
||||
allocationIndirectHeap = heapHelper->getHeapAllocation(heapSize, alignedSize, 0u);
|
||||
UNRECOVERABLE_IF(!allocationIndirectHeap);
|
||||
residencyContainer.push_back(allocationIndirectHeap);
|
||||
}
|
||||
for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) {
|
||||
allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i, heapSize, alignedSize, 0u);
|
||||
UNRECOVERABLE_IF(!allocationIndirectHeaps[i]);
|
||||
residencyContainer.push_back(allocationIndirectHeaps[i]);
|
||||
|
||||
uint32_t index = 0;
|
||||
for (auto &indirectHeap : indirectHeaps) {
|
||||
auto alloc = allocationIndirectHeaps[index++];
|
||||
indirectHeap = std::make_unique<IndirectHeap>(alloc);
|
||||
bool requireInternalHeap = (IndirectHeap::INDIRECT_OBJECT == i);
|
||||
indirectHeaps[i] = std::make_unique<IndirectHeap>(allocationIndirectHeaps[i], requireInternalHeap);
|
||||
}
|
||||
|
||||
instructionHeapBaseAddress = device->getMemoryManager()->getInternalHeapBaseAddress(0);
|
||||
|
||||
@@ -7,17 +7,24 @@
|
||||
|
||||
#include "core/helpers/heap_helper.h"
|
||||
|
||||
#include "core/indirect_heap/indirect_heap.h"
|
||||
#include "core/memory_manager/graphics_allocation.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
|
||||
namespace NEO {
|
||||
GraphicsAllocation *HeapHelper::getHeapAllocation(size_t heapSize, size_t alignment, uint32_t rootDeviceIndex) {
|
||||
auto allocation = this->storageForReuse->obtainReusableAllocation(heapSize, GraphicsAllocation::AllocationType::INTERNAL_HEAP);
|
||||
|
||||
GraphicsAllocation *HeapHelper::getHeapAllocation(uint32_t heapType, size_t heapSize, size_t alignment, uint32_t rootDeviceIndex) {
|
||||
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
|
||||
if (IndirectHeap::Type::INDIRECT_OBJECT == heapType) {
|
||||
allocationType = GraphicsAllocation::AllocationType::INTERNAL_HEAP;
|
||||
}
|
||||
|
||||
auto allocation = this->storageForReuse->obtainReusableAllocation(heapSize, allocationType);
|
||||
if (allocation) {
|
||||
return allocation.release();
|
||||
}
|
||||
NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, GraphicsAllocation::AllocationType::INTERNAL_HEAP, isMultiOsContextCapable, false, {}};
|
||||
NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType, isMultiOsContextCapable, false, {}};
|
||||
properties.alignment = alignment;
|
||||
|
||||
return this->memManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
@@ -20,7 +20,7 @@ class HeapHelper {
|
||||
HeapHelper(MemoryManager *memManager, InternalAllocationStorage *storageForReuse, bool isMultiOsContextCapable) : storageForReuse(storageForReuse),
|
||||
memManager(memManager),
|
||||
isMultiOsContextCapable(isMultiOsContextCapable) {}
|
||||
GraphicsAllocation *getHeapAllocation(size_t heapSize, size_t alignment, uint32_t rootDeviceIndex);
|
||||
GraphicsAllocation *getHeapAllocation(uint32_t heapType, size_t heapSize, size_t alignment, uint32_t rootDeviceIndex);
|
||||
void storeHeapAllocation(GraphicsAllocation *heapAllocation);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -24,7 +24,6 @@ class IndirectHeap : public LinearStream {
|
||||
public:
|
||||
enum Type {
|
||||
DYNAMIC_STATE = 0,
|
||||
GENERAL_STATE,
|
||||
INDIRECT_OBJECT,
|
||||
SURFACE_STATE,
|
||||
NUM_TYPES
|
||||
|
||||
@@ -80,6 +80,24 @@ TEST_F(CommandContainerHeapStateTests, givenDirtyHeapsWhenSettingStateForSingleH
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(CommandContainerTest, givenCmdContainerWhenAllocatingHeapsThenSetCorrectAllocationTypes) {
|
||||
CommandContainer cmdContainer;
|
||||
cmdContainer.initialize(pDevice);
|
||||
|
||||
for (uint32_t i = 0; i < HeapType::NUM_TYPES; i++) {
|
||||
HeapType heapType = static_cast<HeapType>(i);
|
||||
auto heap = cmdContainer.getIndirectHeap(heapType);
|
||||
|
||||
if (HeapType::INDIRECT_OBJECT == heapType) {
|
||||
EXPECT_EQ(GraphicsAllocation::AllocationType::INTERNAL_HEAP, heap->getGraphicsAllocation()->getAllocationType());
|
||||
EXPECT_NE(0u, heap->getHeapGpuStartOffset());
|
||||
} else {
|
||||
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, heap->getGraphicsAllocation()->getAllocationType());
|
||||
EXPECT_EQ(0u, heap->getHeapGpuStartOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIsInitialized) {
|
||||
CommandContainer cmdContainer;
|
||||
auto status = cmdContainer.initialize(pDevice);
|
||||
|
||||
@@ -753,7 +753,6 @@ INSTANTIATE_TEST_CASE_P(
|
||||
CommandQueueIndirectHeapTest,
|
||||
testing::Values(
|
||||
IndirectHeap::DYNAMIC_STATE,
|
||||
IndirectHeap::GENERAL_STATE,
|
||||
IndirectHeap::INDIRECT_OBJECT,
|
||||
IndirectHeap::SURFACE_STATE));
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ TEST(CommandStreamReceiverRootDeviceIndexTest, commandStreamGraphicsAllocationsH
|
||||
EXPECT_EQ(expectedRootDeviceIndex, debugSurface->getRootDeviceIndex());
|
||||
|
||||
// Indirect heaps
|
||||
IndirectHeap::Type heapTypes[]{IndirectHeap::DYNAMIC_STATE, IndirectHeap::GENERAL_STATE, IndirectHeap::INDIRECT_OBJECT, IndirectHeap::SURFACE_STATE};
|
||||
IndirectHeap::Type heapTypes[]{IndirectHeap::DYNAMIC_STATE, IndirectHeap::INDIRECT_OBJECT, IndirectHeap::SURFACE_STATE};
|
||||
for (auto heapType : heapTypes) {
|
||||
IndirectHeap *heap = nullptr;
|
||||
commandStreamReceiver->allocateHeapMemory(heapType, MemoryConstants::pageSize, heap);
|
||||
|
||||
Reference in New Issue
Block a user