JuliaGPU / JuliaGPU/GPUCompiler.jl
Method overrides cannot override kernels
- Dominant language
- Julia
- Stars
- 187
- Forks
- 68
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 28
Description
```
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
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the example using GPUCompiler.@override, native_code_llvm, and the GPUInterpreter method_table methods. Read the outermost method_table path and Core.Compiler.InferenceState construction, especially the CachedMethodTable conversion error. Done means method overrides affect the compiled kernel without breaking InferenceState construction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100