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

Better error message for mixing MtlArray and Array operations #212

Open
ViralBShah opened this issue Jun 22, 2023 · 0 comments
Open

Better error message for mixing MtlArray and Array operations #212

ViralBShah opened this issue Jun 22, 2023 · 0 comments
Labels
arrays Things about the array abstraction. enhancement New feature or request

Comments

@ViralBShah
Copy link
Contributor

Here, a is MtlVector and b is Vector. I imagine we don't want people to mix these things and work automatically. Perhaps the error message could be simpler.

julia> a .+ b
ERROR: GPU compilation of MethodInstance for (::GPUArrays.var"#broadcast_kernel#26")(::Metal.mtlKernelContext, ::MtlDeviceVector{Float32, 1}, ::Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{MtlDeviceVector{Float32, 1}, Tuple{Bool}, Tuple{Int64}}, Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}}}, ::Int64) failed
KernelError: passing and using non-bitstype argument

Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{MtlDeviceVector{Float32, 1}, Tuple{Bool}, Tuple{Int64}}, Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}}}, which is not isbits:
  .args is of type Tuple{Base.Broadcast.Extruded{MtlDeviceVector{Float32, 1}, Tuple{Bool}, Tuple{Int64}}, Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}} which is not isbits.
    .2 is of type Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}} which is not isbits.
      .x is of type Vector{Float32} which is not isbits.


Stacktrace:
  [1] check_invocation(job::GPUCompiler.CompilerJob)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/NVLGB/src/validation.jl:96
  [2] macro expansion
    @ ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:99 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:253 [inlined]
  [4] codegen(output::Symbol, job::GPUCompiler.CompilerJob; libraries::Bool, toplevel::Bool, optimize::Bool, cleanup::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing, ctx::LLVM.ThreadSafeContext)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:97
  [5] codegen
    @ ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:92 [inlined]
  [6] compile(target::Symbol, job::GPUCompiler.CompilerJob; libraries::Bool, toplevel::Bool, optimize::Bool, cleanup::Bool, strip::Bool, validate::Bool, only_entry::Bool, ctx::LLVM.ThreadSafeContext)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:88
  [7] compile
    @ ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:79 [inlined]
  [8] compile(job::GPUCompiler.CompilerJob, ctx::LLVM.ThreadSafeContext)
    @ Metal ~/.julia/packages/Metal/9shJi/src/compiler/compilation.jl:59
  [9] #60
    @ ~/.julia/packages/Metal/9shJi/src/compiler/compilation.jl:55 [inlined]
 [10] LLVM.ThreadSafeContext(f::Metal.var"#60#61"{GPUCompiler.CompilerJob{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}})
    @ LLVM ~/.julia/packages/LLVM/5aiiG/src/executionengine/ts_module.jl:14
 [11] JuliaContext
    @ ~/.julia/packages/GPUCompiler/NVLGB/src/driver.jl:35 [inlined]
 [12] compile
    @ ~/.julia/packages/Metal/9shJi/src/compiler/compilation.jl:54 [inlined]
 [13] actual_compilation(cache::Dict{Any, Any}, src::Core.MethodInstance, world::UInt64, cfg::GPUCompiler.CompilerConfig{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}, compiler::typeof(Metal.compile), linker::typeof(Metal.link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/NVLGB/src/execution.jl:125
 [14] cached_compilation(cache::Dict{Any, Any}, src::Core.MethodInstance, cfg::GPUCompiler.CompilerConfig{GPUCompiler.MetalCompilerTarget, Metal.MetalCompilerParams}, compiler::Function, linker::Function)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/NVLGB/src/execution.jl:103
 [15] macro expansion
    @ ~/.julia/packages/Metal/9shJi/src/compiler/execution.jl:162 [inlined]
 [16] macro expansion
    @ ./lock.jl:267 [inlined]
 [17] mtlfunction(f::GPUArrays.var"#broadcast_kernel#26", tt::Type{Tuple{Metal.mtlKernelContext, MtlDeviceVector{Float32, 1}, Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{MtlDeviceVector{Float32, 1}, Tuple{Bool}, Tuple{Int64}}, Base.Broadcast.Extruded{Vector{Float32}, Tuple{Bool}, Tuple{Int64}}}}, Int64}}; name::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Metal ~/.julia/packages/Metal/9shJi/src/compiler/execution.jl:157
 [18] mtlfunction
    @ ~/.julia/packages/Metal/9shJi/src/compiler/execution.jl:155 [inlined]
 [19] macro expansion
    @ ~/.julia/packages/Metal/9shJi/src/compiler/execution.jl:77 [inlined]
 [20] #launch_heuristic#107
    @ ~/.julia/packages/Metal/9shJi/src/gpuarrays.jl:14 [inlined]
 [21] launch_heuristic
    @ ~/.julia/packages/Metal/9shJi/src/gpuarrays.jl:12 [inlined]
 [22] _copyto!
    @ ~/.julia/packages/GPUArrays/t0LfC/src/host/broadcast.jl:65 [inlined]
 [23] copyto!
    @ ~/.julia/packages/GPUArrays/t0LfC/src/host/broadcast.jl:46 [inlined]
 [24] copy
    @ ~/.julia/packages/GPUArrays/t0LfC/src/host/broadcast.jl:37 [inlined]
 [25] materialize(bc::Base.Broadcast.Broadcasted{Metal.MtlArrayStyle{1}, Nothing, typeof(+), Tuple{MtlVector{Float32}, Vector{Float32}}})
    @ Base.Broadcast ./broadcast.jl:873
 [26] top-level scope
    @ REPL[16]:1
 [27] top-level scope
    @ ~/.julia/packages/Metal/9shJi/src/initialization.jl:51

@maleadt maleadt added enhancement New feature or request arrays Things about the array abstraction. labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays Things about the array abstraction. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants