Conversation
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)
Contributor
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
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