Skip to content

Commit 3044baf

Browse files
committed
Default work-group sizes based on max
Signed-off-by: Stuart Adams <[email protected]>
1 parent 75ee39b commit 3044baf

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
@@ -1417,14 +1417,19 @@ static void adjustNDRangePerKernel(NDRDescT &NDR, RT::PiKernel Kernel,
14171417

14181418
if (WGSize[0] == 0) {
14191419
// kernel does not request specific workgroup shape - set one
1420-
// TODO maximum work group size as the local size might not be the best
1421-
// choice for CPU or FPGA devices
1420+
id<3> MaxWGSizes = get_device_info<
1421+
id<3>, cl::sycl::info::device::max_work_item_sizes>::
1422+
get(DeviceImpl.getHandleRef(), DeviceImpl.getPlugin());
1423+
14221424
size_t WGSize1D = get_kernel_work_group_info<
14231425
size_t, cl::sycl::info::kernel_work_group::work_group_size>::
14241426
get(Kernel, DeviceImpl.getHandleRef(), DeviceImpl.getPlugin());
1425-
assert(WGSize1D != 0);
1426-
// TODO implement better default for 2D/3D case:
1427-
WGSize = {WGSize1D, 1, 1};
1427+
1428+
assert(MaxWGSizes[2] != 0);
1429+
1430+
// Set default work-group size in the Z-direction to either the max
1431+
// number of work-items or the maximum work-group size in the Z-direction.
1432+
WGSize = { 1, 1, min(WGSize1D, MaxWGSizes[2]) };
14281433
}
14291434
NDR.set(NDR.Dims, nd_range<3>(NDR.NumWorkGroups * WGSize, WGSize));
14301435
}

0 commit comments

Comments
 (0)