Cut allocations when launching CPU kernels - #768
Merged
Merged
Conversation
giordano
added this pull request to stack #770
September 11, 2026 22:25
giordano
force-pushed
the
mg/launch-allocations-p1
branch
from
September 11, 2026 22:25
ca28982 to
afd85a2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Contributor
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Collaborator
Author
|
It'd probably be good to get #774 in first, so that we can actually track memory allocations (besides having more benchmarks) |
Member
|
Can you rebase to pick up the new benchmarks? |
A warm launch of a two-argument kernel on the CPU backend allocated about
50 times (2.2 KiB). Most of it came from Julia not specializing on
`args...` that a method only splats onward, which boxed every kernel
argument on the way from `Kernel` to `clSetKernelArg`; the rest from
per-launch vectors for the work sizes and SVM pointers, a keyword splat
through the generated kernel call, and a device property query.
- Annotate the splatted arguments as `Vararg{Any, N}` in the `Kernel`
call, the generated `AbstractKernel` call, `call` and `set_args!`, and
unroll `set_args!` by recursion instead of `enumerate`.
- Pass each kernel argument to `clSetKernelArg` as a `Ref{T}` `ccall`
argument, which copies it to the stack.
- Pass the global and local work sizes as three-element tuples through a
`ccall` taking `Ref{NTuple{3, Csize_t}}` when there is no offset or
device RNG state, skipping the `max_work_item_dims` query.
- The generated kernel call takes `global_size` and `local_size` as
explicit keywords.
- `clconvert` and `call` take `nothing` for the SVM pointers instead of
allocating an empty vector; no adaptor rule collects such pointers.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
giordano
force-pushed
the
mg/launch-allocations-p1
branch
from
September 12, 2026 17:30
afd85a2 to
1347c84
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
=======================================
Coverage 63.72% 63.73%
=======================================
Files 23 23
Lines 1935 1941 +6
=======================================
+ Hits 1233 1237 +4
- Misses 702 704 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
Allocations reduction confirmed by the benchmarks 👀 |
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.
Redo of #766 in this repo, only first part