JuliaGPU / JuliaGPU/GPUCompiler.jl

InvalidIRError: hide GC intrinsics

Open
#554 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Julia
Stars
187
Forks
68
Avg merge
1d 12h
Merged PRs (30d)
28

Description

When there's actual useful frames to report, the GC ones are pretty much irrelevant:

```
julia> map(i->evalpoly(i,p.coefficients), cux)
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#broadcast_kernel#34")(::CUDA.CuKernelContext, ::CuDeviceVector{…}, ::CartesianIndices{…}, ::Base.Broadcast.Broadcasted{…}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported call to an unknown function (call to julia.new_gc_frame)
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[2] _broadcast_getindex
@ ./broadcast.jl:682
[3] getindex
@ ./broadcast.jl:636
[4] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
Reason: unsupported call to an unknown function (call to julia.push_gc_frame)
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[2] _broadcast_getindex
@ ./broadcast.jl:682
[3] getindex
@ ./broadcast.jl:636
[4] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
Reason: unsupported call to an unknown function (call to julia.get_gc_frame_slot)
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[2] _broadcast_getindex
@ ./broadcast.jl:682
[3] getindex
@ ./broadcast.jl:636
[4] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
Reason: unsupported dynamic function invocation (call to getproperty)
Stacktrace:
[1] #34
@ ./REPL[25]:1
[2] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[3] _broadcast_getindex
@ ./broadcast.jl:682
[4] getindex
@ ./broadcast.jl:636
[5] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
Reason: unsupported dynamic function invocation (call to evalpoly)
Stacktrace:
[1] #34
@ ./REPL[25]:1
[2] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[3] _broadcast_getindex
@ ./broadcast.jl:682
[4] getindex
@ ./broadcast.jl:636
[5] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
Reason: unsupported call to an unknown function (call to julia.pop_gc_frame)
Stacktrace:
[1] _broadcast_getindex_evalf
@ ./broadcast.jl:709
[2] _broadcast_getindex
@ ./broadcast.jl:682
[3] getindex
@ ./broadcast.jl:636
[4] broadcast_kernel
@ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:62
```

However, we can't always hide them, as it's possible that there's GC operations without type instabilities (as commonly encountered with escaping `StaticArray`s).

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the shown Julia expression and inspect the InvalidIRError diagnostic path using the stacktrace entries in broadcast.jl and GPUArrays/src/host/broadcast.jl. Determine when GC intrinsic frames can be omitted without hiding GC operations caused by type instability or escaping StaticArrays. Done means useful frames remain visible while irrelevant GC frames are suppressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.