Skip to content

Commit 4704cd4

Browse files
fix: Remove fence handling when reuse cmd buffer
Resolves: NEO-10163 Related-To: NEO-7116 Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent 63a5b64 commit 4704cd4

File tree

4 files changed

+1
-99
lines changed

4 files changed

+1
-99
lines changed

level_zero/core/source/cmdlist/cmdlist_imp.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ CommandList *CommandList::create(uint32_t productFamily, Device *device, NEO::En
119119
if (returnValue != ZE_RESULT_SUCCESS) {
120120
commandList->destroy();
121121
commandList = nullptr;
122-
} else {
123-
commandList->getCmdContainer().setHandleFenceCompletionRequired();
124122
}
125123
}
126124

shared/source/command_container/cmdcontainer.cpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,28 +296,9 @@ void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
296296
}
297297
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
298298
if (this->reusableAllocationList) {
299-
bool allocationHandled = false;
300-
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
301-
auto osContextId = engine.osContext->getContextId();
302-
if (cmdBufferAllocations[i]->isUsedByOsContext(osContextId) && engine.commandStreamReceiver->isAnyDirectSubmissionEnabled()) {
303-
auto lock = engine.commandStreamReceiver->obtainUniqueOwnership();
304-
auto taskCount = engine.commandStreamReceiver->peekTaskCount() + 1;
305-
cmdBufferAllocations[i]->updateTaskCount(taskCount, osContextId);
306-
cmdBufferAllocations[i]->updateResidencyTaskCount(taskCount, osContextId);
307-
engine.commandStreamReceiver->flushTagUpdate();
308-
engine.commandStreamReceiver->waitForTaskCount(taskCount);
309-
allocationHandled = true;
310-
}
311-
}
312-
if (!allocationHandled && isHandleFenceCompletionRequired) {
299+
if (isHandleFenceCompletionRequired) {
313300
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
314301
}
315-
316-
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
317-
auto osContextId = engine.osContext->getContextId();
318-
cmdBufferAllocations[i]->releaseUsageInOsContext(osContextId);
319-
}
320-
321302
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
322303
} else {
323304
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);

shared/source/command_container/cmdcontainer.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,6 @@ class CommandContainer : public NonCopyableOrMovableClass {
202202
return this->alignedPrimarySize;
203203
}
204204
void endAlignedPrimaryBuffer();
205-
void setHandleFenceCompletionRequired() {
206-
this->isHandleFenceCompletionRequired = true;
207-
}
208205

209206
protected:
210207
size_t getAlignedCmdBufferSize() const;

shared/test/unit_test/command_container/command_container_tests.cpp

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -302,66 +302,6 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset
302302
allocList.freeAllGraphicsAllocations(pDevice);
303303
}
304304

