Repository navigation
Conversation
This was referenced Sep 30, 2026
Closed
Contributor
CUDA.jl BenchmarksDetails
This comment was automatically generated by workflow using github-action-benchmark. |
This was referenced Oct 2, 2026
This was referenced Oct 7, 2026
maleadt
force-pushed
the
ka-0.10
branch
2 times, most recently
from
October 12, 2026 07:52
6461633 to
34e43e0
Compare
KernelAbstractions 0.10 builds on KernelInterface, which defines what a back end provides: memory and device management, compiling and launching kernels, and the device-side intrinsics. KernelAbstractions then launches `@kernel` kernels itself on any KernelInterface back end, which replaces CUDA's copy of that launch path: partitioning the ndrange, building the kernel's context, and tuning the workgroup size. `CUDABackend` now implements KernelInterface in CUDACore, which depends on it instead of on KernelAbstractions. What KernelAbstractions still needs from a back end moves to an extension: the `MArray` behind `@private`, the Adapt rule for `@Const`, and the `maxthreads` hint for a static workgroup size. `prefer_blocks` now applies in `KI.launch_configuration`, which receives the number of work-items. `KI.launch` passes the kernel arguments on as a tuple, so kernels with many arguments stay cheap to launch, as #3309 made them for the old launch path. It rejects `threads` and `blocks`, which would override the launch geometry that KernelInterface validated. `KI.copyto!` accepts dense arrays and contiguous views of them, as the old `KA.copyto!` did. KernelAbstractions converts the arguments twice, to determine the types to compile for and again when launching, where CUDA's launch converted them once. `cudaconvert` has to be pure, so this only shows with conversions that have side effects, as in two tests that count them. Co-authored-by: Christian Guinard <28689358+christiangnrd@users.noreply.github.com>
Sub-groups are warps: implement the sub-group queries, `sub_group_barrier` and `shfl_down`, and report their support to KernelInterface. KernelInterface leaves unspecified how work-items are grouped into sub-groups; CUDA forms warps from consecutive linear thread indices, so the last warp of a block can be partial, which a test checks. Co-authored-by: Christian Guinard <28689358+christiangnrd@users.noreply.github.com>
Implement `KI.record_event` and `KI.wait_event` with a `CuEvent` recorded on, and waited for by, the task's stream. `KernelAbstractions.@spawn` uses them to order a new task's work after the work its parent had queued, without synchronizing the parent; the default is a full synchronization. KernelInterface's testsuite checks them once `record_event` returns an event.
`KI.versioninfo(CUDABackend())` prints `CUDA.versioninfo()`.
KernelAbstractions now backs @Private with a stack-allocated PrivateArray, provided as an overlay in GPUCompiler's shared method table, which CUDA's method table already stacks on top of. Drop our MArray-based Scratchpad override so that it takes effect, and require GPUCompiler 2.12. That leaves StaticArrays only for the dimension_mismatch_fail device override, so make it a weak dependency with a regular extension.
KI.max_work_group_size and KI.launch_configuration are specialized on the kernel, so their bodies were compiled for every kernel launched through KernelAbstractions. Forward them to functions of the CuFunction, which are compiled once.
Implement the sub-group communication of KernelInterface's updated contract: `shfl`, `shfl_up` and `shfl_xor` next to `shfl_down`, their variants within segments of a `width` (a single `shfl.sync` each), and the votes `sub_group_any`, `sub_group_all` and `sub_group_ballot`, using the warp intrinsics with the full mask. Warps are formed from consecutive linear thread indices and are independent, so report `supports_linear_subgroups` and `supports_independent_subgroups`. The shuffles, and `supports_shuffle`, are restricted to the primitive types CUDA's warp shuffles support, so that KernelInterface shuffles structs and tuples (including `Complex`) field by field. `shfl.sync` only uses the low 5 bits of an offset, so offsets past the warp (including ones that don't fit in 32 bits) become 0, giving the thread's own value as KernelInterface requires. The warp size is the constant 32 rather than a read of `%WARP_SZ`, so that `get_max_sub_group_size` is a constant of the generated code, and the sub-group queries are computed with unsigned 32-bit shifts. Co-authored-by: Tim Besard <tim@juliahub.com>
On sm_80 and later, implement `sub_group_reduce` of `+`, `min`, `max`, `&`, `|` and `⊻` on 32-bit integers with a single `redux.sync`. These operators are commutative, so the order of the lanes, which KernelInterface's reduction follows, doesn't change the result. Other operators, types and devices use KernelInterface's fallback. Co-authored-by: Tim Besard <tim@juliahub.com>
Report `supports_partitionable_subgroups`: the functions with a `width` now pass the member mask of the caller's segment to the `.sync` warp intrinsics instead of the full mask, so that only the threads of that segment have to execute them together. This covers the width shuffles, the votes (masking other segments out of the ballot and shifting it to the segment), the 32-bit integer reductions with `redux.sync`, and the width `sub_group_barrier`, which becomes `bar.warp.sync` on the segment. Other reductions and scans use KernelInterface's fallbacks on top of the width shuffles. The width is a constant, so a width of 32 still compiles to the full mask. This lets KernelAbstractions put several narrow tiles in one warp: a DG-like kernel with tiles of 16 runs 2.4x faster with 16 tiles per block than with a block per tile.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3314 +/- ##
==========================================
- Coverage 87.07% 85.08% -2.00%
==========================================
Files 191 191
Lines 19472 19242 -230
==========================================
- Hits 16956 16372 -584
- Misses 2516 2870 +354 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 13, 2026
maleadt
added a commit
that referenced
this pull request
Oct 14, 2026
…3391) Since KernelAbstractions 0.10 (#3314) this step takes 7-10 minutes longer when the precompile cache is cold: KA 0.10 itself precompiles much slower, core/exceptions recompiles the stack at two extra debug levels, and the KA/KernelInterface tests grew. It was already at 17-25 minutes, so it now hits the 30-minute limit. Match the other memory-configuration steps.
SimonDanisch
added a commit
to SimonDanisch/CUDA.jl
that referenced
this pull request
Oct 16, 2026
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.
KernelAbstractions 0.10 moves its back-end API into a separate package, KernelInterface. A back end implements KernelInterface: allocating and copying memory, selecting devices, compiling and launching kernels, and the device-side intrinsics. KernelAbstractions then launches
@kernelkernels the same way on every back end (JuliaGPU/KernelAbstractions.jl#801). This PR ports CUDA.jl to that model in one step. It replaces #3246, which added KernelInterface next to the existing KernelAbstractions 0.9 back end, and #3302/#3304, which then ported that to KernelAbstractions 0.10.CUDABackendnow implements KernelInterface, in CUDACore, which depends on KernelInterface instead of KernelAbstractions. That makes the KernelInterface layer usable on its own, without KernelAbstractions' macros:KernelAbstractions becomes a weak dependency. Its extension only provides what KernelAbstractions still needs from a back end: the
MArraybehind@private, the Adapt rule behind@Const, and themaxthreadshint for kernels with a static workgroup size. CUDA's own copy of the KernelAbstractions launch path goes away: partitioning the ndrange, building the kernel's context, tuning the workgroup size, and calling the kernel. What remains specific to KernelAbstractions is a 37-line extension.Kernels behave the same, but they are launched differently. KernelAbstractions now launches them on a 3-D grid, and computes
@indexin 32 bits when the iteration space fits (JuliaGPU/KernelAbstractions.jl#797). So a kernel over a 3-Dndrangedoesn't need divisions to compute its index. The test suite checks that for the generated PTX. With a KA kernel that copies aFloat32array, on an RTX 5080:@index(Global, Cartesian)@index(Global, Linear)@index(Global, Cartesian)@index(Global, Linear)CUDABackend(; prefer_blocks=true)still prefers more, smaller blocks. It now takes effect inKI.launch_configuration, which receives the number of work-items to cover.Launching kernels with many arguments stays as cheap as with #3309. KernelInterface 0.4 passes the arguments to the back end as a tuple (JuliaGPU/KernelAbstractions.jl#811), and CUDA forwards that tuple to its own launch.
KI.launchrejectsthreadsandblocks, which would override the launch geometry KernelInterface has validated, but passes CUDA's other launch options on:The first commit is the port. The next ones implement parts of KernelInterface that are optional: sub-groups (warps, including a partial last warp), ordering work across tasks with CUDA events for
KernelAbstractions.@spawn, andKI.versioninfo.One regression remains. KernelAbstractions converts the arguments twice, once to determine the argument types to compile for and once when launching, where CUDA converted them once.
cudaconvertis supposed to be pure, so this only shows with a conversion that has side effects. Two tests that count conversions are now@test_broken.This needs a breaking release, since it requires KernelAbstractions 0.10, which isn't registered yet. Until then, the last commit takes KernelAbstractions and KernelInterface from their development branch, through
[sources]and, for Julia 1.10 and 1.11, which don't pick those up, by developing them explicitly on Buildkite. That commit is dropped before merging.