diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp index c0dca161c1..75d45f72c7 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_3_tests.cpp @@ -10,6 +10,7 @@ #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/dispatch_flags_helper.h" #include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/ult_device_factory.h" #include "opencl/source/helpers/hardware_commands_helper.h" #include "opencl/source/mem_obj/buffer.h" @@ -1941,3 +1942,37 @@ TEST(MultiRootDeviceCommandStreamReceiverTests, givenMultipleEventInMultiRootDev EXPECT_EQ(2u, mockCsr3->waitForCompletionWithTimeoutCalled); } } + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenStaticPartitioningEnabledWhenFlushingTaskThenWorkPartitionAllocationIsMadeResident) { + DebugManagerStateRestore restore{}; + DebugManager.flags.EnableStaticPartitioning.set(1); + DebugManager.flags.ForcePreemptionMode.set(PreemptionMode::Disabled); + UltDeviceFactory deviceFactory{1, 2}; + MockDevice *device = deviceFactory.rootDevices[0]; + auto &mockCsr = device->getUltCommandStreamReceiver(); + ASSERT_NE(nullptr, mockCsr.getWorkPartitionAllocation()); + + auto mockedSubmissionsAggregator = new mockSubmissionsAggregator(); + mockCsr.overrideDispatchPolicy(DispatchMode::BatchedDispatch); + mockCsr.submissionAggregator.reset(mockedSubmissionsAggregator); + + DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); + mockCsr.flushTask(commandStream, + 0, + dsh, + ioh, + ssh, + taskLevel, + dispatchFlags, + *device); + + auto cmdBuffer = mockedSubmissionsAggregator->peekCommandBuffers().peekHead(); + bool found = false; + for (auto allocation : cmdBuffer->surfaces) { + if (allocation == mockCsr.getWorkPartitionAllocation()) { + found = true; + break; + } + } + EXPECT_TRUE(found); +} 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 d205d0f6b7..c78f7869d1 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -506,6 +506,10 @@ CompletionStamp CommandStreamReceiverHw::flushTask( experimentalCmdBuffer->makeResidentAllocations(); } + if (workPartitionAllocation) { + makeResident(*workPartitionAllocation); + } + // If the CSR has work in its CS, flush it before the task bool submitTask = commandStreamStartTask != commandStreamTask.getUsed(); bool submitCSR = (commandStreamStartCSR != commandStreamCSR.getUsed()) || this->isMultiOsContextCapable();