Skip to content

Commit 679d3a2

Browse files
feature: add printf kernel support when executing regular from immediate
Related-To: NEO-10356 Signed-off-by: Zbigniew Zdanowicz <[email protected]>
1 parent 1c377dc commit 679d3a2

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,13 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::hostSynchronize(uint6
11811181
}
11821182
}
11831183

1184-
this->printKernelsPrintfOutput(status == ZE_RESULT_ERROR_DEVICE_LOST);
1184+
bool hangDetected = status == ZE_RESULT_ERROR_DEVICE_LOST;
1185+
this->printKernelsPrintfOutput(hangDetected);
11851186
this->checkAssert();
1187+
{
1188+
auto cmdQueueImp = static_cast<CommandQueueImp *>(this->cmdQImmediate);
1189+
cmdQueueImp->printKernelsPrintfOutput(hangDetected);
1190+
}
11861191
}
11871192
}
11881193

level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,5 +1794,32 @@ HWTEST2_F(ImmediateCommandListTest, givenAsyncCmdlistWhenCmdlistIsDestroyedThenH
17941794
EXPECT_EQ(0u, clientCount);
17951795
}
17961796

1797+
HWTEST_F(ImmediateCommandListTest,
1798+
givenImmediateCmdListWhenAppendingRegularCmdListWithPrintfKernelThenPrintfIsCalledAfterSynchronization) {
1799+
ze_result_t returnValue;
1800+
1801+
auto kernel = new Mock<KernelImp>{};
1802+
kernel->module = module.get();
1803+
kernel->descriptor.kernelAttributes.flags.usesPrintf = true;
1804+
kernel->createPrintfBuffer();
1805+
module->getPrintfKernelContainer().push_back(std::shared_ptr<Kernel>{kernel});
1806+
1807+
ze_group_count_t groupCount{1, 1, 1};
1808+
CmdListKernelLaunchParams launchParams = {};
1809+
returnValue = commandList->appendLaunchKernel(kernel->toHandle(), groupCount, nullptr, 0, nullptr, launchParams, false);
1810+
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
1811+
returnValue = commandList->close();
1812+
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
1813+
1814+
auto commandListHandle = commandList->toHandle();
1815+
EXPECT_EQ(0u, kernel->printPrintfOutputCalledTimes);
1816+
returnValue = commandListImmediate->appendCommandLists(1, &commandListHandle, nullptr, 0, nullptr);
1817+
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
1818+
1819+
returnValue = commandListImmediate->hostSynchronize(std::numeric_limits<uint64_t>::max());
1820+
EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue);
1821+
EXPECT_EQ(1u, kernel->printPrintfOutputCalledTimes);
1822+
}
1823+
17971824
} // namespace ult
17981825
} // namespace L0

0 commit comments

Comments
 (0)