KernelAbstractions.jl
KernelAbstractions.jl copied to clipboard
weird issue with index macro
using KernelAbstractions
@kernel function kernel_index!(a)
i = KernelAbstractions.@index(Global)
@inbounds a[i] = i
end
let
a = zeros(1)
kernel! = kernel_index!(CPU(), 1, 1)
event = kernel!(a)
wait(event)
end
fails with
TaskFailedException:
MethodError: no method matching __index_Global_Linear()
Stacktrace:
[1] call at /home/mwarusz/.julia/packages/Cassette/7OymZ/src/context.jl:450 [inlined]
[2] fallback at /home/mwarusz/.julia/packages/Cassette/7OymZ/src/context.jl:448 [inlined]
[3] _overdub_fallback at /home/mwarusz/.julia/packages/Cassette/7OymZ/src/overdub.jl:486 [inlined]
[4] ##cpu_kernel_index!#423 at /home/mwarusz/repos/KernelAbstractions.jl/src/macros.jl:4 [inlined]
[5] (::KernelAbstractions.var"#22#27"{Cassette.Context{nametype(CPUCtx),KernelAbstractions.CompilerMetadata{KernelAbstractions.StaticSize{(1,)},KernelAbstractions.StaticSize{(1,)},false,Int64,Nothing,Nothing},Nothing,KernelAbstractions.var"##PassType#422",Nothing,Cassette.DisableHooks},KernelAbstractions.Kernel{CPU,KernelAbstractions.StaticSize{(1,)},KernelAbstractions.StaticSize{(1,)},var"###cpu_kernel_index!#423"},Tuple{Array{Float64,1}}})() at ./threadingconstructs.jl:113
Stacktrace:
[1] macro expansion at ./task.jl:319 [inlined]
[2] macro expansion at /home/mwarusz/repos/KernelAbstractions.jl/src/backends/cpu.jl:38 [inlined]
[3] (::KernelAbstractions.var"#18#23"{KernelAbstractions.Kernel{CPU,KernelAbstractions.StaticSize{(1,)},KernelAbstractions.StaticSize{(1,)},var"###cpu_kernel_index!#423"},Tuple{Array{Float64,1}},Int64,Bool})() at ./threadingconstructs.jl:113
Stacktrace:
[1] wait at ./task.jl:251 [inlined]
[2] wait at /home/mwarusz/repos/KernelAbstractions.jl/src/backends/cpu.jl:7 [inlined]
[3] wait(::KernelAbstractions.CPUEvent) at /home/mwarusz/repos/KernelAbstractions.jl/src/backends/cpu.jl:6
[4] top-level scope at /home/mwarusz/repos/KernelAbstractions.jl/examples/unroll_issue.jl:13
in expression starting at /home/mwarusz/repos/KernelAbstractions.jl/examples/unroll_issue.jl:9
Probably an issue with using the prefix form... The challenge of doing this as a macro, things are not normalized yet.
Yeah we would need to add a variant of KernelAbstractions.@index for
https://github.com/JuliaGPU/KernelAbstractions.jl/blob/d983201a47460eee32705bd9ee3903c242519ce1/src/macros.jl#L160-L175
I am hesitant to do that since people might think Oceanigans.KernelAbstractions.@index would then also work, but on the otherhand maybe we can normalize the name...