Skip to content

Commit b1b8510

Browse files
authored
[SYCL] Workaround to support any kernel name for the L0 backend (#1980)
Problem is that currently the L0 driver truncates name of the kernel when queried from the L0 driver. Problem comes from specification which allows to accept any kernel name but limits a kernel name which can be returned by the zeKernelGetProperties function. Signed-off-by: Artur Gainullin <[email protected]>
1 parent 7d6ede4 commit b1b8510

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

sycl/plugins/level_zero/pi_level0.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName,
18951895
&ZeKernelDesc, &ZeKernel));
18961896

18971897
try {
1898-
auto ZePiKernel = new _pi_kernel(ZeKernel, Program);
1898+
auto ZePiKernel = new _pi_kernel(ZeKernel, Program, KernelName);
18991899
*RetKernel = pi_cast<pi_kernel>(ZePiKernel);
19001900
} catch (const std::bad_alloc &) {
19011901
return PI_OUT_OF_HOST_MEMORY;
@@ -1961,7 +1961,12 @@ pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName,
19611961
case PI_KERNEL_INFO_PROGRAM:
19621962
return ReturnValue(pi_program{Kernel->Program});
19631963
case PI_KERNEL_INFO_FUNCTION_NAME:
1964-
return ReturnValue(ZeKernelProperties.name);
1964+
// TODO: Replace with the line in the comment once bug in the L0 driver will
1965+
// be fixed. Problem is that currently L0 driver truncates name of the
1966+
// returned kernel if it is longer than 256 symbols.
1967+
//
1968+
// return ReturnValue(ZeKernelProperties.name);
1969+
return ReturnValue(Kernel->KernelName.c_str());
19651970
case PI_KERNEL_INFO_NUM_ARGS:
19661971
return ReturnValue(pi_uint32{ZeKernelProperties.numKernelArgs});
19671972
case PI_KERNEL_INFO_REFERENCE_COUNT:

sycl/plugins/level_zero/pi_level0.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,18 @@ struct _pi_program : _pi_object {
317317
};
318318

319319
struct _pi_kernel : _pi_object {
320-
_pi_kernel(ze_kernel_handle_t Kernel, pi_program Program)
321-
: ZeKernel{Kernel}, Program{Program} {}
320+
_pi_kernel(ze_kernel_handle_t Kernel, pi_program Program,
321+
const char *KernelName)
322+
: ZeKernel{Kernel}, Program{Program}, KernelName(KernelName) {}
322323

323324
// L0 function handle.
324325
ze_kernel_handle_t ZeKernel;
325326

326327
// Keep the program of the kernel.
327328
pi_program Program;
329+
330+
// TODO: remove when bug in the L0 runtime will be fixed.
331+
std::string KernelName;
328332
};
329333

330334
struct _pi_sampler : _pi_object {

0 commit comments

Comments
 (0)