JuliaGPU / JuliaGPU/KernelAbstractions.jl
Unroll factor compilation not available for Val values
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 523
- Forks
- 88
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 25
Description
I am trying to do the following:
using KernelAbstractions, CUDA
using KernelAbstractions.Extras: @unroll
backend = CUDABackend()
@kernel function add1_kernel!(A, ::Val{VALSPERTHREAD} = Val(4), ::Val{UNROLLFACTOR} = Val(4)) where {VALSPERTHREAD, UNROLLFACTOR}
I = @index(Global,Linear)
@unroll UNROLLFACTOR for i in 0:VALSPERTHREAD-1
@inbounds A[I*4+i] = A[I*4+i]+1
end
end
function myadd!(A)
backend = get_backend(A)
kernel = add1_kernel!(backend)
kernel(A, ndrange = (Int(length(A)/4)))
return
end
A = KernelAbstractions.zeros(backend, Float32, 64)
myadd!(A)
KernelAbstractions.synchronize(backend)
And getting an error:
ERROR: LoadError: Syntax error: `@unroll N expr` needs a constant integer N
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] var"@unroll"(__source__::LineNumberNode, __module__::Module, N::Any, expr::Any)
@ KernelAbstractions.Extras.LoopInfo C:\Users\evely\.julia\packages\KernelAbstractions\lGrz7\src\extras\loopinfo.jl:60
in expression starting at C:\Users\evely\NextLATuner\juliakernels\unrollparam.jl:7
in expression starting at C:\Users\evely\NextLATuner\juliakernels\unrollparam.jl:5
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
Start by reproducing the example with the CUDA backend and read src/extras/loopinfo.jl around the @unroll implementation and its constant-integer check. Determine how Val parameters reach the macro, then add support if appropriate and verify that the shown kernel compiles and runs without the syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100