mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add debug variable to force default heap allocation size
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
abd90308f3
commit
b60d963ff5
@ -821,6 +821,23 @@ TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledT
|
||||
delete indirectHeap;
|
||||
}
|
||||
|
||||
TEST_F(CommandQueueIndirectHeapTest, givenForceDefaultHeapSizeWhenGetHeapMemoryIsCalledThenHeapIsCreatedWithProperSize) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.ForceDefaultHeapSize.set(64 * MemoryConstants::kiloByte);
|
||||
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
|
||||
MockCommandQueue cmdQ(context.get(), pClDevice, props, false);
|
||||
|
||||
IndirectHeap *indirectHeap = nullptr;
|
||||
cmdQ.allocateHeapMemory(IndirectHeap::Type::INDIRECT_OBJECT, 100, indirectHeap);
|
||||
EXPECT_NE(nullptr, indirectHeap);
|
||||
EXPECT_NE(nullptr, indirectHeap->getGraphicsAllocation());
|
||||
EXPECT_EQ(indirectHeap->getAvailableSpace(), 64 * MemoryConstants::megaByte);
|
||||
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(indirectHeap->getGraphicsAllocation());
|
||||
delete indirectHeap;
|
||||
}
|
||||
|
||||
TEST_P(CommandQueueIndirectHeapTest, givenCommandQueueWhenGetHeapMemoryIsCalledWithAlreadyAllocatedHeapThenGraphicsAllocationIsCreated) {
|
||||
const cl_queue_properties props[3] = {CL_QUEUE_PROPERTIES, 0, 0};
|
||||
MockCommandQueue cmdQ(context.get(), pClDevice, props, false);
|
||||
|
@ -207,6 +207,8 @@ ZebinAppendElws = 0
|
||||
ZebinIgnoreIcbeVersion = 0
|
||||
LogWaitingForCompletion = 0
|
||||
ForceUserptrAlignment = -1
|
||||
ForceCommandBufferAlignment = -1
|
||||
ForceDefaultHeapSize = -1
|
||||
UseExternalAllocatorForSshAndDsh = 0
|
||||
DirectSubmissionDrmContext = -1
|
||||
DirectSubmissionOverrideBlitterSupport = -1
|
||||
|
@ -188,7 +188,13 @@ void CommandStreamReceiver::ensureCommandBufferAllocation(LinearStream &commandS
|
||||
return;
|
||||
}
|
||||
|
||||
const auto allocationSize = alignUp(minimumRequiredSize + additionalAllocationSize, MemoryConstants::pageSize64k);
|
||||
auto alignment = MemoryConstants::pageSize64k;
|
||||
|
||||
if (DebugManager.flags.ForceCommandBufferAlignment.get() != -1) {
|
||||
alignment = DebugManager.flags.ForceCommandBufferAlignment.get() * MemoryConstants::kiloByte;
|
||||
}
|
||||
|
||||
const auto allocationSize = alignUp(minimumRequiredSize + additionalAllocationSize, alignment);
|
||||
constexpr static auto allocationType = AllocationType::COMMAND_BUFFER;
|
||||
auto allocation = this->getInternalAllocationStorage()->obtainReusableAllocation(allocationSize, allocationType).release();
|
||||
if (allocation == nullptr) {
|
||||
@ -474,7 +480,7 @@ IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType
|
||||
void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
|
||||
size_t minRequiredSize, IndirectHeap *&indirectHeap) {
|
||||
size_t reservedSize = 0;
|
||||
auto finalHeapSize = defaultHeapSize;
|
||||
auto finalHeapSize = getDefaultHeapSize();
|
||||
if (IndirectHeap::Type::SURFACE_STATE == heapType) {
|
||||
finalHeapSize = defaultSshSize;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -14,7 +14,7 @@ namespace NEO {
|
||||
|
||||
template <typename GfxFamily>
|
||||
size_t CommandStreamReceiverHw<GfxFamily>::getSshHeapSize() {
|
||||
return defaultHeapSize;
|
||||
return getDefaultHeapSize();
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
@ -368,6 +368,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, UseKmdMigration, -1, "-1: devices default mode,
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceSemaphoreDelayBetweenWaits, -1, "Specifies the minimum number of microseconds allowed for command streamer to wait before re-fetching the data. 0 - poll interval will be equal to the memory latency of the read completion")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceLocalMemoryAccessMode, -1, "-1: don't override, 0: default rules apply, 1: CPU can access local memory, 3: CPU never accesses local memory")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceUserptrAlignment, -1, "-1: no force (4kb), >0: n kb alignment")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceCommandBufferAlignment, -1, "-1: no force (64kb), >0: n kb alignment")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceDefaultHeapSize, -1, "-1: no force (64kb), >0: n kb size")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, PreferCopyEngineForCopyBufferToBuffer, -1, "-1: default, 0: prefer EUs, 1: prefer blitter")
|
||||
DECLARE_DEBUG_VARIABLE(int64_t, ForceSystemMemoryPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force system memory placement")
|
||||
DECLARE_DEBUG_VARIABLE(int64_t, ForceNonSystemMemoryPlacement, 0, "0: default, >0: (bitmask) for given Graphics Allocation Type, force non-system memory placement")
|
||||
|
@ -21,6 +21,14 @@ using HeapContainer = std::vector<GraphicsAllocation *>;
|
||||
|
||||
constexpr size_t defaultHeapSize = 64 * KB;
|
||||
|
||||
inline size_t getDefaultHeapSize() {
|
||||
auto defaultSize = defaultHeapSize;
|
||||
if (DebugManager.flags.ForceDefaultHeapSize.get() != -1) {
|
||||
defaultSize = DebugManager.flags.ForceDefaultHeapSize.get() * MemoryConstants::kiloByte;
|
||||
}
|
||||
return defaultSize;
|
||||
}
|
||||
|
||||
class IndirectHeap : public LinearStream {
|
||||
typedef LinearStream BaseClass;
|
||||
|
||||
|
@ -1477,6 +1477,20 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsur
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenForceCommandBufferAlignmentWhenEnsureCommandBufferAllocationThenItHasProperAlignment) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.ForceCommandBufferAlignment.set(2048);
|
||||
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::COMMAND_BUFFER, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, commandStream.getGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, commandStream.getMaxAvailableSpace());
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenAdditionalAllocationSizeWhenCallingEnsureCommandBufferAllocationThenSizesOfAllocationAndCommandBufferAreCorrect) {
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, AllocationType::COMMAND_BUFFER, pDevice->getDeviceBitfield()});
|
||||
LinearStream commandStream{allocation};
|
||||
|
Reference in New Issue
Block a user