JuliaGPU / JuliaGPU/KernelAbstractions.jl
`@localmem` silently breaks things when used with non-const dims
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 523
- Forks
- 88
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 25
Description
I'm not sure how to explain this behavior, it's like @localmem cancels the effects of the kernel:
julia> using Metal, KernelAbstractions
julia> backend = Metal.MetalBackend()
MetalBackend()
julia> @kernel function settoone_localmem!(x::AbstractVector)
i = @index(Global)
n = length(x)
y = @localmem Bool (n,)
x[i] = one(eltype(x))
end
settoone_localmem! (generic function with 4 methods)
julia> @kernel function settoone_nolocalmem!(x::AbstractVector)
i = @index(Global)
x[i] = one(eltype(x))
end
settoone_nolocalmem! (generic function with 4 methods)
julia> x = KernelAbstractions.zeros(backend, Float32, 3);
julia> settoone_localmem!(backend)(x; ndrange=length(x)) # fails
julia> x
3-element MtlVector{Float32, Metal.PrivateStorage}:
0.0
0.0
0.0
julia> settoone_nolocalmem!(backend)(x; ndrange=length(x)) # works
julia> x
3-element MtlVector{Float32, Metal.PrivateStorage}:
1.0
1.0
1.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Julia example with MetalBackend and compare the @localmem kernel against the version without local memory, using both non-const and const dimensions. Trace how @localmem handles the dimension expression; done means the kernel writes 1.0 to every element when n is non-const.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100