Skip to content

Commit

Permalink
[L0] Fix UR_KERNEL_INFO_ATTRIBUTES returned value
Browse files Browse the repository at this point in the history
Currently L0 adapter returns garbage value for that property because
string is incorrectly copied to the output buffer.
Probably ur::getInfo implementation should be fixed to handle such cases
properly.
  • Loading branch information
againull committed Oct 23, 2024
1 parent d8cc532 commit 164d115
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/adapters/level_zero/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ ur_result_t urKernelGetInfo(
char *attributes = new char[Size];
ZE2UR_CALL(zeKernelGetSourceAttributes,
(Kernel->ZeKernel, &Size, &attributes));
auto Res = ReturnValue(attributes);
auto Res = ReturnValue(static_cast<const char *>(attributes));
delete[] attributes;
return Res;
} catch (const std::bad_alloc &) {
Expand Down
16 changes: 16 additions & 0 deletions test/conformance/kernel/urKernelGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ TEST_P(urKernelGetInfoTest, Success) {
ASSERT_GT(*returned_reference_count, 0U);
break;
}
case UR_KERNEL_INFO_ATTRIBUTES: {
auto returned_attributes = std::string(property_value.data());
ur_platform_backend_t backend;
ASSERT_SUCCESS(urPlatformGetInfo(platform, UR_PLATFORM_INFO_BACKEND,
sizeof(backend), &backend, nullptr));
if (backend == UR_PLATFORM_BACKEND_OPENCL ||
backend == UR_PLATFORM_BACKEND_LEVEL_ZERO) {
// Older intel drivers don't attach any default attributes and newer ones force walk order to X/Y/Z using special attribute.
ASSERT_TRUE(returned_attributes.empty() ||
returned_attributes ==
"intel_reqd_workgroup_walk_order(0,1,2)");
} else {
ASSERT_TRUE(returned_attributes.empty());
}
break;
}
default:
break;
}
Expand Down

0 comments on commit 164d115

Please sign in to comment.