Skip to content

[SYCL] Remove the workaround for long kernel names in the L0 plugin #2875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2987,7 +2987,7 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName,
return mapError(ZeResult);

try {
*RetKernel = new _pi_kernel(ZeKernel, Program, KernelName);
*RetKernel = new _pi_kernel(ZeKernel, Program);
} catch (const std::bad_alloc &) {
return PI_OUT_OF_HOST_MEMORY;
} catch (...) {
Expand Down Expand Up @@ -3066,12 +3066,19 @@ pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName,
case PI_KERNEL_INFO_PROGRAM:
return ReturnValue(pi_program{Kernel->Program});
case PI_KERNEL_INFO_FUNCTION_NAME:
// TODO: Replace with the line in the comment once bug in the Level Zero
// driver will be fixed. Problem is that currently Level Zero driver
// truncates name of the returned kernel if it is longer than 256 symbols.
//
// return ReturnValue(ZeKernelProperties.name);
return ReturnValue(Kernel->KernelName.c_str());
try {
size_t Size = 0;
ZE_CALL(zeKernelGetName(Kernel->ZeKernel, &Size, nullptr));
char *KernelName = new char[Size];
ZE_CALL(zeKernelGetName(Kernel->ZeKernel, &Size, KernelName));
Comment on lines +3072 to +3073
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we skip this if we are only going to return the size, i.e. ParamValue is null?
I see that we currently are doing strlen of the string to return to re-calculate the size though, which would need to change then.

Thoughts?

Anyways, this must not be a part of this PR.

pi_result Res = ReturnValue(static_cast<const char *>(KernelName));
delete[] KernelName;
return Res;
} catch (const std::bad_alloc &) {
return PI_OUT_OF_HOST_MEMORY;
} catch (...) {
return PI_ERROR_UNKNOWN;
}
case PI_KERNEL_INFO_NUM_ARGS:
return ReturnValue(pi_uint32{ZeKernelProperties.numKernelArgs});
case PI_KERNEL_INFO_REFERENCE_COUNT:
Expand Down
8 changes: 2 additions & 6 deletions sycl/plugins/level_zero/pi_level_zero.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,18 +695,14 @@ struct _pi_program : _pi_object {
};

struct _pi_kernel : _pi_object {
_pi_kernel(ze_kernel_handle_t Kernel, pi_program Program,
const char *KernelName)
: ZeKernel{Kernel}, Program{Program}, KernelName(KernelName) {}
_pi_kernel(ze_kernel_handle_t Kernel, pi_program Program)
: ZeKernel{Kernel}, Program{Program} {}

// Level Zero function handle.
ze_kernel_handle_t ZeKernel;

// Keep the program of the kernel.
pi_program Program;

// TODO: remove when bug in the Level Zero runtime will be fixed.
std::string KernelName;
};

struct _pi_sampler : _pi_object {
Expand Down