mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
TBX - fix residency of command buffer.
- Make sure that command buffer is properly resident and task counts are updated. - There is no need for divergent code flow in flush, we want to ensure here that command buffer is resident. - By code unification tbx command stream receiver properly handles command buffer allocation in all dispatch modes. Change-Id: Ied3f96ccd3e4774fe2d6f8810021cb9e030b3004 Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
41cca6d790
commit
ee0cd25bef
@ -188,12 +188,10 @@ FlushStamp TbxCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
|
||||
DEBUG_BREAK_IF(currentOffset < batchBuffer.startOffset);
|
||||
auto sizeBatchBuffer = currentOffset - batchBuffer.startOffset;
|
||||
|
||||
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
|
||||
CommandStreamReceiver::makeResident(*batchBuffer.commandBufferAllocation);
|
||||
} else {
|
||||
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
|
||||
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->osContext->getContextId());
|
||||
}
|
||||
auto submissionTaskCount = this->taskCount + 1;
|
||||
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
|
||||
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(submissionTaskCount, this->osContext->getContextId());
|
||||
batchBuffer.commandBufferAllocation->updateTaskCount(submissionTaskCount, osContext->getContextId());
|
||||
|
||||
// Write allocations for residency
|
||||
processResidency(allocationsForResidency);
|
||||
|
@ -311,6 +311,32 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledTh
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxCommandStreamReceiverWhenFlushIsCalledThenItMakesCommandBufferAllocationsProperlyResident) {
|
||||
TbxCommandStreamReceiverHw<FamilyType> *tbxCsr = (TbxCommandStreamReceiverHw<FamilyType> *)pCommandStreamReceiver;
|
||||
TbxMemoryManager *memoryManager = tbxCsr->getMemoryManager();
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
|
||||
GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
EXPECT_FALSE(commandBuffer->isResident(tbxCsr->getOsContext().getContextId()));
|
||||
|
||||
tbxCsr->flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_TRUE(commandBuffer->isResident(tbxCsr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, commandBuffer->getTaskCount(tbxCsr->getOsContext().getContextId()));
|
||||
EXPECT_EQ(tbxCsr->peekTaskCount() + 1, commandBuffer->getResidencyTaskCount(tbxCsr->getOsContext().getContextId()));
|
||||
ASSERT_EQ(1u, allocationsForResidency.size());
|
||||
EXPECT_EQ(commandBuffer, allocationsForResidency[0]);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
TEST(TbxMemoryManagerTest, givenTbxMemoryManagerWhenItIsQueriedForSystemSharedMemoryThen1GBIsReturned) {
|
||||
MockExecutionEnvironment executionEnvironment(*platformDevices);
|
||||
TbxMemoryManager memoryManager(executionEnvironment);
|
||||
|
Reference in New Issue
Block a user