@@ -356,11 +356,15 @@ HWTEST_F(CommandQueueCreate, givenContainerWithAllocationsWhenResidencyContainer
356356 false ,
357357 returnValue));
358358 ResidencyContainer container;
359- commandQueue->submitBatchBuffer (0 , container, nullptr , false );
359+ uint32_t peekTaskCountBefore = commandQueue->csr ->peekTaskCount ();
360+ uint32_t flushedTaskCountBefore = commandQueue->csr ->peekLatestFlushedTaskCount ();
361+ NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer (0 , container, nullptr , false );
360362 EXPECT_EQ (csr->makeResidentCalledTimes , 0u );
361-
362- EXPECT_EQ (commandQueue->commandStream ->getGraphicsAllocation ()->getTaskCount (commandQueue->csr ->getOsContext ().getContextId ()), commandQueue->csr ->peekTaskCount ());
363+ EXPECT_EQ (ret, NEO::SubmissionStatus::SUCCESS);
364+ EXPECT_EQ ((peekTaskCountBefore + 1 ), commandQueue->csr ->peekTaskCount ());
365+ EXPECT_EQ ((flushedTaskCountBefore + 1 ), commandQueue->csr ->peekLatestFlushedTaskCount ());
363366 EXPECT_EQ (commandQueue->commandStream ->getGraphicsAllocation ()->getTaskCount (commandQueue->csr ->getOsContext ().getContextId ()), commandQueue->csr ->peekTaskCount ());
367+ EXPECT_EQ (commandQueue->commandStream ->getGraphicsAllocation ()->getResidencyTaskCount (commandQueue->csr ->getOsContext ().getContextId ()), commandQueue->csr ->peekTaskCount ());
364368 commandQueue->destroy ();
365369}
366370
@@ -377,9 +381,14 @@ HWTEST_F(CommandQueueCreate, givenCommandStreamReceiverFailsThenSubmitBatchBuffe
377381 false ,
378382 returnValue));
379383 ResidencyContainer container;
384+ uint32_t peekTaskCountBefore = commandQueue->csr ->peekTaskCount ();
385+ uint32_t flushedTaskCountBefore = commandQueue->csr ->peekLatestFlushedTaskCount ();
380386 NEO::SubmissionStatus ret = commandQueue->submitBatchBuffer (0 , container, nullptr , false );
381387 EXPECT_EQ (ret, NEO::SubmissionStatus::FAILED);
382-
388+ EXPECT_EQ (peekTaskCountBefore, commandQueue->csr ->peekTaskCount ());
389+ EXPECT_EQ (flushedTaskCountBefore, commandQueue->csr ->peekLatestFlushedTaskCount ());
390+ EXPECT_EQ (commandQueue->commandStream ->getGraphicsAllocation ()->getTaskCount (commandQueue->csr ->getOsContext ().getContextId ()), commandQueue->csr ->peekTaskCount ());
391+ EXPECT_EQ (commandQueue->commandStream ->getGraphicsAllocation ()->getResidencyTaskCount (commandQueue->csr ->getOsContext ().getContextId ()), commandQueue->csr ->peekTaskCount ());
383392 commandQueue->destroy ();
384393}
385394
@@ -1537,6 +1546,87 @@ HWTEST2_F(ExecuteCommandListTests, givenFailingSubmitBatchBufferThenExecuteComma
15371546 commandList->destroy ();
15381547}
15391548
1549+ HWTEST2_F (ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphicsTaskCountsLatestFlushedTaskCountZero, IsAtLeastSkl) {
1550+ ze_command_queue_desc_t desc = {};
1551+
1552+ NEO::CommandStreamReceiver *csr;
1553+ device->getCsrForOrdinalAndIndex (&csr, 0u , 0u );
1554+
1555+ auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1556+ commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1557+
1558+ commandQueue->initialize (false , false );
1559+ auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1560+ commandList->initialize (device, NEO::EngineGroupType::Compute, 0u );
1561+ auto commandListHandle = commandList->toHandle ();
1562+
1563+ void *alloc = alignedMalloc (0x100 , 0x100 );
1564+ NEO::GraphicsAllocation graphicsAllocation1 (0 , NEO::AllocationType::BUFFER, alloc, 0u , 0u , 1u , MemoryPool::System4KBPages, 1u );
1565+ NEO::GraphicsAllocation graphicsAllocation2 (0 , NEO::AllocationType::BUFFER, alloc, 0u , 0u , 1u , MemoryPool::System4KBPages, 1u );
1566+ commandList->commandContainer .addToResidencyContainer (&graphicsAllocation1);
1567+ commandList->commandContainer .addToResidencyContainer (&graphicsAllocation2);
1568+ static_cast <NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->taskCount = 0 ;
1569+ auto res = commandQueue->executeCommandLists (1 , &commandListHandle, nullptr , false );
1570+ EXPECT_EQ (ZE_RESULT_ERROR_UNKNOWN, res);
1571+
1572+ EXPECT_EQ (NEO::GraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount (csr->getOsContext ().getContextId ()));
1573+ EXPECT_EQ (NEO::GraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount (csr->getOsContext ().getContextId ()));
1574+ commandQueue->destroy ();
1575+ commandList->destroy ();
1576+ alignedFree (alloc);
1577+ }
1578+
1579+ HWTEST2_F (ExecuteCommandListTests, givenFailingSubmitBatchBufferThenResetGraphicsTaskCountsLatestFlushedTaskCountNonZero, IsAtLeastSkl) {
1580+ ze_command_queue_desc_t desc = {};
1581+
1582+ NEO::CommandStreamReceiver *csr;
1583+ device->getCsrForOrdinalAndIndex (&csr, 0u , 0u );
1584+
1585+ auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1586+ commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1587+
1588+ commandQueue->initialize (false , false );
1589+ auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1590+ commandList->initialize (device, NEO::EngineGroupType::Compute, 0u );
1591+ auto commandListHandle = commandList->toHandle ();
1592+
1593+ void *alloc = alignedMalloc (0x100 , 0x100 );
1594+ NEO::GraphicsAllocation graphicsAllocation1 (0 , NEO::AllocationType::BUFFER, alloc, 0u , 0u , 1u , MemoryPool::System4KBPages, 1u );
1595+ NEO::GraphicsAllocation graphicsAllocation2 (0 , NEO::AllocationType::BUFFER, alloc, 0u , 0u , 1u , MemoryPool::System4KBPages, 1u );
1596+ commandList->commandContainer .addToResidencyContainer (&graphicsAllocation1);
1597+ commandList->commandContainer .addToResidencyContainer (&graphicsAllocation2);
1598+ static_cast <NEO::UltCommandStreamReceiver<FamilyType> *>(csr)->taskCount = 2 ;
1599+ auto res = commandQueue->executeCommandLists (1 , &commandListHandle, nullptr , false );
1600+ EXPECT_EQ (ZE_RESULT_ERROR_UNKNOWN, res);
1601+
1602+ EXPECT_EQ (2u , graphicsAllocation1.getTaskCount (csr->getOsContext ().getContextId ()));
1603+ EXPECT_EQ (2u , graphicsAllocation2.getTaskCount (csr->getOsContext ().getContextId ()));
1604+ commandQueue->destroy ();
1605+ commandList->destroy ();
1606+ alignedFree (alloc);
1607+ }
1608+
1609+ HWTEST2_F (ExecuteCommandListTests, givenFailingSubmitBatchBufferThenWaitForCompletionFalse, IsAtLeastSkl) {
1610+ ze_command_queue_desc_t desc = {};
1611+ NEO::CommandStreamReceiver *csr;
1612+ device->getCsrForOrdinalAndIndex (&csr, 0u , 0u );
1613+ auto commandQueue = new MockCommandQueueSubmitBatchBuffer<gfxCoreFamily>(device, csr, &desc);
1614+ commandQueue->submitBatchBufferResult = NEO::SubmissionStatus::FAILED;
1615+
1616+ commandQueue->initialize (false , false );
1617+ auto commandList = new CommandListCoreFamily<gfxCoreFamily>();
1618+ commandList->initialize (device, NEO::EngineGroupType::Compute, 0u );
1619+ auto commandListHandle = commandList->toHandle ();
1620+ uint32_t flushedTaskCountPrior = csr->peekTaskCount ();
1621+ csr->setLatestFlushedTaskCount (flushedTaskCountPrior);
1622+ auto res = commandQueue->executeCommandLists (1 , &commandListHandle, nullptr , false );
1623+ EXPECT_EQ (ZE_RESULT_ERROR_UNKNOWN, res);
1624+ EXPECT_EQ (csr->peekLatestFlushedTaskCount (), flushedTaskCountPrior);
1625+
1626+ commandQueue->destroy ();
1627+ commandList->destroy ();
1628+ }
1629+
15401630HWTEST2_F (ExecuteCommandListTests, givenSuccessfulSubmitBatchBufferThenExecuteCommandListReturnsSuccess, IsAtLeastSkl) {
15411631 ze_command_queue_desc_t desc = {};
15421632 NEO::CommandStreamReceiver *csr;
0 commit comments