305-
HWTEST_F(CommandContainerTest, givenCmdContainerAndHandleFenceWithAllocsListWhenAllocateAndResetThenCmdBufferAllocIsReused) {
306-
AllocationsList allocList;
307-
auto cmdContainer = std::make_unique<CommandContainer>();
308-
cmdContainer->setHandleFenceCompletionRequired();
309-
cmdContainer->initialize(pDevice, &allocList, true, HeapSize::defaultHeapSize, false);
310-
auto &cmdBufferAllocs = cmdContainer->getCmdBufferAllocations();
311-
auto memoryManager = static_cast<MockMemoryManager *>(pDevice->getMemoryManager());
312-
auto csr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(memoryManager->getRegisteredEngines(0u)[0].commandStreamReceiver);
313-
csr->directSubmissionAvailable = true;
314-
csr->callFlushTagUpdate = false;
315-
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u);
316-
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
317-
EXPECT_TRUE(allocList.peekIsEmpty());
318-
319-
cmdContainer->allocateNextCommandBuffer();
320-
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
321-
322-
auto cmdBuffer0 = cmdBufferAllocs[0];
323-
auto cmdBuffer1 = cmdBufferAllocs[1];
324-
325-
cmdContainer->reset();
326-
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 1u);
327-
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
328-
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
329-
EXPECT_FALSE(allocList.peekIsEmpty());
330-
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
331-
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
332-
333-
cmdContainer->allocateNextCommandBuffer();
334-
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
335-
cmdContainer->reset();
336-
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 2u);
337-
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
338-
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
339-
EXPECT_FALSE(allocList.peekIsEmpty());
340-
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
341-
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
342-
343-
cmdContainer->allocateNextCommandBuffer();
344-
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
345-
EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0);
346-
EXPECT_EQ(cmdBufferAllocs[1], cmdBuffer1);
347-
EXPECT_TRUE(allocList.peekIsEmpty());
348-
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
349-
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
350-
cmdBuffer1->updateTaskCount(1u, 0u);
351-
352-
cmdContainer.reset();
353-
354-
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
355-
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
356-
csr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(memoryManager->getRegisteredEngines(0u)[1].commandStreamReceiver);
357-
EXPECT_FALSE(csr->stopDirectSubmissionCalled);
358-
EXPECT_FALSE(csr->stopDirectSubmissionCalledBlocking);
359-
EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 3u);
360-
EXPECT_FALSE(allocList.peekIsEmpty());
361-
cmdBuffer1->releaseUsageInOsContext(0u);
362-
allocList.freeAllGraphicsAllocations(pDevice);
363-
}
364-
365305
TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlistResetAndDestroyFlagWhenAllocateAndResetThenHandleFenceCompletionIsCalled) {
366306
DebugManagerStateRestore restore;
367307
debugManager.flags.RemoveUserFenceInCmdlistResetAndDestroy.set(0);
@@ -375,21 +315,14 @@ TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlist
375315
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
376316
cmdContainer->allocateNextCommandBuffer();
377317
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
378-
379318
cmdContainer->reset();
380319
EXPECT_EQ(1u, memoryManager->handleFenceCompletionCalled);
381320
cmdContainer->allocateNextCommandBuffer();
382321
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
383-
384-
cmdBufferAllocs[1]->updateTaskCount(2u, 0u);
385322
cmdContainer->reset();
386323
EXPECT_EQ(2u, memoryManager->handleFenceCompletionCalled);
387324
cmdContainer->allocateNextCommandBuffer();
388325
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
389-
EXPECT_FALSE(cmdBufferAllocs[1]->isUsedByOsContext(0u));
390-
391-
cmdBufferAllocs[0]->updateTaskCount(5u, 0u);
392-
cmdBufferAllocs[1]->updateTaskCount(5u, 0u);
393326
cmdContainer.reset();
394327
EXPECT_EQ(4u, memoryManager->handleFenceCompletionCalled);
395328
allocList.freeAllGraphicsAllocations(pDevice);
@@ -408,21 +341,14 @@ TEST_F(CommandContainerTest, givenReusableAllocationsAndRemoveUserFenceInCmdlist
408341
EXPECT_EQ(cmdBufferAllocs.size(), 1u);
409342
cmdContainer->allocateNextCommandBuffer();
410343
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
411-
412344
cmdContainer->reset();
413345
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
414346
cmdContainer->allocateNextCommandBuffer();
415347
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
416-
417-
cmdBufferAllocs[1]->updateTaskCount(2u, 0u);
418348
cmdContainer->reset();
419349
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
420350
cmdContainer->allocateNextCommandBuffer();
421351
EXPECT_EQ(cmdBufferAllocs.size(), 2u);
422-
EXPECT_FALSE(cmdBufferAllocs[1]->isUsedByOsContext(0u));
423-
424-
cmdBufferAllocs[0]->updateTaskCount(5u, 0u);
425-
cmdBufferAllocs[1]->updateTaskCount(5u, 0u);
426352
cmdContainer.reset();
427353
EXPECT_EQ(0u, memoryManager->handleFenceCompletionCalled);
428354
allocList.freeAllGraphicsAllocations(pDevice);

0 commit comments

Comments
 (0)