Repository navigation
Conversation
Support local memory whose size is chosen at launch: the `localmem` launch keyword, `KI.dynamic_localmemory`, `KI.dynamic_localmemory_size` and `KI.max_dynamic_localmemory`. Kernels that use the block get two more arguments, after the others: a pointer to local memory, and the size the launch asked for. They are added by `add_input_arguments!` when the module has been linked, so only kernels that use the block change. Launches of such a kernel size the pointer argument, which makes Level Zero allocate the memory, also when they ask for none. Nothing specifies how the driver aligns that memory, so launches allocate 16 bytes more than they were asked for, and the kernel aligns the block itself. That also keeps the allocation from being empty. A launch can ask for what the device has for a work-group, less the static local memory of the kernel and those 16 bytes. `@oneapi` and calls of a `HostKernel` take `localmem` as well. Assisted-by: Claude Code (Fable 5.2)
…cal memory branch Dynamic local memory needs the KernelInterface of JuliaGPU/KernelAbstractions.jl's `ccr-c54f0813-yayzye` branch. To be dropped when that is released. Julia 1.10 ignores `[sources]`, so its tests keep using the released packages. Assisted-by: Claude Code (Fable 5.2)
maleadt
force-pushed
the
vc/ki-dynamic-localmem
branch
from
December 2, 2026 10:40
09cb799 to
e0ab4ff
Compare
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.
Implements KernelInterface's dynamic local memory for
oneAPIBackend. The KernelInterface side is theccr-c54f0813-yayzyebranch of JuliaGPU/KernelAbstractions.jl; the CUDA counterpart is JuliaGPU/CUDA.jl#3620.Nothing here has run on a Level Zero device. The machine it was written on has none; CI is the first run. Code generation was checked without a device.
Changes
julia.oneapi.dynamic_localmemoryandjulia.oneapi.dynamic_localmemory_size.finish_linked_module!hook turns them into the last two kernel arguments withGPUCompiler.add_input_arguments!: a pointer in the Workgroup address space, then the requested size. Only kernels that use the block get them, and those are flagged ononeAPIResultsandZeKernel.onecalltakeslocalmem::Int=0. For a flagged kernel it sizes the pointer argument withzeKernelSetArgumentValue(kernel, index, localmem + 16, C_NULL)and sets the size argument. Kernels without the arguments ignorelocalmem.KI.max_dynamic_localmemoryismaxSharedLocalMemoryof the device, less the kernel'slocalMemSizeand the 16 bytes of padding.@oneapialso acceptslocalmem. This goes beyond KernelInterface and is easy to drop.What was checked without a device
GPUCompiler.compileto LLVM IR and SPIR-V with both back-ends, for five kernels: a kernel that doesn't use the block is unchanged; every kernel that does getsptr addrspace(3) dynamic_localmemory, i64 dynamic_localmemory_sizeas its last two parameters. All ten SPIR-V modules passspirv-val.Assumptions to confirm in CI
ze_api.hsays so; the runtime behaviour is unverified, including that the size persists and that the validation layer accepts the null value.kernel_arg_addr_spacemetadata.onecalldoes, so the two new ones are atlength(args) + 1and+ 2.localMemSizeis the static local memory only and doesn't change once the argument is sized. The new test set asserts the limit formula exactly and launches at the limit; those assertions are the most likely to need adjusting.maxSharedLocalMemoryis in bytes and bounds static plus argument local memory together.Before merging
[sources]at the KernelAbstractions branch. Julia 1.10 ignores[sources], so oneAPI.jl fails to load there until KernelInterface is released.🤖 Generated with Claude Code