From 9e16ef4de59f86e0b399f54c910858c2fb55d812 Mon Sep 17 00:00:00 2001 From: Bellekallu Rajkiran Date: Mon, 22 Sep 2025 15:51:41 +0000 Subject: [PATCH] fix: Modify kernelWithAssert flag handling Reset kernelWithAssertAppended flag only upon synchronization for immediate command list Related-To: NEO-14997 Signed-off-by: Bellekallu Rajkiran --- .../source/cmdlist/cmdlist_hw_immediate.inl | 2 +- .../unit_tests/sources/assert/test_assert.cpp | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index 54ab0de2ee..1a7f8e4f31 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -538,7 +538,6 @@ inline ze_result_t CommandListCoreFamilyImmediate::executeCommand status = hostSynchronize(std::numeric_limits::max(), true); } } - this->kernelWithAssertAppended = false; return status; } @@ -1255,6 +1254,7 @@ ze_result_t CommandListCoreFamilyImmediate::hostSynchronize(uint6 cmdQueueImp->checkAssert(); } } + this->kernelWithAssertAppended = false; } return status; diff --git a/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp b/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp index ba477ce64e..4c3f3a8bd2 100644 --- a/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp +++ b/level_zero/core/test/unit_tests/sources/assert/test_assert.cpp @@ -198,7 +198,7 @@ TEST(CommandListAssertTest, GivenCmdListWithAppendedAssertKernelWhenResetThenKer EXPECT_FALSE(commandList->hasKernelWithAssert()); } -TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWhenKernelWithAssertAppendedThenHasKernelWithAssertIsSetFalseAfterFlush) { +TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithSyncModeWhenKernelWithAssertAppendedThenHasKernelWithAssertIsSetFalseAfterFlush) { auto assertHandler = new MockAssertHandler(device->getNEODevice()); device->getNEODevice()->getRootDeviceEnvironmentRef().assertHandler.reset(assertHandler); @@ -227,6 +227,40 @@ TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWhenKernelWithAssert EXPECT_FALSE(commandList->hasKernelWithAssert()); } +TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithASynchronousModeWhenKernelWithAssertAppendedThenHasKernelWithAssertIsSetFalseOnlyAfterSynchronize) { + auto assertHandler = new MockAssertHandler(device->getNEODevice()); + device->getNEODevice()->getRootDeviceEnvironmentRef().assertHandler.reset(assertHandler); + + ze_result_t result; + Mock module(device, nullptr, ModuleType::user); + Mock kernel; + kernel.module = &module; + ze_command_queue_desc_t desc = {}; + desc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC; + desc.pNext = 0; + desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; + + std::unique_ptr commandList(CommandList::createImmediate(NEO::defaultHwInfo->platform.eProductFamily, device, &desc, false, + NEO::EngineGroupType::renderCompute, result)); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + ze_group_count_t groupCount{1, 1, 1}; + + kernel.descriptor.kernelAttributes.flags.usesAssert = true; + + CmdListKernelLaunchParams launchParams = {}; + result = commandList->appendLaunchKernel(kernel.toHandle(), groupCount, nullptr, 0, nullptr, launchParams); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + EXPECT_TRUE(commandList->hasKernelWithAssert()); + + result = commandList->hostSynchronize(std::numeric_limits::max()); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + EXPECT_EQ(1u, assertHandler->printAssertAndAbortCalled); + EXPECT_FALSE(commandList->hasKernelWithAssert()); +} + HWTEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWhenCheckingAssertThenPrintMessageAndAbortOnAssertHandlerIsCalled) { ze_result_t result; ze_command_queue_desc_t desc = {};