mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 01:48:50 +08:00
Align command buffers to 64KB
Change-Id: Id1fbd7c6f1aee48c4b69ec305d5332cb0aa86507 Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
af2dc200c5
commit
2bcecf3e62
@@ -208,15 +208,14 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
|
||||
|
||||
if (commandStream->getAvailableSpace() < minRequiredSize) {
|
||||
// If not, allocate a new block. allocate full pages
|
||||
minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize);
|
||||
|
||||
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
|
||||
minRequiredSize += CSRequirements::csOverfetchSize;
|
||||
minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize64k);
|
||||
|
||||
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
|
||||
GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(requiredSize, allocationType).release();
|
||||
GraphicsAllocation *allocation = storageForAllocation->obtainReusableAllocation(minRequiredSize, allocationType).release();
|
||||
|
||||
if (!allocation) {
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, allocationType});
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({minRequiredSize, allocationType});
|
||||
}
|
||||
|
||||
// Deallocate the old block, if not null
|
||||
@@ -225,7 +224,7 @@ LinearStream &CommandQueue::getCS(size_t minRequiredSize) {
|
||||
if (oldAllocation) {
|
||||
storageForAllocation->storeAllocation(std::unique_ptr<GraphicsAllocation>(oldAllocation), REUSABLE_ALLOCATION);
|
||||
}
|
||||
commandStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize);
|
||||
commandStream->replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - CSRequirements::minCommandQueueCommandStreamSize - CSRequirements::csOverfetchSize);
|
||||
commandStream->replaceGraphicsAllocation(allocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,16 +125,15 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
if (commandStream.getAvailableSpace() < minRequiredSize) {
|
||||
// Make sure we have enough room for a MI_BATCH_BUFFER_END and any padding.
|
||||
// Currently reserving 64bytes (cacheline) which should be more than enough.
|
||||
static const size_t sizeForSubmission = MemoryConstants::cacheLineSize;
|
||||
minRequiredSize += sizeForSubmission;
|
||||
minRequiredSize += MemoryConstants::cacheLineSize;
|
||||
minRequiredSize += CSRequirements::csOverfetchSize;
|
||||
// If not, allocate a new block. allocate full pages
|
||||
minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize);
|
||||
minRequiredSize = alignUp(minRequiredSize, MemoryConstants::pageSize64k);
|
||||
|
||||
auto requiredSize = minRequiredSize + CSRequirements::csOverfetchSize;
|
||||
auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM;
|
||||
auto allocation = internalAllocationStorage->obtainReusableAllocation(requiredSize, allocationType).release();
|
||||
auto allocation = internalAllocationStorage->obtainReusableAllocation(minRequiredSize, allocationType).release();
|
||||
if (!allocation) {
|
||||
allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({requiredSize, allocationType});
|
||||
allocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({minRequiredSize, allocationType});
|
||||
}
|
||||
|
||||
//pass current allocation to reusable list
|
||||
@@ -142,7 +141,7 @@ LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
||||
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
||||
}
|
||||
|
||||
commandStream.replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - sizeForSubmission);
|
||||
commandStream.replaceBuffer(allocation->getUnderlyingBuffer(), minRequiredSize - MemoryConstants::cacheLineSize - CSRequirements::csOverfetchSize);
|
||||
commandStream.replaceGraphicsAllocation(allocation);
|
||||
}
|
||||
|
||||
|
||||
@@ -297,10 +297,10 @@ TEST_F(CommandQueueCommandStreamTest, GetCommandStreamReturnsCsWithCsOverfetchSi
|
||||
|
||||
auto *allocation = cs.getGraphicsAllocation();
|
||||
ASSERT_NE(nullptr, &allocation);
|
||||
size_t expectedCsSize = alignUp(minSizeRequested + CSRequirements::minCommandQueueCommandStreamSize, MemoryConstants::pageSize) - CSRequirements::minCommandQueueCommandStreamSize;
|
||||
size_t expectedCsSize = alignUp(minSizeRequested + CSRequirements::minCommandQueueCommandStreamSize + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k) - CSRequirements::minCommandQueueCommandStreamSize - CSRequirements::csOverfetchSize;
|
||||
EXPECT_EQ(expectedCsSize, cs.getMaxAvailableSpace());
|
||||
|
||||
size_t expectedTotalSize = alignUp(minSizeRequested + CSRequirements::minCommandQueueCommandStreamSize, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize;
|
||||
size_t expectedTotalSize = alignUp(minSizeRequested + CSRequirements::minCommandQueueCommandStreamSize + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(expectedTotalSize, allocation->getUnderlyingBufferSize());
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ TEST_F(CommandQueueCommandStreamTest, givenCommandStreamReceiverWithReusableAllo
|
||||
CommandQueue cmdQ(context.get(), pDevice, props);
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
size_t requiredSize = alignUp(100, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize;
|
||||
size_t requiredSize = alignUp(100 + CSRequirements::minCommandQueueCommandStreamSize + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k);
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({requiredSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
|
||||
auto &commandStreamReceiver = cmdQ.getCommandStreamReceiver();
|
||||
commandStreamReceiver.getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
@@ -369,7 +369,7 @@ TEST_F(CommandQueueCommandStreamTest, CommandQueueWhenAskedForNewCommandStreamSt
|
||||
|
||||
auto graphicsAllocation = indirectHeap.getGraphicsAllocation();
|
||||
|
||||
cmdQ.getCS(10000);
|
||||
cmdQ.getCS(indirectHeap.getAvailableSpace() + 100);
|
||||
|
||||
EXPECT_FALSE(pDevice->getDefaultEngine().commandStreamReceiver->getAllocationsForReuse().peekIsEmpty());
|
||||
|
||||
|
||||
@@ -795,14 +795,15 @@ HWTEST_F(CommandStreamReceiverCQFlushTaskTests, getCSShouldReturnACSWithEnoughSi
|
||||
// work.
|
||||
size_t sizeCQReserves = CSRequirements::minCommandQueueCommandStreamSize;
|
||||
|
||||
size_t sizeRequested = 0x1000 - sizeCQReserves;
|
||||
size_t sizeRequested = MemoryConstants::pageSize64k - sizeCQReserves;
|
||||
auto &commandStream = commandQueue.getCS(sizeRequested);
|
||||
ASSERT_GE(0x1000u, commandStream.getMaxAvailableSpace());
|
||||
auto expect = alignUp(sizeRequested + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k);
|
||||
ASSERT_GE(expect, commandStream.getMaxAvailableSpace());
|
||||
|
||||
EXPECT_GE(commandStream.getAvailableSpace(), sizeRequested);
|
||||
commandStream.getSpace(sizeRequested - sizeCQReserves);
|
||||
|
||||
MockGraphicsAllocation allocation((void *)MemoryConstants::pageSize, 1);
|
||||
MockGraphicsAllocation allocation((void *)MemoryConstants::pageSize64k, 1);
|
||||
IndirectHeap linear(&allocation);
|
||||
|
||||
auto blocking = true;
|
||||
@@ -820,7 +821,7 @@ HWTEST_F(CommandStreamReceiverCQFlushTaskTests, getCSShouldReturnACSWithEnoughSi
|
||||
dispatchFlags,
|
||||
*pDevice);
|
||||
|
||||
auto expectedSize = 0x1000u - sizeCQReserves;
|
||||
auto expectedSize = MemoryConstants::pageSize64k - sizeCQReserves;
|
||||
|
||||
if (::renderCoreFamily == IGFX_GEN8_CORE) {
|
||||
expectedSize -= sizeof(typename FamilyType::PIPE_CONTROL);
|
||||
|
||||
@@ -114,7 +114,7 @@ TEST_F(CommandStreamReceiverTest, getCsReturnsCsWithCsOverfetchSizeIncludedInGra
|
||||
auto *allocation = commandStream.getGraphicsAllocation();
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
size_t expectedTotalSize = alignUp(sizeRequested + MemoryConstants::cacheLineSize, MemoryConstants::pageSize) + CSRequirements::csOverfetchSize;
|
||||
size_t expectedTotalSize = alignUp(sizeRequested + MemoryConstants::cacheLineSize + CSRequirements::csOverfetchSize, MemoryConstants::pageSize64k);
|
||||
|
||||
EXPECT_LT(commandStream.getAvailableSpace(), expectedTotalSize);
|
||||
EXPECT_LE(commandStream.getAvailableSpace(), expectedTotalSize - CSRequirements::csOverfetchSize);
|
||||
|
||||
@@ -247,9 +247,9 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
|
||||
MemoryManager *memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
|
||||
//Make two allocations, since CSR will try to reuse it also
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::LINEAR_STREAM});
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize, GraphicsAllocation::AllocationType::LINEAR_STREAM});
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::LINEAR_STREAM});
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
|
||||
MockExperimentalCommandBuffer *mockExCmdBuffer = static_cast<MockExperimentalCommandBuffer *>(commandStreamReceiver.experimentalCmdBuffer.get());
|
||||
|
||||
Reference in New Issue
Block a user