Repository navigation
Conversation
KernelInterface 0.5 drops `KI.sub_group_size`, the width every kernel ran at: a kernel is now only guaranteed a sub-group width it requests when it is constructed. The block reductions and scans size their local memory and pick their code paths by that width, so choose it from `KI.sub_group_sizes` (the first width that fits the block, which is the backend's suggestion where it fits) and construct every kernel that takes it with `sub_group_size = W`. Kernels on the local-memory path request nothing. This needs KernelAbstractions 0.10.10, whose kernel constructors take the request, so support for KernelAbstractions 0.9 goes, together with the guards for it. KernelInterface is imported directly.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports AcceleratedKernels to KernelInterface 0.5 (JuliaGPU/KernelAbstractions.jl#990), as AcceleratedKernels 0.6.0. The 0.5.x series stays on KernelInterface 0.4 (#217, released as 0.5.14).
What changes
KernelInterface 0.5 removes
KI.sub_group_size(backend), the one width at which every kernel ran. Instead a backend lists the widths a kernel can request (KI.sub_group_sizes(backend), its suggestion first), and only a kernel constructed withsub_group_size = Wis guaranteed to run at widthW. Without a request, the backend may choose any width.AcceleratedKernels' block reductions and scans (
src/block.jl) depend on knowing the width on the host. It sizes their local memory (a slot per sub-group), and it selects theByLanesreductions that reduce a whole output within one sub-group. So:subgroup_widthnow picks the first width inKI.sub_group_sizesthat meets the existing conditions (sub-groups enabled by the tuning, linear sub-groups, shuffles of the element type, a power of two,W ≤ block_size ≤ W²). It falls back toVal(0), the local-memory path, when no width fits.Val(W)is now constructed withsub_group_size = W, using KernelAbstractions 0.10.10's new constructor keyword. These are the scan, tile-aggregate and compaction kernels, the 1-D, ordered, by-block, by-block-vector, by-lanes and multigroup reductions, the second pass that combines groups, andRadixSelect's block, histogram and resolve kernels. Kernels on the local-memory path request nothing, so they compile as before.RadixSelect's resolve kernel takes both a scan width and a reduction width. A kernel can request only one width, sosub_group_request(WS, WR)checks that the two agree. They always do: both are chosen for the same block size, and the element type decides only whether a width is usable at all, never which one is picked.import KernelInterface as KI). The compat entries are nowKernelInterface = "0.5"andKernelAbstractions = "0.10.10".isdefined(KernelAbstractions, :KernelInterface)guards are gone, as is the 0.9 special case ofruns_kernelsfor the host backend. The docs and comments that mentioned 0.9 are updated to match.The back-end extensions (
ext/) needed no changes, since none of them uses the sub-group width.Behaviour per device
(32, 1, 2, 4, 8, 16, 64), so blocks of 256 threads use width 32, as before. Its CPU tunings keep sub-groups off by default.tb/ki-0.5): it offers(32, 8, 16), so blocks of 256 threads request 32, the width they used before.Testing
On Julia 1.12, against
tb/sub-group-request, on a Ryzen 9 5950X:--cpu --cpu-ka, which covers the threaded algorithms and AK's kernels on PoCL, including the sub-group reductions and scans that the tests force on:Overall | 104449 104449, SUCCESS.tb/ki-0.5:Overall | 52891 52891, SUCCESS.ByLanes,ByBlock,ByBlocksand ordered reductions, 1-D and sliced scans, andfindall:findall, andRadixSelectfor slices of one block and for the global passes). The other widths do not fit blocks of 256.sub_group_requestreturningnothing), the kernels compile at the default width of 32. Width 32 still gave 19/19 correct, but 16 gave only 4/19 on both PoCL and oneAPI. On PoCL, width 64 gave 2/15 on the reductions, scans andfindall, and then hung inRadixSelect. So the request is what makes a non-default width correct.Not tested here: the CUDA, AMDGPU, Metal and OpenCL back-ends. Each has a KernelInterface 0.5 branch (
tb/ki-0.5) whose[TEMP]commit points at this branch, and KernelAbstractions.jl#990's Buildkite jobs test them together.Before merging
Drop the
[TEMP]commit, which points[sources]at the KernelInterface 0.5 branch of KernelAbstractions, once KernelInterface 0.5 and KernelAbstractions 0.10.10 are registered.