From c7a89f3e0a9d82d82889191ba5b81ea92b8fb8d8 Mon Sep 17 00:00:00 2001 From: Bellekallu Rajkiran Date: Mon, 15 Dec 2025 11:17:11 +0000 Subject: [PATCH] fix: Fix signalling with zero size mem operations Related-To: NEO-13003 Signed-off-by: Bellekallu Rajkiran --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 8 ++-- .../sources/cmdlist/test_cmdlist_blit.cpp | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 74f2f26361..25780226bb 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -1689,7 +1689,7 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyBlitRegion(Ali } dummyBlitWa.isWaRequired = true; - if (!useAdditionalBlitProperties) { + if (!useAdditionalBlitProperties || (copySize.x * copySize.y * copySize.z == 0)) { appendSignalEventPostWalker(signalEvent, nullptr, nullptr, false, false, true); } return ZE_RESULT_SUCCESS; @@ -2261,11 +2261,11 @@ ze_result_t CommandListCoreFamily::appendMemoryCopyRegion(void *d if (this->isInOrderExecutionEnabled()) { if (inOrderCopyOnlySignalingAllowed) { - if (!useAdditionalBlitProperties) { + if (!useAdditionalBlitProperties || srcSize == 0) { appendSignalInOrderDependencyCounter(signalEvent, memoryCopyParams.copyOffloadAllowed, false, false, false); } handleInOrderDependencyCounter(signalEvent, false, isCopyOnlyEnabled); - } else if (!useAdditionalBlitProperties && isCopyOnlyEnabled && Event::isAggregatedEvent(signalEvent)) { + } else if ((!useAdditionalBlitProperties || srcSize == 0) && isCopyOnlyEnabled && Event::isAggregatedEvent(signalEvent)) { appendSignalAggregatedEventAtomic(*signalEvent, isCopyOnlyEnabled); } } else { @@ -2843,7 +2843,7 @@ ze_result_t CommandListCoreFamily::appendBlitFill(void *ptr, cons return ZE_RESULT_ERROR_INVALID_SIZE; } else { const bool dualStreamCopyOffloadOperation = isDualStreamCopyOffloadOperation(memoryCopyParams.copyOffloadAllowed); - const bool isCopyOnlySignaling = isCopyOnly(dualStreamCopyOffloadOperation) && !useAdditionalBlitProperties; + const bool isCopyOnlySignaling = isCopyOnly(dualStreamCopyOffloadOperation) && (!useAdditionalBlitProperties || size == 0); ze_result_t ret = addEventsToCmdList(numWaitEvents, phWaitEvents, nullptr, memoryCopyParams.relaxedOrderingDispatch, false, true, false, dualStreamCopyOffloadOperation); if (ret) { diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp index 8b02a7414f..848a884883 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp @@ -1725,5 +1725,42 @@ HWTEST2_F(MultiTileAggregatedBcsSplitTests, givenBcsSplitDisabledWhenCallingZexD EXPECT_EQ(incValue, expectedTileCount); } +HWTEST2_F(AppendMemoryCopyTests, givenZeroSizeWhenAppendMemoryFillThenNoMemSetOrXyColorBltProgrammed, IsAtLeastXeHpcCore) { + using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; + using MEM_SET = typename GfxFamily::MEM_SET; + using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; + + DebugManagerStateRestore restorer; + debugManager.flags.EnableDeviceUsmAllocationPool.set(0); + debugManager.flags.EnableHostUsmAllocationPool.set(0); + + MockCommandListForMemFill commandList; + MockDriverHandle driverHandleMock; + NEO::DeviceVector neoDevices; + neoDevices.push_back(std::unique_ptr(neoDevice)); + driverHandleMock.initialize(std::move(neoDevices)); + device->setDriverHandle(&driverHandleMock); + commandList.initialize(device, NEO::EngineGroupType::copy, 0u); + commandList.useAdditionalBlitProperties = true; + + uint8_t pattern = 0xAB; + void *ptr = reinterpret_cast(0x1234); + + commandList.appendMemoryFill(ptr, reinterpret_cast(&pattern), sizeof(pattern), 0, nullptr, 0, nullptr, copyParams); + + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::Parse::parseCommandBuffer( + cmdList, ptrOffset(commandList.getCmdContainer().getCommandStream()->getCpuBase(), 0), + commandList.getCmdContainer().getCommandStream()->getUsed())); + + auto memSetItor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), memSetItor); + + auto xyColorBltItor = find(cmdList.begin(), cmdList.end()); + EXPECT_EQ(cmdList.end(), xyColorBltItor); + + device->setDriverHandle(driverHandle.get()); +} + } // namespace ult } // namespace L0