Support emitting a generated function - #786
Merged
Merged
Conversation
Contributor
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
vchuravy
force-pushed
the
vc/generated-main
branch
from
October 3, 2026 15:03
26e22bb to
63af672
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #786 +/- ##
==========================================
+ Coverage 79.06% 79.35% +0.28%
==========================================
Files 24 24
Lines 2040 2088 +48
==========================================
+ Hits 1613 1657 +44
- Misses 427 431 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vchuravy
commented
Oct 4, 2026
Add a `generated=true` configuration to `@kernel`. The transformed kernel body is quoted and expanded via `macroexpand`, so `$` interpolation is available and `where`-parameters are bound to their values. This makes it possible to e.g. unroll a loop `$N` times with `@unroll $N for ...`, which requires a literal count. Port of #667 (release-0.9) to main / 0.10. Assisted-by: Claude Code (Fable 5.1)
- Reject short-form method definitions wrapped in `where` clauses or a
return type annotation (`g(x::T) where {T} = ...`, `g(x)::T = ...`),
which previously slipped past the closure check and surfaced only as
"kernel returns a value of type `Any`".
- Make `generated_error_body` robust against failures while building the
message, and escape NUL characters, which a `Symbol` cannot contain.
Assisted-by: Claude Code (Opus 5.5)
Assisted-by: Claude Code (Opus 5.5)
vchuravy
force-pushed
the
vc/generated-main
branch
from
October 4, 2026 06:56
9a21d3d to
f947d4c
Compare
vchuravy
commented
Oct 4, 2026
Assisted-by: Claude Code (Opus 5.5)
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.
Port of #667 (which targets
release-0.9) tomainfor 0.10.Adds a
generated=trueconfiguration to@kernel. The transformed kernel body is quoted and run throughmacroexpand, so$interpolation is available inside the kernel andwhere-parameters are bound to their values. This makes it possible to write e.g.since
@unroll Nrequires a literal count.Differences from #667:
mainonly emits the GPU function, so only that path is wrapped.__kernelnow takes__module__alongside__source__.@kerneldocstring documents the new option.test/unroll.jland actually launches the kernel and checks the result (the test added in support emitting a generated function #667 called an undefinedtest_generated_kernel).Locally verified on the CPU (POCL) backend: the unroll, linenumbers and CPU codegen testsuites pass, and
@device_code_llvmon a generated kernel works.🤖 Generated with Claude Code