diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp index ea92b5759a..2cd82acb06 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_1_tests.cpp @@ -600,6 +600,60 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNotApplicableGrfConfigWhenFlu } } +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenMultiOsContextCapableSetAndDispatchFlagsWhenFlushingTaskThenReloadSbaProperly) { + using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; + auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); + + // 1. Ignore dispatchFlags.useGlobalAtomics flip if csr is not multi context capable + commandStreamReceiver.multiOsContextCapable = false; + + flushTaskFlags.useGlobalAtomics = false; + auto offset = commandStreamReceiver.commandStream.getUsed(); + flushTask(commandStreamReceiver); + + parseCommands(commandStreamReceiver.commandStream, 0); + auto stateBaseAddressItor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), stateBaseAddressItor); + + flushTaskFlags.useGlobalAtomics ^= true; + offset = commandStreamReceiver.commandStream.getUsed(); + flushTask(commandStreamReceiver); + + cmdList.clear(); + parseCommands(commandStreamReceiver.commandStream, offset); + stateBaseAddressItor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), stateBaseAddressItor); + + // 2. Reprogram SBA only if dispatchFlags.useGlobalAtomics flips and csr is multi context capable + commandStreamReceiver.multiOsContextCapable = true; + + flushTaskFlags.useGlobalAtomics = true; + offset = commandStreamReceiver.commandStream.getUsed(); + flushTask(commandStreamReceiver); + + cmdList.clear(); + parseCommands(commandStreamReceiver.commandStream, offset); + stateBaseAddressItor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), stateBaseAddressItor); + + flushTaskFlags.useGlobalAtomics ^= true; + offset = commandStreamReceiver.commandStream.getUsed(); + flushTask(commandStreamReceiver); + + cmdList.clear(); + parseCommands(commandStreamReceiver.commandStream, offset); + stateBaseAddressItor = find(cmdList.begin(), cmdList.end()); + EXPECT_NE(cmdList.end(), stateBaseAddressItor); + + offset = commandStreamReceiver.commandStream.getUsed(); + flushTask(commandStreamReceiver); + + cmdList.clear(); + parseCommands(commandStreamReceiver.commandStream, offset); + stateBaseAddressItor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), stateBaseAddressItor); +} + HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenPreambleNotSentWhenFlushingTaskThenPreambleIsSent) { auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver(); commandStreamReceiver.isPreambleSent = false; diff --git a/shared/source/command_stream/command_stream_receiver_hw_base.inl b/shared/source/command_stream/command_stream_receiver_hw_base.inl index 1e2006edd6..1ea19f11d2 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -375,7 +375,7 @@ CompletionStamp CommandStreamReceiverHw::flushTask( latestSentStatelessMocsConfig = mocsIndex; } - if (dispatchFlags.useGlobalAtomics != lastSentUseGlobalAtomics) { + if (isMultiOsContextCapable() && (dispatchFlags.useGlobalAtomics != lastSentUseGlobalAtomics)) { isStateBaseAddressDirty = true; lastSentUseGlobalAtomics = dispatchFlags.useGlobalAtomics; }