Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when getting the index on the CPU backend #542

Open
JamesWrigley opened this issue Oct 22, 2024 · 1 comment
Open

Exception when getting the index on the CPU backend #542

JamesWrigley opened this issue Oct 22, 2024 · 1 comment
Assignees

Comments

@JamesWrigley
Copy link

JamesWrigley commented Oct 22, 2024

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
@vchuravy
Copy link
Member

Huh that's a fun one...

@vchuravy vchuravy self-assigned this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants