diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp index 84aba60be0..3b792cd8a3 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_signal_event.cpp @@ -379,6 +379,7 @@ HWTEST_F(CommandListAppendSignalEvent, givenInOrderImmediateCmdListWhenAppending using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; using MI_BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; + using StallingBarrierType = typename FamilyType::StallingBarrierType; ze_event_pool_desc_t eventPoolDesc = {}; eventPoolDesc.count = 1; @@ -446,7 +447,7 @@ HWTEST_F(CommandListAppendSignalEvent, givenInOrderImmediateCmdListWhenAppending GenCmdList::iterator itorResolveCmd = itorBbStart; if (NEO::MemorySynchronizationCommands::getDcFlushEnable(true, neoDevice->getRootDeviceEnvironment())) { - itorResolveCmd = find(cmdList.begin(), itorBbStart); + itorResolveCmd = find(cmdList.begin(), itorBbStart); } else { itorResolveCmd = find(cmdList.begin(), itorBbStart); } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp index 72149fcc4a..0778604526 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_in_order_cmdlist_1.cpp @@ -993,7 +993,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenResolveDependenciesViaPip ptrOffset(cmdStream->getCpuBase(), offset), cmdStream->getUsed() - offset)); - auto itor = find(cmdList.begin(), cmdList.end()); + auto itor = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itor); completeHostAddress>>(immCmdList.get()); @@ -1024,7 +1024,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenOptimizedCbEventWhenSubmi cmdStream->getUsed() - offset)); if (immCmdList->dcFlushSupport || !immCmdList->isHeaplessModeEnabled()) { - auto itor = find(cmdList.begin(), cmdList.end()); + auto itor = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itor); } else { auto itor = find(cmdList.begin(), cmdList.end()); @@ -1059,7 +1059,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, InOrderCmdListTests, givenInOrderCmdListWhenSubmitt cmdStream->getUsed() - offset)); if (immCmdList->dcFlushSupport) { - auto itor = find(cmdList.begin(), cmdList.end()); + auto itor = find(cmdList.begin(), cmdList.end()); ASSERT_NE(cmdList.end(), itor); } else { auto itor = find(cmdList.begin(), cmdList.end()); diff --git a/opencl/source/command_queue/gpgpu_walker_base.inl b/opencl/source/command_queue/gpgpu_walker_base.inl index 831ab5afaf..b971831f3c 100644 --- a/opencl/source/command_queue/gpgpu_walker_base.inl +++ b/opencl/source/command_queue/gpgpu_walker_base.inl @@ -99,7 +99,7 @@ size_t EnqueueOperation::getTotalSizeRequiredCS(uint32_t eventType, c expectedSizeCS += TimestampPacketHelper::getRequiredCmdStreamSize(csrDeps, relaxedOrderingEnabled); expectedSizeCS += EnqueueOperation::getSizeRequiredForTimestampPacketWrite(); if (resolveDependenciesByPipecontrol) { - expectedSizeCS += MemorySynchronizationCommands::getSizeForSingleBarrier(); + expectedSizeCS += MemorySynchronizationCommands::getSizeForStallingBarrier(); } if (isMarkerWithProfiling) { if (!eventsInWaitlist) { diff --git a/opencl/test/unit_test/command_queue/dispatch_walker_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_queue/dispatch_walker_tests_xehp_and_later.cpp index 741de05aaf..1f8fd6bc52 100644 --- a/opencl/test/unit_test/command_queue/dispatch_walker_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_queue/dispatch_walker_tests_xehp_and_later.cpp @@ -586,7 +586,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, XeHPAndLaterDispatchWalkerBasicTest, givenTimestamp size_t additionalSize = 0u; if (isResolveDependenciesByPipeControlsEnabled) { - additionalSize = MemorySynchronizationCommands::getSizeForSingleBarrier(); + additionalSize = MemorySynchronizationCommands::getSizeForStallingBarrier(); } EXPECT_EQ(sizeWithEnabled, sizeWithDisabled + additionalSize); diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp index 2d5fa4562d..6e35a65192 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp @@ -2179,7 +2179,7 @@ HWTEST_F(PauseOnGpuTests, givenGpuScratchWriteEnabledWhenEstimatingCommandStream EXPECT_EQ(baseCommandStreamSize + sizeof(typename FamilyType::MI_LOAD_REGISTER_IMM), extendedCommandStreamSize); } -HWTEST_F(PauseOnGpuTests, givenResolveDependenciesByPipecontrolWhenEstimatingCommandStreamSizeThenPipeControlSizeIsIncluded) { +HWTEST_F(PauseOnGpuTests, givenResolveDependenciesByPipecontrolWhenEstimatingCommandStreamSizeThenStallingBarrierSizeIsIncluded) { MockKernelWithInternals mockKernel(*pClDevice); DispatchInfo dispatchInfo; MultiDispatchInfo multiDispatchInfo(mockKernel.mockKernel); @@ -2192,7 +2192,7 @@ HWTEST_F(PauseOnGpuTests, givenResolveDependenciesByPipecontrolWhenEstimatingCom auto extendedCommandStreamSize = EnqueueOperation::getTotalSizeRequiredCS(CL_COMMAND_NDRANGE_KERNEL, {}, false, false, false, *pCmdQ, multiDispatchInfo, false, false, true, nullptr); - EXPECT_EQ(baseCommandStreamSize + MemorySynchronizationCommands::getSizeForSingleBarrier(), extendedCommandStreamSize); + EXPECT_EQ(baseCommandStreamSize + MemorySynchronizationCommands::getSizeForStallingBarrier(), extendedCommandStreamSize); } HWTEST_F(PauseOnGpuTests, givenTimestampPacketWriteDisabledAndMarkerWithProfilingWhenEstimatingCommandStreamSizeThenStoreMMIOSizeIsIncluded) { 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 253bc3c9cb..daa2ad30ab 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 @@ -393,38 +393,28 @@ HWCMDTEST_F(IGFX_GEN12LP_CORE, CommandStreamReceiverFlushTaskTests, WhenForcePip GenCmdList::iterator itor = cmdList.begin(); int counterPC = 0; while (itor != cmdList.end()) { - auto pipeControl = genCmdCast(*itor); - if (pipeControl) { - switch (counterPC) { - case 0: // First pipe control with CS Stall - EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); - EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), false); - EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getTlbInvalidate()), false); - break; - case 1: // Second pipe control with all flushes - EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); - EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), true); - EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getTlbInvalidate()), true); - default: - break; - } + if (counterPC == 0 && isStallingBarrier(itor)) { counterPC++; + itor++; + continue; + } + auto pipeControl = genCmdCast(*itor); + if (pipeControl != nullptr) { + // Second pipe control with all flushes + EXPECT_EQ(1, counterPC); + EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); + EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), true); + EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getTlbInvalidate()), true); + counterPC++; + break; } - ++itor; } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp index 0ff5441543..24cd6d41a2 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp @@ -372,36 +372,28 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, Wh GenCmdList::iterator itor = cmdList.begin(); int counterPC = 0; while (itor != cmdList.end()) { - auto pipeControl = genCmdCast(*itor); - if (pipeControl) { - switch (counterPC) { - case 0: // First pipe control with CS Stall - EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); - EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), false); - EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), false); - EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), false); - EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), false); - break; - case 1: // Second pipe control with all flushes - EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); - EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), true); - EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), true); - EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), true); - EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), true); - default: - break; - } + if (counterPC == 0 && isStallingBarrier(itor)) { counterPC++; + itor++; + continue; + } + auto pipeControl = genCmdCast(*itor); + if (pipeControl != nullptr) { + // Second pipe control with all flushes + EXPECT_EQ(1, counterPC); + EXPECT_EQ(bool(pipeControl->getCommandStreamerStallEnable()), true); + EXPECT_EQ(bool(pipeControl->getDcFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getRenderTargetCacheFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getInstructionCacheInvalidateEnable()), true); + EXPECT_EQ(bool(pipeControl->getTextureCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getPipeControlFlushEnable()), true); + EXPECT_EQ(bool(pipeControl->getVfCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getConstantCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getStateCacheInvalidationEnable()), true); + EXPECT_EQ(bool(pipeControl->getTlbInvalidate()), true); + counterPC++; + break; } - ++itor; } diff --git a/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp index b69125ffd7..f533b7ec74 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_1_tests.cpp @@ -227,7 +227,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEstimatingStr size_t sizeForPipeControl = 0; if (isResolveDependenciesByPipeControlsEnabled) { - sizeForPipeControl = MemorySynchronizationCommands::getSizeForSingleBarrier(); + sizeForPipeControl = MemorySynchronizationCommands::getSizeForStallingBarrier(); } size_t extendedSize = sizeWithDisabled + EnqueueOperation::getSizeRequiredForTimestampPacketWrite() + sizeForNodeDependency + sizeForPipeControl; @@ -1656,6 +1656,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledAndDependenciesRe using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END; + using StallingBarrierType = typename FamilyType::StallingBarrierType; device->getUltCommandStreamReceiver().timestampPacketWriteEnabled = true; @@ -1687,9 +1688,11 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledAndDependenciesRe size_t pipeControlCountSecondEnqueue = 0u; size_t semaphoreWaitCount = 0u; size_t currentEnqueue = 1u; + bool stallingBarrierProgrammed = false; while (it != hwParser.cmdList.end()) { MI_SEMAPHORE_WAIT *semaphoreWaitCmd = genCmdCast(*it); PIPE_CONTROL *pipeControlCmd = genCmdCast(*it); + StallingBarrierType *stallingBarrierCmd = genCmdCast(*it); MI_BATCH_BUFFER_END *miBatchBufferEnd = genCmdCast(*it); if (pipeControlCmd != nullptr) { if (currentEnqueue == 1) { @@ -1697,6 +1700,9 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledAndDependenciesRe } else if (currentEnqueue == 2) { ++pipeControlCountSecondEnqueue; } + } else if (stallingBarrierCmd != nullptr) { + EXPECT_EQ(2u, currentEnqueue); + stallingBarrierProgrammed = true; } else if (semaphoreWaitCmd != nullptr) { ++semaphoreWaitCount; } else if (miBatchBufferEnd != nullptr) { @@ -1707,7 +1713,8 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledAndDependenciesRe ++it; } EXPECT_EQ(semaphoreWaitCount, 0u); - EXPECT_EQ(pipeControlCountSecondEnqueue, pipeControlCountFirstEnqueue + 1); + auto stallingBarrierAsPC = stallingBarrierProgrammed ? 0 : 1; + EXPECT_EQ(pipeControlCountSecondEnqueue, pipeControlCountFirstEnqueue + stallingBarrierAsPC); } HWTEST2_F(TimestampPacketTests, givenTimestampPacketWriteEnabledAndDependenciesResolvedViaPipeControlsAndSingleIOQWhenEnqueueKernelThenDoNotProgramSemaphoresButProgramPipeControlWithProperFlagsBeforeGpgpuWalker, IsXeHpgCore) { diff --git a/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp b/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp index c07564718e..9df9f6a9d6 100644 --- a/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp +++ b/opencl/test/unit_test/helpers/timestamp_packet_2_tests.cpp @@ -246,7 +246,6 @@ HWTEST_F(TimestampPacketTests, whenEnqueueingBarrierThenDontRequestPipeControlOn HWTEST_F(TimestampPacketTests, givenWaitlistWhenEnqueueingBarrierThenProgramNonStallingBarrier) { using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT; using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; auto &csr = device->getUltCommandStreamReceiver(); csr.timestampPacketWriteEnabled = true; @@ -273,7 +272,7 @@ HWTEST_F(TimestampPacketTests, givenWaitlistWhenEnqueueingBarrierThenProgramNonS auto it = hwParser.cmdList.begin(); if (device->getProductHelper().isResolveDependenciesByPipeControlsSupported(device->getHardwareInfo(), false, cmdQ.taskCount, cmdQ.getGpgpuCommandStreamReceiver())) { - EXPECT_NE(nullptr, genCmdCast(*it)); + EXPECT_TRUE(hwParser.isStallingBarrier(it)); } else { EXPECT_NE(nullptr, genCmdCast(*it)); EXPECT_NE(nullptr, genCmdCast(*(++it))); diff --git a/shared/source/command_container/command_encoder_tgllp_and_later.inl b/shared/source/command_container/command_encoder_tgllp_and_later.inl index 8aedae7c26..af14fa2fd7 100644 --- a/shared/source/command_container/command_encoder_tgllp_and_later.inl +++ b/shared/source/command_container/command_encoder_tgllp_and_later.inl @@ -26,7 +26,7 @@ size_t EncodeComputeMode::getCmdSizeForComputeMode(const RootDeviceEnvir } size += sizeof(typename Family::STATE_COMPUTE_MODE); if (hasSharedHandles) { - size += MemorySynchronizationCommands::getSizeForSingleBarrier(); + size += MemorySynchronizationCommands::getSizeForStallingBarrier(); } if (productHelper.is3DPipelineSelectWARequired() && isRcs) { size += (2 * PreambleHelper::getCmdSizeForPipelineSelect(rootDeviceEnvironment)); 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 5b0aec7149..5840b1a948 100644 --- a/shared/source/command_stream/command_stream_receiver_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_hw_base.inl @@ -813,7 +813,8 @@ size_t CommandStreamReceiverHw::getRequiredCmdStreamSize(const Dispat } if (debugManager.flags.ForcePipeControlPriorToWalker.get()) { - size += 2 * MemorySynchronizationCommands::getSizeForSingleBarrier(); + size += MemorySynchronizationCommands::getSizeForStallingBarrier(); + size += MemorySynchronizationCommands::getSizeForSingleBarrier(); } return size; diff --git a/shared/source/gen12lp/hw_cmds_base.h b/shared/source/gen12lp/hw_cmds_base.h index 45d557cdcb..387da27f96 100644 --- a/shared/source/gen12lp/hw_cmds_base.h +++ b/shared/source/gen12lp/hw_cmds_base.h @@ -102,6 +102,7 @@ struct Gen12LpFamily : public Gen12Lp { using XY_COLOR_BLT = typename GfxFamily::XY_FAST_COLOR_BLT; using MI_STORE_REGISTER_MEM_CMD = typename GfxFamily::MI_STORE_REGISTER_MEM; using TimestampPacketType = uint32_t; + using StallingBarrierType = PIPE_CONTROL; static const GPGPU_WALKER cmdInitGpgpuWalker; static const INTERFACE_DESCRIPTOR_DATA cmdInitInterfaceDescriptorData; static const MEDIA_INTERFACE_DESCRIPTOR_LOAD cmdInitMediaInterfaceDescriptorLoad; diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 0d4d9abbb7..09cc32d5b8 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -492,6 +492,7 @@ struct MemorySynchronizationCommands { static void setSingleBarrier(void *commandsBuffer, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, PipeControlArgs &args); static void addSingleBarrier(LinearStream &commandStream, PipeControlArgs &args); static void setSingleBarrier(void *commandsBuffer, PipeControlArgs &args); + static void setStallingBarrier(void *commandsBuffer, PipeControlArgs &args); static void addBarrierWithPostSyncOperation(LinearStream &commandStream, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, const RootDeviceEnvironment &rootDeviceEnvironment, PipeControlArgs &args); static void setBarrierWithPostSyncOperation(void *&commandsBuffer, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, const RootDeviceEnvironment &rootDeviceEnvironment, PipeControlArgs &args); @@ -526,6 +527,7 @@ struct MemorySynchronizationCommands { static size_t getSizeForSingleAdditionalSynchronization(const RootDeviceEnvironment &rootDeviceEnvironment); static size_t getSizeForAdditonalSynchronization(const RootDeviceEnvironment &rootDeviceEnvironment); static size_t getSizeForInstructionCacheFlush(); + static size_t getSizeForStallingBarrier(); static bool isBarrierWaRequired(const RootDeviceEnvironment &rootDeviceEnvironment); static bool isBarrierPriorToPipelineSelectWaRequired(const RootDeviceEnvironment &rootDeviceEnvironment); diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index e41ef11103..2fafe1c6be 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -236,25 +236,40 @@ void MemorySynchronizationCommands::setSingleBarrier(void *commandsBu template void MemorySynchronizationCommands::addSingleBarrier(LinearStream &commandStream, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, PipeControlArgs &args) { - auto barrier = commandStream.getSpace(MemorySynchronizationCommands::getSizeForSingleBarrier()); + auto barrierSize = MemorySynchronizationCommands::getSizeForSingleBarrier(); + if (args.csStallOnly) { + barrierSize = MemorySynchronizationCommands::getSizeForStallingBarrier(); + } + auto barrier = commandStream.getSpace(barrierSize); setSingleBarrier(barrier, postSyncMode, gpuAddress, immediateData, args); } template -void MemorySynchronizationCommands::setSingleBarrier(void *commandsBuffer, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, PipeControlArgs &args) { +void MemorySynchronizationCommands::setStallingBarrier(void *commandsBuffer, PipeControlArgs &args) { using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; PIPE_CONTROL pipeControl = GfxFamily::cmdInitPipeControl; pipeControl.setCommandStreamerStallEnable(true); setBarrierExtraProperties(&pipeControl, args); + *reinterpret_cast(commandsBuffer) = pipeControl; +} + +template +void MemorySynchronizationCommands::setSingleBarrier(void *commandsBuffer, PostSyncMode postSyncMode, uint64_t gpuAddress, uint64_t immediateData, PipeControlArgs &args) { + using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; if (args.csStallOnly) { - *reinterpret_cast(commandsBuffer) = pipeControl; + setStallingBarrier(commandsBuffer, args); return; } + PIPE_CONTROL pipeControl = GfxFamily::cmdInitPipeControl; + + pipeControl.setCommandStreamerStallEnable(true); + setBarrierExtraProperties(&pipeControl, args); + pipeControl.setConstantCacheInvalidationEnable(args.constantCacheInvalidationEnable); pipeControl.setInstructionCacheInvalidateEnable(args.instructionCacheInvalidateEnable); pipeControl.setPipeControlFlushEnable(args.pipeControlFlushEnable); @@ -335,7 +350,7 @@ void MemorySynchronizationCommands::setBarrierWa(void *&commandsBuffe additionalArgs.csStallOnly = true; MemorySynchronizationCommands::setSingleBarrier(commandsBuffer, additionalArgs); - commandsBuffer = ptrOffset(commandsBuffer, sizeof(PIPE_CONTROL)); + commandsBuffer = ptrOffset(commandsBuffer, getSizeForStallingBarrier()); } } @@ -384,7 +399,7 @@ size_t MemorySynchronizationCommands::getSizeForBarrierWa(const RootD size = getSizeForSingleBarrier() + getSizeForSingleAdditionalSynchronization(rootDeviceEnvironment); } else if (releaseHelper && postSyncMode == PostSyncMode::timestamp && releaseHelper->programmAdditionalStallPriorToBarrierWithTimestamp()) { - size = getSizeForSingleBarrier(); + size = getSizeForStallingBarrier(); } return size; } @@ -856,6 +871,11 @@ bool GfxCoreHelperHw::isCacheFlushPriorImageReadRequired() const { return false; } +template +size_t MemorySynchronizationCommands::getSizeForStallingBarrier() { + return sizeof(typename GfxFamily::StallingBarrierType); +} + template uint32_t GfxCoreHelperHw::getQueuePriorityLevels() const { return 2; diff --git a/shared/source/helpers/gfx_core_helper_xe2_and_later.inl b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl index 1a75a19537..9696103e0e 100644 --- a/shared/source/helpers/gfx_core_helper_xe2_and_later.inl +++ b/shared/source/helpers/gfx_core_helper_xe2_and_later.inl @@ -97,4 +97,15 @@ bool GfxCoreHelperHw::isCacheFlushPriorImageReadRequired() const { return true; } +template <> +void MemorySynchronizationCommands::setStallingBarrier(void *commandsBuffer, PipeControlArgs &args) { + using RESOURCE_BARRIER = typename Family::RESOURCE_BARRIER; + + auto resourceBarrier = Family::cmdInitResourceBarrier; + resourceBarrier.setBarrierType(RESOURCE_BARRIER::BARRIER_TYPE::BARRIER_TYPE_IMMEDIATE); + resourceBarrier.setWaitStage(RESOURCE_BARRIER::WAIT_STAGE::WAIT_STAGE_TOP); + resourceBarrier.setSignalStage(RESOURCE_BARRIER::SIGNAL_STAGE::SIGNAL_STAGE_GPGPU); + *reinterpret_cast(commandsBuffer) = resourceBarrier; +} + } // namespace NEO diff --git a/shared/source/xe2_hpg_core/hw_cmds_base.h b/shared/source/xe2_hpg_core/hw_cmds_base.h index de10e0b6dc..c64ec05433 100644 --- a/shared/source/xe2_hpg_core/hw_cmds_base.h +++ b/shared/source/xe2_hpg_core/hw_cmds_base.h @@ -109,6 +109,7 @@ struct Xe2HpgCoreFamily : public Xe2HpgCore { using XY_COLOR_BLT = typename GfxFamily::XY_FAST_COLOR_BLT; using MI_STORE_REGISTER_MEM_CMD = typename GfxFamily::MI_STORE_REGISTER_MEM; using TimestampPacketType = uint64_t; + using StallingBarrierType = RESOURCE_BARRIER; static const COMPUTE_WALKER cmdInitGpgpuWalker; static const CFE_STATE cmdInitCfeState; static const INTERFACE_DESCRIPTOR_DATA cmdInitInterfaceDescriptorData; diff --git a/shared/source/xe3_core/hw_cmds_base.h b/shared/source/xe3_core/hw_cmds_base.h index c2e1a12eb6..d65ca078af 100644 --- a/shared/source/xe3_core/hw_cmds_base.h +++ b/shared/source/xe3_core/hw_cmds_base.h @@ -112,6 +112,7 @@ struct Xe3CoreFamily : public Xe3Core { using XY_COLOR_BLT = typename GfxFamily::XY_FAST_COLOR_BLT; using MI_STORE_REGISTER_MEM_CMD = typename GfxFamily::MI_STORE_REGISTER_MEM; using TimestampPacketType = uint64_t; + using StallingBarrierType = RESOURCE_BARRIER; static const COMPUTE_WALKER cmdInitGpgpuWalker; static const CFE_STATE cmdInitCfeState; static const INTERFACE_DESCRIPTOR_DATA cmdInitInterfaceDescriptorData; diff --git a/shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h b/shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h index c1647006b1..181385b4da 100644 --- a/shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h +++ b/shared/source/xe_hpc_core/hw_cmds_xe_hpc_core_base.h @@ -91,6 +91,7 @@ struct XeHpcCoreFamily : public XeHpcCore { using XY_COLOR_BLT = typename GfxFamily::XY_FAST_COLOR_BLT; using MI_STORE_REGISTER_MEM_CMD = typename GfxFamily::MI_STORE_REGISTER_MEM; using TimestampPacketType = uint32_t; + using StallingBarrierType = PIPE_CONTROL; static const COMPUTE_WALKER cmdInitGpgpuWalker; static const CFE_STATE cmdInitCfeState; static const INTERFACE_DESCRIPTOR_DATA cmdInitInterfaceDescriptorData; diff --git a/shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h b/shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h index e0c87d027e..2fc111a342 100644 --- a/shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h +++ b/shared/source/xe_hpg_core/hw_cmds_xe_hpg_core_base.h @@ -111,6 +111,7 @@ struct XeHpgCoreFamily : public XeHpgCore { using XY_COLOR_BLT = typename GfxFamily::XY_FAST_COLOR_BLT; using MI_STORE_REGISTER_MEM_CMD = typename GfxFamily::MI_STORE_REGISTER_MEM; using TimestampPacketType = uint32_t; + using StallingBarrierType = PIPE_CONTROL; static const COMPUTE_WALKER cmdInitGpgpuWalker; static const CFE_STATE cmdInitCfeState; static const INTERFACE_DESCRIPTOR_DATA cmdInitInterfaceDescriptorData; diff --git a/shared/test/common/cmd_parse/CMakeLists.txt b/shared/test/common/cmd_parse/CMakeLists.txt index e75b84548c..8cb5b978ef 100644 --- a/shared/test/common/cmd_parse/CMakeLists.txt +++ b/shared/test/common/cmd_parse/CMakeLists.txt @@ -40,5 +40,6 @@ if(TESTS_XE2_AND_LATER) target_sources(neo_libult_common PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_state_context_data_base_address.inl ${CMAKE_CURRENT_SOURCE_DIR}/hw_parse_xe2_hpg_and_later.inl + ${CMAKE_CURRENT_SOURCE_DIR}/cmd_parse_resource_barrier.inl ) endif() diff --git a/shared/test/common/cmd_parse/cmd_parse_resource_barrier.inl b/shared/test/common/cmd_parse/cmd_parse_resource_barrier.inl new file mode 100644 index 0000000000..042e84de70 --- /dev/null +++ b/shared/test/common/cmd_parse/cmd_parse_resource_barrier.inl @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/cmd_parse/gen_cmd_parse.h" + +using namespace NEO; +using RESOURCE_BARRIER = GenStruct::RESOURCE_BARRIER; + +template <> +RESOURCE_BARRIER *genCmdCast(void *buffer) { + auto pCmd = reinterpret_cast(buffer); + + return (0x3 == pCmd->TheStructure.Common.DwordLength && + 0x3 == pCmd->TheStructure.Common.Opcode && + 0x5 == pCmd->TheStructure.Common.CommandType) + ? pCmd + : nullptr; +} diff --git a/shared/test/common/cmd_parse/hw_parse.h b/shared/test/common/cmd_parse/hw_parse.h index 648051fba4..c7f06243da 100644 --- a/shared/test/common/cmd_parse/hw_parse.h +++ b/shared/test/common/cmd_parse/hw_parse.h @@ -63,6 +63,9 @@ struct HardwareParse : NEO::NonCopyableAndNonMovableClass { return true; } + template + bool isStallingBarrier(GenCmdList::iterator &iter); + template void findHardwareCommands(); diff --git a/shared/test/common/cmd_parse/hw_parse_base.inl b/shared/test/common/cmd_parse/hw_parse_base.inl index a6072f09d8..4f9a3d24da 100644 --- a/shared/test/common/cmd_parse/hw_parse_base.inl +++ b/shared/test/common/cmd_parse/hw_parse_base.inl @@ -155,4 +155,22 @@ const typename FamilyType::RENDER_SURFACE_STATE *HardwareParse::getSurfaceState( } } +template +bool HardwareParse::isStallingBarrier(GenCmdList::iterator &iter) { + PIPE_CONTROL *pipeControlCmd = genCmdCast(*iter); + if (pipeControlCmd == nullptr) { + return false; + } + EXPECT_EQ(pipeControlCmd->getCommandStreamerStallEnable(), true); + EXPECT_EQ(pipeControlCmd->getDcFlushEnable(), false); + EXPECT_EQ(pipeControlCmd->getRenderTargetCacheFlushEnable(), false); + EXPECT_EQ(pipeControlCmd->getInstructionCacheInvalidateEnable(), false); + EXPECT_EQ(pipeControlCmd->getTextureCacheInvalidationEnable(), false); + EXPECT_EQ(pipeControlCmd->getPipeControlFlushEnable(), false); + EXPECT_EQ(pipeControlCmd->getVfCacheInvalidationEnable(), false); + EXPECT_EQ(pipeControlCmd->getConstantCacheInvalidationEnable(), false); + EXPECT_EQ(pipeControlCmd->getStateCacheInvalidationEnable(), false); + return true; +} + } // namespace NEO diff --git a/shared/test/common/cmd_parse/hw_parse_xe2_hpg_and_later.inl b/shared/test/common/cmd_parse/hw_parse_xe2_hpg_and_later.inl index 2ebe76e75f..4645bebf44 100644 --- a/shared/test/common/cmd_parse/hw_parse_xe2_hpg_and_later.inl +++ b/shared/test/common/cmd_parse/hw_parse_xe2_hpg_and_later.inl @@ -23,4 +23,13 @@ bool HardwareParse::requiresPipelineSelectBeforeMediaState() { return false; } +template <> +bool HardwareParse::isStallingBarrier(GenCmdList::iterator &iter) { + GenGfxFamily::RESOURCE_BARRIER *resourceBarrierCmd = genCmdCast(*iter); + EXPECT_EQ(resourceBarrierCmd->getBarrierType(), RESOURCE_BARRIER::BARRIER_TYPE::BARRIER_TYPE_IMMEDIATE); + EXPECT_EQ(resourceBarrierCmd->getWaitStage(), RESOURCE_BARRIER::WAIT_STAGE::WAIT_STAGE_TOP); + EXPECT_EQ(resourceBarrierCmd->getSignalStage(), RESOURCE_BARRIER::SIGNAL_STAGE::SIGNAL_STAGE_GPGPU); + return resourceBarrierCmd != nullptr; +} + } // namespace NEO diff --git a/shared/test/common/gen12lp/cmd_parse_gen12lp.cpp b/shared/test/common/gen12lp/cmd_parse_gen12lp.cpp index edd5dbaa19..8ae4f97767 100644 --- a/shared/test/common/gen12lp/cmd_parse_gen12lp.cpp +++ b/shared/test/common/gen12lp/cmd_parse_gen12lp.cpp @@ -132,4 +132,6 @@ template void HardwareParse::findHardwareCommands(); template void HardwareParse::findHardwareCommands(IndirectHeap *); template const void *HardwareParse::getStatelessArgumentPointer(const KernelInfo &kernelInfo, uint32_t indexArg, IndirectHeap &ioh, uint32_t rootDeviceIndex); template const typename Gen12LpFamily::RENDER_SURFACE_STATE *HardwareParse::getSurfaceState(IndirectHeap *ssh, uint32_t index); +template bool HardwareParse::isStallingBarrier(GenCmdList::iterator &iter); + } // namespace NEO diff --git a/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp b/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp index 2303b07323..5fd4b8cd24 100644 --- a/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp +++ b/shared/test/common/xe2_hpg_core/cmd_parse_xe2_hpg_core.cpp @@ -11,6 +11,7 @@ using GenGfxFamily = NEO::Xe2HpgCoreFamily; #include "shared/test/common/cmd_parse/cmd_parse_mem_fence.inl" #include "shared/test/common/cmd_parse/cmd_parse_mem_set.inl" +#include "shared/test/common/cmd_parse/cmd_parse_resource_barrier.inl" #include "shared/test/common/cmd_parse/cmd_parse_state_context_data_base_address.inl" #include "shared/test/common/cmd_parse/cmd_parse_state_prefetch.inl" #include "shared/test/common/cmd_parse/cmd_parse_system_mem_fence_address.inl" @@ -22,6 +23,7 @@ using STATE_SYSTEM_MEM_FENCE_ADDRESS = GenStruct::STATE_SYSTEM_MEM_FENCE_ADDRESS using STATE_PREFETCH = GenStruct::STATE_PREFETCH; using MEM_SET = GenStruct::MEM_SET; using STATE_CONTEXT_DATA_BASE_ADDRESS = GenStruct::STATE_CONTEXT_DATA_BASE_ADDRESS; +using RESOURCE_BARRIER = GenStruct::RESOURCE_BARRIER; template <> size_t CmdParse::getAdditionalCommandLength(void *cmd) { @@ -50,6 +52,11 @@ size_t CmdParse::getAdditionalCommandLength(void *cmd) { return sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS) / sizeof(uint32_t); } } + { + if (genCmdCast(cmd)) { + return sizeof(RESOURCE_BARRIER) / sizeof(uint32_t); + } + } return 0; } diff --git a/shared/test/common/xe3_core/cmd_parse_xe3_core.cpp b/shared/test/common/xe3_core/cmd_parse_xe3_core.cpp index c548cd8687..a4e6f2f7fb 100644 --- a/shared/test/common/xe3_core/cmd_parse_xe3_core.cpp +++ b/shared/test/common/xe3_core/cmd_parse_xe3_core.cpp @@ -12,6 +12,7 @@ using GenGfxFamily = NEO::Xe3CoreFamily; #include "shared/test/common/cmd_parse/cmd_parse_mem_fence.inl" #include "shared/test/common/cmd_parse/cmd_parse_mem_set.inl" +#include "shared/test/common/cmd_parse/cmd_parse_resource_barrier.inl" #include "shared/test/common/cmd_parse/cmd_parse_state_context_data_base_address.inl" #include "shared/test/common/cmd_parse/cmd_parse_state_prefetch.inl" #include "shared/test/common/cmd_parse/cmd_parse_system_mem_fence_address.inl" @@ -23,6 +24,7 @@ using STATE_SYSTEM_MEM_FENCE_ADDRESS = GenStruct::STATE_SYSTEM_MEM_FENCE_ADDRESS using STATE_PREFETCH = GenStruct::STATE_PREFETCH; using MEM_SET = GenStruct::MEM_SET; using STATE_CONTEXT_DATA_BASE_ADDRESS = GenStruct::STATE_CONTEXT_DATA_BASE_ADDRESS; +using RESOURCE_BARRIER = GenStruct::RESOURCE_BARRIER; template <> size_t CmdParse::getAdditionalCommandLength(void *cmd) { @@ -51,6 +53,11 @@ size_t CmdParse::getAdditionalCommandLength(void *cmd) { return sizeof(STATE_CONTEXT_DATA_BASE_ADDRESS) / sizeof(uint32_t); } } + { + if (genCmdCast(cmd)) { + return sizeof(RESOURCE_BARRIER) / sizeof(uint32_t); + } + } return 0; } diff --git a/shared/test/common/xe_hpc_core/cmd_parse_xe_hpc_core.cpp b/shared/test/common/xe_hpc_core/cmd_parse_xe_hpc_core.cpp index a07d861727..62fcd2e260 100644 --- a/shared/test/common/xe_hpc_core/cmd_parse_xe_hpc_core.cpp +++ b/shared/test/common/xe_hpc_core/cmd_parse_xe_hpc_core.cpp @@ -71,3 +71,4 @@ const char *CmdParse::getAdditionalCommandName(void *cmd) { #include "shared/test/common/cmd_parse/hw_parse_xe_hpg_and_later.inl" template const typename GenGfxFamily::RENDER_SURFACE_STATE *NEO::HardwareParse::getSurfaceState(IndirectHeap *ssh, uint32_t index); +template bool NEO::HardwareParse::isStallingBarrier(GenCmdList::iterator &iter); \ No newline at end of file diff --git a/shared/test/common/xe_hpg_core/cmd_parse_xe_hpg_core.cpp b/shared/test/common/xe_hpg_core/cmd_parse_xe_hpg_core.cpp index 4ab098f9e8..8a65ef67dc 100644 --- a/shared/test/common/xe_hpg_core/cmd_parse_xe_hpg_core.cpp +++ b/shared/test/common/xe_hpg_core/cmd_parse_xe_hpg_core.cpp @@ -57,3 +57,4 @@ const char *CmdParse::getAdditionalCommandName(void *cmd) { #include "shared/test/common/cmd_parse/hw_parse_xe_hpg_and_later.inl" template const typename GenGfxFamily::RENDER_SURFACE_STATE *NEO::HardwareParse::getSurfaceState(IndirectHeap *ssh, uint32_t index); +template bool NEO::HardwareParse::isStallingBarrier(GenCmdList::iterator &iter); \ No newline at end of file diff --git a/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp b/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp index ef4bde20eb..ba675c73b4 100644 --- a/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp +++ b/shared/test/unit_test/command_stream/compute_mode_tests_xehp_and_later.cpp @@ -70,7 +70,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ComputeModeRequirements, givenCoherencyWithSharedHa overrideComputeModeRequest(false, true, true); EXPECT_FALSE(getCsrHw()->streamProperties.stateComputeMode.isDirty()); - auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + sizeof(PIPE_CONTROL); + auto cmdsSize = sizeof(STATE_COMPUTE_MODE) + MemorySynchronizationCommands::getSizeForStallingBarrier(); if (isBasicWARequired) { cmdsSize += +sizeof(PIPE_CONTROL); } diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index fce20049c4..b7edf62560 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1933,6 +1933,24 @@ HWTEST2_F(GfxCoreHelperTest, whenIsCacheFlushPriorImageReadRequiredCalledThenFal EXPECT_FALSE(helper.isCacheFlushPriorImageReadRequired()); } +HWTEST2_F(GfxCoreHelperTest, givenAtLeastXe2HpgWhenSetStallOnlyBarrierThenPipeControlProgrammed, IsBeforeXe2HpgCore) { + using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + constexpr static auto bufferSize = sizeof(PIPE_CONTROL); + + char streamBuffer[bufferSize]; + LinearStream stream(streamBuffer, bufferSize); + PipeControlArgs args; + args.csStallOnly = true; + MemorySynchronizationCommands::addSingleBarrier(stream, PostSyncMode::noWrite, 0u, 0u, args); + + HardwareParse hwParser; + hwParser.parseCommands(stream, 0); + GenCmdList pipeControlList = hwParser.getCommandsList(); + EXPECT_EQ(1u, pipeControlList.size()); + GenCmdList::iterator itor = pipeControlList.begin(); + EXPECT_TRUE(hwParser.isStallingBarrier(itor)); +} + TEST_F(GfxCoreHelperTest, whenGetQueuePriorityLevelsQueriedThen2IsReturned) { auto &gfxCoreHelper = getHelper(); EXPECT_EQ(2u, gfxCoreHelper.getQueuePriorityLevels()); diff --git a/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp index 2c73d3ff0c..fc8709a64b 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_xe2_and_later.cpp @@ -111,4 +111,22 @@ HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenIsCacheFlushPrior MockExecutionEnvironment mockExecutionEnvironment{}; auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); EXPECT_TRUE(gfxCoreHelper.isCacheFlushPriorImageReadRequired()); -} \ No newline at end of file +} + +HWTEST2_F(GfxCoreHelperXe2AndLaterTests, givenAtLeastXe2HpgWhenSetStallOnlyBarrierThenResourceBarrierProgrammed, IsAtLeastXe2HpgCore) { + using RESOURCE_BARRIER = typename FamilyType::RESOURCE_BARRIER; + constexpr static auto bufferSize = sizeof(RESOURCE_BARRIER); + + char streamBuffer[bufferSize]; + LinearStream stream(streamBuffer, bufferSize); + PipeControlArgs args; + args.csStallOnly = true; + MemorySynchronizationCommands::addSingleBarrier(stream, PostSyncMode::noWrite, 0u, 0u, args); + + HardwareParse hwParser; + hwParser.parseCommands(stream, 0); + GenCmdList resourceBarrierList = hwParser.getCommandsList(); + EXPECT_EQ(1u, resourceBarrierList.size()); + GenCmdList::iterator itor = resourceBarrierList.begin(); + EXPECT_TRUE(hwParser.isStallingBarrier(itor)); +}