@@ -1521,42 +1521,36 @@ using CommandQueueSynchronizeTest = Test<ContextFixture>;
15211521template <typename GfxFamily>
15221522struct SynchronizeCsr : public NEO ::UltCommandStreamReceiver<GfxFamily> {
15231523 ~SynchronizeCsr () override {
1524- delete tagAddress;
1524+ delete[] tagAddress;
15251525 }
15261526
15271527 SynchronizeCsr (const NEO::ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
15281528 : NEO::UltCommandStreamReceiver<GfxFamily>(const_cast <NEO::ExecutionEnvironment &>(executionEnvironment), 0 , deviceBitfield) {
1529- tagAddress = new uint32_t ;
1530- }
1531-
1532- bool waitForCompletionWithTimeout (volatile uint32_t *pollAddress, bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait, uint32_t partitionCount, uint32_t offsetSize) override {
1533- enableTimeoutSet = enableTimeout;
1534- partitionCountSet = partitionCount;
1535- offsetSizeSet = offsetSize;
1536- waitForComplitionCalledTimes++;
1537- return true ;
1529+ tagAddress = new uint32_t [tagSize];
1530+ memset (tagAddress, 0xFFFFFFFF , tagSize * sizeof (uint32_t ));
15381531 }
15391532
15401533 bool waitForCompletionWithTimeout (bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait) override {
15411534 enableTimeoutSet = enableTimeout;
15421535 waitForComplitionCalledTimes++;
1536+ partitionCountSet = this ->activePartitions ;
15431537 return true ;
15441538 }
15451539
1546- void waitForTaskCountWithKmdNotifyFallback (uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode, uint32_t partitionCount, uint32_t offsetSize ) override {
1540+ void waitForTaskCountWithKmdNotifyFallback (uint32_t taskCountToWait, FlushStamp flushStampToWait, bool quickKmdSleep, bool forcePowerSavingMode) override {
15471541 waitForTaskCountWithKmdNotifyFallbackCalled++;
1548- NEO::UltCommandStreamReceiver<GfxFamily>::waitForTaskCountWithKmdNotifyFallback (taskCountToWait, flushStampToWait, quickKmdSleep, forcePowerSavingMode, partitionCount, offsetSize );
1542+ NEO::UltCommandStreamReceiver<GfxFamily>::waitForTaskCountWithKmdNotifyFallback (taskCountToWait, flushStampToWait, quickKmdSleep, forcePowerSavingMode);
15491543 }
15501544
15511545 volatile uint32_t *getTagAddress () const override {
15521546 return tagAddress;
15531547 }
15541548
1549+ static constexpr size_t tagSize = 64 ;
15551550 uint32_t *tagAddress;
15561551 uint32_t waitForComplitionCalledTimes = 0 ;
15571552 uint32_t waitForTaskCountWithKmdNotifyFallbackCalled = 0 ;
15581553 uint32_t partitionCountSet = 0 ;
1559- uint32_t offsetSizeSet = 0 ;
15601554 bool enableTimeoutSet = false ;
15611555};
15621556
@@ -1634,73 +1628,81 @@ HWTEST_F(CommandQueueSynchronizeTest, givenDebugOverrideEnabledWhenCallToSynchro
16341628}
16351629
16361630HWTEST_F (CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenCallingSynchronizeThenExpectTheSameNumberCsrSynchronizeCalls) {
1637- auto csr = std::unique_ptr<SynchronizeCsr<FamilyType>>(new SynchronizeCsr<FamilyType>(*device->getNEODevice ()->getExecutionEnvironment (),
1638- device->getNEODevice ()->getDeviceBitfield ()));
1639- csr->setupContext (*device->getNEODevice ()->getDefaultEngine ().osContext );
1640-
16411631 const ze_command_queue_desc_t desc{};
16421632 ze_result_t returnValue;
1633+
1634+ auto csr = reinterpret_cast <NEO::UltCommandStreamReceiver<FamilyType> *>(neoDevice->getDefaultEngine ().commandStreamReceiver );
1635+ volatile uint32_t *tagAddress = csr->getTagAddress ();
1636+ for (uint32_t i = 0 ; i < 2 ; i++) {
1637+ *tagAddress = 0xFF ;
1638+ tagAddress = ptrOffset (tagAddress, 8 );
1639+ }
16431640 auto commandQueue = whitebox_cast (CommandQueue::create (productFamily,
16441641 device,
1645- csr. get () ,
1642+ neoDevice-> getDefaultEngine (). commandStreamReceiver ,
16461643 &desc,
16471644 false ,
16481645 false ,
16491646 returnValue));
16501647 EXPECT_EQ (returnValue, ZE_RESULT_SUCCESS);
16511648 ASSERT_NE (nullptr , commandQueue);
16521649
1653- commandQueue->partitionCount = 2 ;
1650+ auto commandList = std::unique_ptr<CommandList>(whitebox_cast (CommandList::create (productFamily, device, NEO::EngineGroupType::RenderCompute, 0u , returnValue)));
1651+ ASSERT_NE (nullptr , commandList);
1652+ commandList->partitionCount = 2 ;
1653+
1654+ ze_command_list_handle_t cmdListHandle = commandList->toHandle ();
1655+ commandQueue->executeCommandLists (1 , &cmdListHandle, nullptr , false );
1656+
16541657 uint64_t timeout = std::numeric_limits<uint64_t >::max ();
16551658 commandQueue->synchronize (timeout);
16561659
1657- EXPECT_EQ (1u , csr->waitForComplitionCalledTimes );
1658- EXPECT_EQ (2u , csr->partitionCountSet );
1659- EXPECT_EQ (8u , csr->offsetSizeSet );
1660+ EXPECT_EQ (2u , csr->activePartitions );
16601661
16611662 L0::CommandQueue::fromHandle (commandQueue)->destroy ();
16621663}
16631664
1664- template <typename GfxFamily>
1665- struct TestCmdQueueCsr : public NEO ::UltCommandStreamReceiver<GfxFamily> {
1666- TestCmdQueueCsr (const NEO::ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
1667- : NEO::UltCommandStreamReceiver<GfxFamily>(const_cast <NEO::ExecutionEnvironment &>(executionEnvironment), 0 , deviceBitfield) {
1668- }
1669- MOCK_METHOD3 (waitForCompletionWithTimeout, bool (bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait));
1670- MOCK_METHOD6 (waitForCompletionWithTimeout, bool (volatile uint32_t *pollAddress, bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait, uint32_t partitionCount, uint32_t offsetSize));
1671- };
1672-
1673- HWTEST_F (CommandQueueSynchronizeTest, givenSinglePartitionCountWhenWaitFunctionFailsThenReturnNotReady) {
1674- auto csr = std::unique_ptr<TestCmdQueueCsr<FamilyType>>(new TestCmdQueueCsr<FamilyType>(*device->getNEODevice ()->getExecutionEnvironment (),
1675- device->getNEODevice ()->getDeviceBitfield ()));
1676- csr->setupContext (*device->getNEODevice ()->getDefaultEngine ().osContext );
1677-
1665+ HWTEST_F (CommandQueueSynchronizeTest, givenCsrHasMultipleActivePartitionWhenExecutingCmdListOnNewCmdQueueThenExpectCmdPartitionCountMatchCsrActivePartitions) {
16781666 const ze_command_queue_desc_t desc{};
16791667 ze_result_t returnValue;
1668+
1669+ auto csr = reinterpret_cast <NEO::UltCommandStreamReceiver<FamilyType> *>(neoDevice->getDefaultEngine ().commandStreamReceiver );
1670+ volatile uint32_t *tagAddress = csr->getTagAddress ();
1671+ for (uint32_t i = 0 ; i < 2 ; i++) {
1672+ *tagAddress = 0xFF ;
1673+ tagAddress = ptrOffset (tagAddress, 8 );
1674+ }
1675+ csr->activePartitions = 2u ;
16801676 auto commandQueue = whitebox_cast (CommandQueue::create (productFamily,
16811677 device,
1682- csr. get () ,
1678+ neoDevice-> getDefaultEngine (). commandStreamReceiver ,
16831679 &desc,
16841680 false ,
16851681 false ,
16861682 returnValue));
16871683 EXPECT_EQ (returnValue, ZE_RESULT_SUCCESS);
16881684 ASSERT_NE (nullptr , commandQueue);
16891685
1690- EXPECT_CALL (*csr, waitForCompletionWithTimeout (::testing::_,
1691- ::testing::_,
1692- ::testing::_))
1693- .Times (1 )
1694- .WillOnce (::testing::Return (false ));
1686+ auto commandList = std::unique_ptr<CommandList>(whitebox_cast (CommandList::create (productFamily, device, NEO::EngineGroupType::RenderCompute, 0u , returnValue)));
1687+ ASSERT_NE (nullptr , commandList);
16951688
1696- uint64_t timeout = std::numeric_limits<uint64_t >::max ();
1697- returnValue = commandQueue->synchronize (timeout);
1698- EXPECT_EQ (returnValue, ZE_RESULT_NOT_READY);
1689+ ze_command_list_handle_t cmdListHandle = commandList->toHandle ();
1690+ commandQueue->executeCommandLists (1 , &cmdListHandle, nullptr , false );
16991691
1700- commandQueue->destroy ();
1692+ EXPECT_EQ (2u , commandQueue->partitionCount );
1693+
1694+ L0::CommandQueue::fromHandle (commandQueue)->destroy ();
17011695}
17021696
1703- HWTEST_F (CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenWaitFunctionFailsThenReturnNotReady) {
1697+ template <typename GfxFamily>
1698+ struct TestCmdQueueCsr : public NEO ::UltCommandStreamReceiver<GfxFamily> {
1699+ TestCmdQueueCsr (const NEO::ExecutionEnvironment &executionEnvironment, const DeviceBitfield deviceBitfield)
1700+ : NEO::UltCommandStreamReceiver<GfxFamily>(const_cast <NEO::ExecutionEnvironment &>(executionEnvironment), 0 , deviceBitfield) {
1701+ }
1702+ MOCK_METHOD3 (waitForCompletionWithTimeout, bool (bool enableTimeout, int64_t timeoutMs, uint32_t taskCountToWait));
1703+ };
1704+
1705+ HWTEST_F (CommandQueueSynchronizeTest, givenSinglePartitionCountWhenWaitFunctionFailsThenReturnNotReady) {
17041706 auto csr = std::unique_ptr<TestCmdQueueCsr<FamilyType>>(new TestCmdQueueCsr<FamilyType>(*device->getNEODevice ()->getExecutionEnvironment (),
17051707 device->getNEODevice ()->getDeviceBitfield ()));
17061708 csr->setupContext (*device->getNEODevice ()->getDefaultEngine ().osContext );
@@ -1718,15 +1720,11 @@ HWTEST_F(CommandQueueSynchronizeTest, givenMultiplePartitionCountWhenWaitFunctio
17181720 ASSERT_NE (nullptr , commandQueue);
17191721
17201722 EXPECT_CALL (*csr, waitForCompletionWithTimeout (::testing::_,
1721- ::testing::_,
1722- ::testing::_,
1723- ::testing::_,
17241723 ::testing::_,
17251724 ::testing::_))
17261725 .Times (1 )
17271726 .WillOnce (::testing::Return (false ));
17281727
1729- commandQueue->partitionCount = 2 ;
17301728 uint64_t timeout = std::numeric_limits<uint64_t >::max ();
17311729 returnValue = commandQueue->synchronize (timeout);
17321730 EXPECT_EQ (returnValue, ZE_RESULT_NOT_READY);
0 commit comments