Skip to content

Commit b48f08f

Browse files
authored
[SYCL] Default work-group sizes based on max (#952)
Signed-off-by: Stuart Adams <stuart.adams@codeplay.com>
1 parent 1c4137c commit b48f08f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,14 +1422,19 @@ static void adjustNDRangePerKernel(NDRDescT &NDR, RT::PiKernel Kernel,
14221422

14231423
if (WGSize[0] == 0) {
14241424
// kernel does not request specific workgroup shape - set one
1425-
// TODO maximum work group size as the local size might not be the best
1426-
// choice for CPU or FPGA devices
1425+
id<3> MaxWGSizes =
1426+
get_device_info<id<3>, cl::sycl::info::device::max_work_item_sizes>::
1427+
get(DeviceImpl.getHandleRef(), DeviceImpl.getPlugin());
1428+
14271429
size_t WGSize1D = get_kernel_work_group_info<
14281430
size_t, cl::sycl::info::kernel_work_group::work_group_size>::
14291431
get(Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getPlugin());
1430-
assert(WGSize1D != 0);
1431-
// TODO implement better default for 2D/3D case:
1432-
WGSize = {WGSize1D, 1, 1};
1432+
1433+
assert(MaxWGSizes[2] != 0);
1434+
1435+
// Set default work-group size in the Z-direction to either the max
1436+
// number of work-items or the maximum work-group size in the Z-direction.
1437+
WGSize = {1, 1, min(WGSize1D, MaxWGSizes[2])};
14331438
}
14341439
NDR.set(NDR.Dims, nd_range<3>(NDR.NumWorkGroups * WGSize, WGSize));
14351440
}

0 commit comments

Comments
 (0)