Skip to content

Commit df6c1a4

Browse files
committed
mapreduce: size the coalesced LTS kernel via launch_configuration
The coalesced-reduction launch used a hardcoded items = clamp(length(Rother), 1, 256), which can exceed the kernel's max work-group size on some devices and fail the launch. Query launch_configuration(kernel) for the actual limit, like the main partial_mapreduce_device path already does. Verified the coalesced path (dim-1-kept reductions) stays correct across a range of sizes, including large Rother. Addresses PR_REVIEW.md additional observation (hardcoded coalesced items).
1 parent e2ddd99 commit df6c1a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/mapreduce.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,13 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::oneWrappedArray{T},
207207
# sweep of `dims=(1,3)`-style mixed reductions with small leading dims (n1 ∈ 2..7) matched
208208
# the CPU exactly, so no extra materialization is needed for those (see PR_REVIEW.md #7).
209209
if oneL0.LTS[] && size(Rreduce, 1) == 1
210-
items = clamp(length(Rother), 1, 256)
210+
# cap the group size at what this kernel actually supports on this device (queried
211+
# from the driver), rather than a hardcoded 256 that can exceed the kernel's max
212+
# work-group size on some devices and fail the launch.
213+
cargs = (f, op, init, Rreduce, Rother, R′, A)
214+
ckernel = zefunction(coalesced_mapreduce_device,
215+
Tuple{Core.Typeof.(kernel_convert.(cargs))...})
216+
items = clamp(length(Rother), 1, launch_configuration(ckernel))
211217
groups = min(cld(length(Rother), items), 1024)
212218
@oneapi items=items groups=groups coalesced_mapreduce_device(
213219
f, op, init, Rreduce, Rother, R′, A)

0 commit comments

Comments
 (0)