Skip to content

Unroll factor compilation not available for Val values #665

Description

@evelyne-ringoot

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions