Skip to content

Method overrides cannot override kernels #208

@maleadt

Description

@maleadt
julia> kernel() = 0
kernel (generic function with 1 method)

julia> GPUCompiler.@override method_table kernel() = 1

julia> native_code_llvm(kernel, Tuple{})
;  @ REPL[1]:1 within `kernel`
; Function Attrs: alwaysinline
define i64 @julia_kernel_683() local_unnamed_addr #0 {
top:
  ret i64 0
}

The reason for this is that we implement Core.Compiler.method_table(interp::GPUInterpreter, sv::InferenceState), whereas for the outermost function Core.Compiler.method_table(interp::GPUInterpreter) seem to be called. But we can't implement that method, because that breaks InferenceState construction:

ERROR: LoadError: MethodError: no method matching convert(::Type{Core.Compiler.CachedMethodTable{Core.Compiler.InternalMethodTable}}, ::Core.Compiler.CachedMethodTable{Core.Compiler.OverlayMethodTable})
Closest candidates are:
  convert(::Type{Union{}}, ::Any) at essentials.jl:216
  convert(::Type{Any}, ::Any) at essentials.jl:217
  convert(::Type{T}, ::T) where T at essentials.jl:218
Stacktrace:
  [1] Core.Compiler.InferenceState(result::Core.Compiler.InferenceResult, src::Core.CodeInfo, cached::Bool, interp::GPUCompiler.GPUInterpreter)
    @ Core.Compiler ./compiler/inferencestate.jl:106

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