From 679d3a2be555ceb8284feb541e3ffa3927dd7216 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Mon, 7 Apr 2025 22:36:37 +0000 Subject: [PATCH] feature: add printf kernel support when executing regular from immediate Related-To: NEO-10356 Signed-off-by: Zbigniew Zdanowicz --- .../source/cmdlist/cmdlist_hw_immediate.inl | 7 ++++- .../sources/cmdlist/test_cmdlist_4.cpp | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index 946d625d24..e6e55d5183 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -1181,8 +1181,13 @@ ze_result_t CommandListCoreFamilyImmediate::hostSynchronize(uint6 } } - this->printKernelsPrintfOutput(status == ZE_RESULT_ERROR_DEVICE_LOST); + bool hangDetected = status == ZE_RESULT_ERROR_DEVICE_LOST; + this->printKernelsPrintfOutput(hangDetected); this->checkAssert(); + { + auto cmdQueueImp = static_cast(this->cmdQImmediate); + cmdQueueImp->printKernelsPrintfOutput(hangDetected); + } } } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp index 51b32b28f1..d96f1b7b3c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp @@ -1794,5 +1794,32 @@ HWTEST2_F(ImmediateCommandListTest, givenAsyncCmdlistWhenCmdlistIsDestroyedThenH EXPECT_EQ(0u, clientCount); } +HWTEST_F(ImmediateCommandListTest, + givenImmediateCmdListWhenAppendingRegularCmdListWithPrintfKernelThenPrintfIsCalledAfterSynchronization) { + ze_result_t returnValue; + + auto kernel = new Mock{}; + kernel->module = module.get(); + kernel->descriptor.kernelAttributes.flags.usesPrintf = true; + kernel->createPrintfBuffer(); + module->getPrintfKernelContainer().push_back(std::shared_ptr{kernel}); + + ze_group_count_t groupCount{1, 1, 1}; + CmdListKernelLaunchParams launchParams = {}; + returnValue = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + returnValue = commandList->close(); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + auto commandListHandle = commandList->toHandle(); + EXPECT_EQ(0u, kernel->printPrintfOutputCalledTimes); + returnValue = commandListImmediate->appendCommandLists(1, &commandListHandle, nullptr, 0, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + + returnValue = commandListImmediate->hostSynchronize(std::numeric_limits::max()); + EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); + EXPECT_EQ(1u, kernel->printPrintfOutputCalledTimes); +} + } // namespace ult } // namespace L0