mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
fix: Remove fence handling when reuse cmd buffer
Resolves: NEO-10163 Related-To: NEO-7116 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
644287d3b1
commit
f3bbd70a58
@@ -119,8 +119,6 @@ CommandList *CommandList::create(uint32_t productFamily, Device *device, NEO::En
|
||||
if (returnValue != ZE_RESULT_SUCCESS) {
|
||||
commandList->destroy();
|
||||
commandList = nullptr;
|
||||
} else {
|
||||
commandList->getCmdContainer().setHandleFenceCompletionRequired();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,28 +296,9 @@ void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
|
||||
}
|
||||
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
|
||||
if (this->reusableAllocationList) {
|
||||
bool allocationHandled = false;
|
||||
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
|
||||
auto osContextId = engine.osContext->getContextId();
|
||||
if (cmdBufferAllocations[i]->isUsedByOsContext(osContextId) && engine.commandStreamReceiver->isAnyDirectSubmissionEnabled()) {
|
||||
auto lock = engine.commandStreamReceiver->obtainUniqueOwnership();
|
||||
auto taskCount = engine.commandStreamReceiver->peekTaskCount() + 1;
|
||||
cmdBufferAllocations[i]->updateTaskCount(taskCount, osContextId);
|
||||
cmdBufferAllocations[i]->updateResidencyTaskCount(taskCount, osContextId);
|
||||
engine.commandStreamReceiver->flushTagUpdate();
|
||||
engine.commandStreamReceiver->waitForTaskCount(taskCount);
|
||||
allocationHandled = true;
|
||||
}
|
||||
}
|
||||
if (!allocationHandled && isHandleFenceCompletionRequired) {
|
||||
if (isHandleFenceCompletionRequired) {
|
||||
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
|
||||
}
|
||||
|
||||
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
|
||||
auto osContextId = engine.osContext->getContextId();
|
||||
cmdBufferAllocations[i]->releaseUsageInOsContext(osContextId);
|
||||
}
|
||||
|
||||
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
|
||||
} else {
|
||||
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);
|
||||
|
||||
@@ -202,9 +202,6 @@ class CommandContainer : public NonCopyableOrMovableClass {
|
||||
return this->alignedPrimarySize;
|
||||
}
|
||||
void endAlignedPrimaryBuffer();
|
||||
void setHandleFenceCompletionRequired() {
|
||||
this->isHandleFenceCompletionRequired = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
size_t getAlignedCmdBufferSize() const;
|
||||
|
||||
@@ -302,66 +302,6 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
|
||||
allocList.freeAllGraphicsAllocations(pDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandContainerTest, givenCmdContainerAndHandleFenceWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) {
|
||||
AllocationsList allocList;
|
||||
auto cmdContainer = std::make_unique<CommandContainer>();
|
||||
cmdContainer->setHandleFenceCompletionRequired();
|
||||
cmdContainer->initialize(pDevice, &allocList, true, HeapSize::defaultHeapSize, false);
|
||||
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
|
||||
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
|
||||
auto csr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(memoryManager->getRegisteredEngines(0u)[0].commandStreamReceiver);
|
||||
csr->directSubmissionAvailable = true;
|
||||
csr->callFlushTagUpdate = false;
|
||||
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u);
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
|
||||
EXPECT_TRUE(allocList.peekIsEmpty());
|
||||
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
|
||||
auto cmdBuffer0 = cmdBufferAllocs[0];
|
||||
auto cmdBuffer1 = cmdBufferAllocs[1];
|
||||
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 1u);
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
|
||||
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
|
||||
EXPECT_FALSE(allocList.peekIsEmpty());
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
|
||||
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 2u);
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
|
||||
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
|
||||
EXPECT_FALSE(allocList.peekIsEmpty());
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
|
||||
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
|
||||
EXPECT_EQ(cmdBufferAllocs[1], cmdBuffer1);
|
||||
EXPECT_TRUE(allocList.peekIsEmpty());
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
|
||||
cmdBuffer1->updateTaskCount(1u, 0u);
|
||||
|
||||
cmdContainer.reset();
|
||||
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
|
||||
csr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(memoryManager->getRegisteredEngines(0u)[1].commandStreamReceiver);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
|
||||
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
|
||||
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 3u);
|
||||
EXPECT_FALSE(allocList.peekIsEmpty());
|
||||
cmdBuffer1->releaseUsageInOsContext(0u);
|
||||
allocList.freeAllGraphicsAllocations(pDevice);
|
||||
}
|
||||
|
||||
TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlistResetAndDestroyFlagWhenAllocateAndResetThenHandleFenceCompletionIsCalled) {
|
||||
DebugManagerStateRestore restore;
|
||||
debugManager.flags.RemoveUserFenceInCmdlistResetAndDestroy.set(0);
|
||||
@@ -375,21 +315,14 @@ TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlist
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(1u, memoryManager->handleFenceCompletionCalled);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
|
||||
cmdBufferAllocs[1]->updateTaskCount(2u, 0u);
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(2u, memoryManager->handleFenceCompletionCalled);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
EXPECT_FALSE(cmdBufferAllocs[1]->isUsedByOsContext(0u));
|
||||
|
||||
cmdBufferAllocs[0]->updateTaskCount(5u, 0u);
|
||||
cmdBufferAllocs[1]->updateTaskCount(5u, 0u);
|
||||
cmdContainer.reset();
|
||||
EXPECT_EQ(4u, memoryManager->handleFenceCompletionCalled);
|
||||
allocList.freeAllGraphicsAllocations(pDevice);
|
||||
@@ -408,21 +341,14 @@ TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlist
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
|
||||
cmdBufferAllocs[1]->updateTaskCount(2u, 0u);
|
||||
cmdContainer->reset();
|
||||
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
|
||||
cmdContainer->allocateNextCommandBuffer();
|
||||
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
|
||||
EXPECT_FALSE(cmdBufferAllocs[1]->isUsedByOsContext(0u));
|
||||
|
||||
cmdBufferAllocs[0]->updateTaskCount(5u, 0u);
|
||||
cmdBufferAllocs[1]->updateTaskCount(5u, 0u);
|
||||
cmdContainer.reset();
|
||||
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
|
||||
allocList.freeAllGraphicsAllocations(pDevice);
|
||||
|
||||
Reference in New Issue
Block a user