Qualified `KA.@index` macro not detected.
When running this slightly minified code from the quickstart guide:
import KernelAbstractions as KA
KA.@kernel function mul2_kernel(A)
I = KA.@index(Global, Linear)
end
dev = KA.CPU()
A = ones(1024, 1024)
ev = mul2_kernel(dev, 64)(A, ndrange=size(A))
KA.synchronize(dev)
all(A .== 2.0)
I get this exception (only on the CPU backend, the CUDA backend works):
TaskFailedException
nested task error: MethodError: no method matching __index_Global_Linear(::KernelAbstractions.CompilerMetadata{KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.NoDynamicCheck, CartesianIndex{2}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.StaticSize{(64, 1)}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Nothing}})
The function `__index_Global_Linear` exists, but no method is defined for this combination of argument types.
Closest candidates are:
__index_Global_Linear(::Any, ::CartesianIndex)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/491pi/src/cpu.jl:163
Stacktrace:
[1] macro expansion
@ ./In[85]:3 [inlined]
[2] cpu_mul2_kernel
@ ~/.julia/packages/KernelAbstractions/491pi/src/macros.jl:291 [inlined]
[3] (::var"#cpu_mul2_kernel#9")(__ctx__::KernelAbstractions.CompilerMetadata{KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.NoDynamicCheck, CartesianIndex{2}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.StaticSize{(64, 1)}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Nothing}}, A::Matrix{Float64})
@ Main ./none:0
[4] __thread_run(tid::Int64, len::Int64, rem::Int64, obj::KernelAbstractions.Kernel{CPU, KernelAbstractions.NDIteration.StaticSize{(64,)}, KernelAbstractions.NDIteration.DynamicSize, var"#cpu_mul2_kernel#9"}, ndrange::Tuple{Int64, Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.StaticSize{(64, 1)}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Nothing}, args::Tuple{Matrix{Float64}}, dynamic::KernelAbstractions.NDIteration.NoDynamicCheck)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/491pi/src/cpu.jl:144
[5] (::KernelAbstractions.var"#20#23"{KernelAbstractions.Kernel{CPU, KernelAbstractions.NDIteration.StaticSize{(64,)}, KernelAbstractions.NDIteration.DynamicSize, var"#cpu_mul2_kernel#9"}, Tuple{Int64, Int64}, KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.StaticSize{(64, 1)}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Nothing}, Tuple{Matrix{Float64}}, KernelAbstractions.NDIteration.NoDynamicCheck, Int64})()
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/491pi/src/cpu.jl:119
...and 39 more exceptions.
Stacktrace:
[1] sync_end(c::Channel{Any})
@ Base ./task.jl:466
[2] macro expansion
@ ./task.jl:499 [inlined]
[3] __run(obj::KernelAbstractions.Kernel{CPU, KernelAbstractions.NDIteration.StaticSize{(64,)}, KernelAbstractions.NDIteration.DynamicSize, var"#cpu_mul2_kernel#9"}, ndrange::Tuple{Int64, Int64}, iterspace::KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.StaticSize{(64, 1)}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Nothing}, args::Tuple{Matrix{Float64}}, dynamic::KernelAbstractions.NDIteration.NoDynamicCheck, static_threads::Bool)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/491pi/src/cpu.jl:118
[4] (::KernelAbstractions.Kernel{CPU, KernelAbstractions.NDIteration.StaticSize{(64,)}, KernelAbstractions.NDIteration.DynamicSize, var"#cpu_mul2_kernel#9"})(args::Matrix{Float64}; ndrange::Tuple{Int64, Int64}, workgroupsize::Nothing)
@ KernelAbstractions ~/.julia/packages/KernelAbstractions/491pi/src/cpu.jl:46
[5] top-level scope
@ In[85]:9
These are the versions I'm running it with:
% julia --project
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.11.1 (2024-10-16)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
(james) pkg> st
Status `Project.toml`
[824d6782] Bonito v3.2.2
[052768ef] CUDA v5.5.2
[f68482b8] Cthulhu v2.15.2
[8bb1440f] DelimitedFiles v1.9.1
[7a1cc6ca] FFTW v1.8.0
[63c18a36] KernelAbstractions v0.9.28
[2fda8390] LsqFit v0.15.0
[67456a42] OhMyThreads v0.7.0
[6099a3de] PythonCall v0.9.23
[276b4fcb] WGLMakie v0.10.14
Huh that's a fun one...
I've encountered the same issue, has anyone found a quick fix to get around the problem?
It doesn't matter if it is inneficient since it only show up on theCPU backend, but it currently prevents me from testing my package in the CI.
Alas, no. My quick fix is not use CPUs 😎
Great news, will email GitHub to kindly ask they add a few GPU to their runners 🚀🚀
Actually this is fixed on master, so I'll close it. @vchuravy, any chance of getting a new release with the fix?
Master will need some more work to stabilize, it's a breaking release
Roger that 👍 Out of curiosity, what more work would be necessary? I might be able to find some time for it in the next few weeks.
(not that I know much about KA 😅 )
Gentle bump, is there a timeline for when the next release will come out?
#600 is currently tracking some of the work needed, but otherwise when it's done and tested enough
Roger that, is there anything a relative noob could help out with? (disclaimer: I will likely not have a lot of time to work on it for a few weeks)
Note that this is due to the use of KA.@index instead of @index
julia> KA.@kernel function mul2_kernel(A)
I = @index(Global, Linear)
end
works.
This is due to https://github.com/JuliaGPU/KernelAbstractions.jl/blob/1f84b17414bc325fce199d51e97f75a408aa1e63/src/macros.jl#L237
Oh my god, I can't believe I avoided using KA on CPUs for like a year because of this 🤦
😢