Skip to content

[SYCL] Fix PI_KERNEL_MAX_SUB_GROUP_SIZE in OpenCL backend #6849

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 2 commits into from
Sep 23, 2022
Merged
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
22 changes: 16 additions & 6 deletions sycl/plugins/opencl/pi_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,14 +865,24 @@ pi_result piKernelGetSubGroupInfo(pi_kernel kernel, pi_device device,
std::shared_ptr<void> implicit_input_value;
if (param_name == PI_KERNEL_MAX_SUB_GROUP_SIZE && !input_value) {
// OpenCL needs an input value for PI_KERNEL_MAX_SUB_GROUP_SIZE so if no
// value is given we use the max work item sizes of the device to avoid
// truncation of max sub-group size.
implicit_input_value = std::shared_ptr<size_t[]>(new size_t[3]);
pi_result pi_ret_err = piDeviceGetInfo(
device, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES, 3 * sizeof(size_t),
implicit_input_value.get(), nullptr);
// value is given we use the max work item size of the device in the first
// dimention to avoid truncation of max sub-group size.
pi_uint32 max_dims = 0;
pi_result pi_ret_err =
piDeviceGetInfo(device, PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS,
sizeof(pi_uint32), &max_dims, nullptr);
if (pi_ret_err != PI_SUCCESS)
return pi_ret_err;
std::shared_ptr<size_t[]> WGSizes{new size_t[max_dims]};
pi_ret_err =
piDeviceGetInfo(device, PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES,
max_dims * sizeof(size_t), WGSizes.get(), nullptr);
if (pi_ret_err != PI_SUCCESS)
return pi_ret_err;
for (size_t i = 1; i < max_dims; ++i)
WGSizes.get()[i] = 1;
implicit_input_value = std::move(WGSizes);
input_value_size = max_dims * sizeof(size_t);
input_value = implicit_input_value.get();
}

Expand Down