From eff4e05c4452f81e4805095a2fea1c4f76b6f4c5 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Thu, 11 Dec 2025 09:11:26 +0000 Subject: [PATCH] fix: remove not needed check Signed-off-by: Bartosz Dunajski --- .../hardware_interface_xehp_and_later.inl | 6 +- .../command_queue/command_queue_tests.cpp | 66 +++++++++++++++++++ .../get_size_required_image_tests.cpp | 3 + .../enqueue_tests_xe2_hpg_core.cpp | 34 ---------- .../xe_hpc_core/enqueue_tests_xe_hpc_core.cpp | 32 --------- 5 files changed, 71 insertions(+), 70 deletions(-) diff --git a/opencl/source/command_queue/hardware_interface_xehp_and_later.inl b/opencl/source/command_queue/hardware_interface_xehp_and_later.inl index 2c70a24663..b310b9a9e8 100644 --- a/opencl/source/command_queue/hardware_interface_xehp_and_later.inl +++ b/opencl/source/command_queue/hardware_interface_xehp_and_later.inl @@ -123,10 +123,8 @@ inline void HardwareInterface::programWalker( } auto isCcsUsed = EngineHelpers::isCcs(commandQueue.getGpgpuEngine().osContext->getEngineType()); - if constexpr (heaplessModeEnabled == false) { - if (auto kernelAllocation = kernelInfo.getIsaGraphicsAllocation()) { - EncodeMemoryPrefetch::programMemoryPrefetch(commandStream, *kernelAllocation, kernelInfo.heapInfo.kernelHeapSize, kernelInfo.getIsaOffsetInParentAllocation(), rootDeviceEnvironment); - } + if (auto kernelAllocation = kernelInfo.getIsaGraphicsAllocation()) { + EncodeMemoryPrefetch::programMemoryPrefetch(commandStream, *kernelAllocation, kernelInfo.heapInfo.kernelHeapSize, kernelInfo.getIsaOffsetInParentAllocation(), rootDeviceEnvironment); } GpgpuWalkerHelper::template setGpgpuWalkerThreadData(&walkerCmd, kernelInfo.kernelDescriptor, startWorkGroups, diff --git a/opencl/test/unit_test/command_queue/command_queue_tests.cpp b/opencl/test/unit_test/command_queue/command_queue_tests.cpp index 79285d38d7..5d1d100b4e 100644 --- a/opencl/test/unit_test/command_queue/command_queue_tests.cpp +++ b/opencl/test/unit_test/command_queue/command_queue_tests.cpp @@ -9,6 +9,7 @@ #include "shared/source/command_stream/command_stream_receiver.h" #include "shared/source/command_stream/wait_status.h" #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/array_count.h" #include "shared/source/helpers/bcs_ccs_dependency_pair_container.h" #include "shared/source/helpers/compiler_product_helper.h" @@ -17,6 +18,7 @@ #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/memory_manager/migration_sync_data.h" #include "shared/source/os_interface/product_helper.h" +#include "shared/test/common/cmd_parse/hw_parse.h" #include "shared/test/common/fixtures/memory_management_fixture.h" #include "shared/test/common/helpers/debug_manager_state_restore.h" #include "shared/test/common/helpers/raii_gfx_core_helper.h" @@ -36,6 +38,7 @@ #include "opencl/source/event/user_event.h" #include "opencl/source/sharings/sharing.h" #include "opencl/test/unit_test/command_queue/command_queue_fixture.h" +#include "opencl/test/unit_test/command_queue/hardware_interface_helper.h" #include "opencl/test/unit_test/command_stream/command_stream_fixture.h" #include "opencl/test/unit_test/fixtures/buffer_fixture.h" #include "opencl/test/unit_test/fixtures/cl_device_fixture.h" @@ -3647,3 +3650,66 @@ HWTEST2_F(CommandQueueTests, givenCmdQueueWhenPlatformWithStatelessNotDisableWit EXPECT_FALSE(mockCmdQ->isForceStateless); } + +struct PrefetchTests : public ::testing::Test { + void SetUp() override { + debugManager.flags.EnableMemoryPrefetch.set(1); + + clDevice = std::make_unique(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get(), mockRootDeviceIndex)); + context = std::make_unique(clDevice.get()); + + mockKernel = std::make_unique(*clDevice, context.get()); + mockKernel->kernelInfo.createKernelAllocation(clDevice->getDevice(), false); + + dispatchInfo = {clDevice.get(), mockKernel->mockKernel, 1, 0, 0, 0}; + } + + void TearDown() override { + clDevice->getMemoryManager()->freeGraphicsMemory(mockKernel->kernelInfo.getIsaGraphicsAllocation()); + } + + template + std::unique_ptr> createCommandQueue() { + return std::make_unique>(context.get(), clDevice.get(), nullptr); + } + + DebugManagerStateRestore restore; + std::unique_ptr clDevice; + std::unique_ptr context; + std::unique_ptr mockKernel; + DispatchInfo dispatchInfo; +}; + +HWTEST2_F(PrefetchTests, givenKernelWhenWalkerIsProgrammedThenPrefetchIsaBeforeWalker, IsAtLeastXeHpcCore) { + using WalkerType = typename FamilyType::DefaultWalkerType; + using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; + + auto commandQueue = createCommandQueue(); + auto &commandStream = commandQueue->getCS(1024); + + auto &heap = commandQueue->getIndirectHeap(IndirectHeap::Type::dynamicState, 1); + size_t workSize[] = {1, 1, 1}; + Vec3 wgInfo = {1, 1, 1}; + + mockKernel->kernelInfo.heapInfo.kernelHeapSize = 1; + + HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(workSize, wgInfo, PreemptionMode::Disabled); + + HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, heap, heap, heap, dispatchInfo, walkerArgs); + + HardwareParse hwParse; + hwParse.parseCommands(commandStream, 0); + auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); + EXPECT_NE(hwParse.cmdList.end(), itorWalker); + + auto itorStatePrefetch = find(hwParse.cmdList.begin(), itorWalker); + EXPECT_NE(itorWalker, itorStatePrefetch); + + auto statePrefetchCmd = genCmdCast(*itorStatePrefetch); + EXPECT_NE(nullptr, statePrefetchCmd); + + auto gmmHelper = clDevice->getRootDeviceEnvironment().getGmmHelper(); + + EXPECT_EQ(gmmHelper->decanonize(mockKernel->kernelInfo.getIsaGraphicsAllocation()->getGpuAddress()), statePrefetchCmd->getAddress()); + EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); +} \ No newline at end of file diff --git a/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp b/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp index d41d6a3945..0fe9fb68c6 100644 --- a/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/get_size_required_image_tests.cpp @@ -230,6 +230,7 @@ HWTEST_F(GetSizeRequiredImageTest, WhenReadingImageNonBlockingThenHeapsAndComman // Since each enqueue* may flush, we may see a MI_BATCH_BUFFER_END appended. expectedSizeCS += sizeof(typename FamilyType::MI_BATCH_BUFFER_END); + expectedSizeCS += sizeof(typename FamilyType::PIPE_CONTROL); // tag update expectedSizeCS = alignUp(expectedSizeCS, MemoryConstants::cacheLineSize); EXPECT_GE(expectedSizeCS, usedAfterCS - usedBeforeCS); @@ -287,6 +288,7 @@ HWTEST_F(GetSizeRequiredImageTest, WhenReadingImageBlockingThenHeapsAndCommandBu // Since each enqueue* may flush, we may see a MI_BATCH_BUFFER_END appended. expectedSizeCS += sizeof(typename FamilyType::MI_BATCH_BUFFER_END); + expectedSizeCS += sizeof(typename FamilyType::PIPE_CONTROL); // tag update expectedSizeCS = alignUp(expectedSizeCS, MemoryConstants::cacheLineSize); EXPECT_GE(expectedSizeCS, usedAfterCS - usedBeforeCS); @@ -401,6 +403,7 @@ HWTEST_F(GetSizeRequiredImageTest, WhenWritingImageBlockingThenHeapsAndCommandBu // Since each enqueue* may flush, we may see a MI_BATCH_BUFFER_END appended. expectedSizeCS += sizeof(typename FamilyType::MI_BATCH_BUFFER_END); + expectedSizeCS += sizeof(typename FamilyType::PIPE_CONTROL); // tag update expectedSizeCS = alignUp(expectedSizeCS, MemoryConstants::cacheLineSize); EXPECT_GE(expectedSizeCS, usedAfterCS - usedBeforeCS); diff --git a/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp b/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp index 1372423107..c417e0216f 100644 --- a/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp +++ b/opencl/test/unit_test/xe2_hpg_core/enqueue_tests_xe2_hpg_core.cpp @@ -62,40 +62,6 @@ struct EnqueueFixtureXe2HpgCore : public ::testing::Test { using MemoryPrefetchTestsXe2HpgCore = EnqueueFixtureXe2HpgCore; -XE2_HPG_CORETEST_F(MemoryPrefetchTestsXe2HpgCore, givenKernelWhenWalkerIsProgrammedThenPrefetchIsaBeforeWalker) { - using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; - using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; - - auto commandQueue = createCommandQueue(); - auto &commandStream = commandQueue->getCS(1024); - - auto &heap = commandQueue->getIndirectHeap(IndirectHeap::Type::dynamicState, 1); - size_t workSize[] = {1, 1, 1}; - Vec3 wgInfo = {1, 1, 1}; - - mockKernel->kernelInfo.heapInfo.kernelHeapSize = 1; - - HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(workSize, wgInfo, PreemptionMode::Disabled); - - HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, heap, heap, heap, dispatchInfo, walkerArgs); - - HardwareParse hwParse; - hwParse.parseCommands(commandStream, 0); - auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); - EXPECT_NE(hwParse.cmdList.end(), itorWalker); - - auto itorStatePrefetch = find(hwParse.cmdList.begin(), itorWalker); - EXPECT_NE(itorWalker, itorStatePrefetch); - - auto statePrefetchCmd = genCmdCast(*itorStatePrefetch); - EXPECT_NE(nullptr, statePrefetchCmd); - - auto gmmHelper = clDevice->getRootDeviceEnvironment().getGmmHelper(); - - EXPECT_EQ(gmmHelper->decanonize(mockKernel->kernelInfo.getIsaGraphicsAllocation()->getGpuAddress()), statePrefetchCmd->getAddress()); - EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); -} - XE2_HPG_CORETEST_F(MemoryPrefetchTestsXe2HpgCore, givenPrefetchEnabledWhenEstimatingCommandsSizeThenAddStatePrefetch) { auto commandQueue = createCommandQueue(); diff --git a/opencl/test/unit_test/xe_hpc_core/enqueue_tests_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/enqueue_tests_xe_hpc_core.cpp index 0a93a61db4..54ef6b05c0 100644 --- a/opencl/test/unit_test/xe_hpc_core/enqueue_tests_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/enqueue_tests_xe_hpc_core.cpp @@ -62,38 +62,6 @@ struct EnqueueFixtureXeHpcCore : public ::testing::Test { using MemoryPrefetchTestsXeHpcCore = EnqueueFixtureXeHpcCore; -XE_HPC_CORETEST_F(MemoryPrefetchTestsXeHpcCore, givenKernelWhenWalkerIsProgrammedThenPrefetchIsaBeforeWalker) { - using COMPUTE_WALKER = typename FamilyType::COMPUTE_WALKER; - using STATE_PREFETCH = typename FamilyType::STATE_PREFETCH; - - auto commandQueue = createCommandQueue(); - auto &commandStream = commandQueue->getCS(1024); - - auto &heap = commandQueue->getIndirectHeap(IndirectHeap::Type::dynamicState, 1); - size_t workSize[] = {1, 1, 1}; - Vec3 wgInfo = {1, 1, 1}; - - HardwareInterfaceWalkerArgs walkerArgs = createHardwareInterfaceWalkerArgs(workSize, wgInfo, PreemptionMode::Disabled); - - mockKernel->kernelInfo.heapInfo.kernelHeapSize = 1; - HardwareInterface::template programWalker(commandStream, *mockKernel->mockKernel, *commandQueue, - heap, heap, heap, dispatchInfo, walkerArgs); - - HardwareParse hwParse; - hwParse.parseCommands(commandStream, 0); - auto itorWalker = find(hwParse.cmdList.begin(), hwParse.cmdList.end()); - EXPECT_NE(hwParse.cmdList.end(), itorWalker); - - auto itorStatePrefetch = find(hwParse.cmdList.begin(), itorWalker); - EXPECT_NE(itorWalker, itorStatePrefetch); - - auto statePrefetchCmd = genCmdCast(*itorStatePrefetch); - EXPECT_NE(nullptr, statePrefetchCmd); - - EXPECT_EQ(mockKernel->kernelInfo.getIsaGraphicsAllocation()->getGpuAddress(), statePrefetchCmd->getAddress()); - EXPECT_TRUE(statePrefetchCmd->getKernelInstructionPrefetch()); -} - XE_HPC_CORETEST_F(MemoryPrefetchTestsXeHpcCore, givenPrefetchEnabledWhenEstimatingCommandsSizeThenAddStatePrefetch) { auto commandQueue = createCommandQueue();