Skip to content

Hide GPU runtime stubs from the native cache (v2.0)#799

Draft
maleadt wants to merge 1 commit into
mainfrom
tb/method_tables
Draft

Hide GPU runtime stubs from the native cache (v2.0)#799
maleadt wants to merge 1 commit into
mainfrom
tb/method_tables

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented May 19, 2026

Re-lands #749, by forcing stacked method overlays to be used by all back-ends. CPU-visible bodies of the runtime intrinsic stubs no longer reference extern gpu_* symbols, so AOT pipelines (compile=all sysimages, juliac, PrecompileTools workloads) can link cleanly. The real ccall bodies move into overlays in a private GLOBAL_METHOD_TABLE.

Replaces the singular method_table(job) override with plural method_tables(job) returning a tuple of Core.MethodTables. The default method_table_view stacks them on top of GLOBAL_METHOD_TABLE, so back-ends inherit the runtime overlays without naming them. GLOBAL_METHOD_TABLE is internal and back-ends must not @overlay it directly.

Back-end migration: method_table(::MyJob) = mt becomes method_tables(::MyJob) = (mt,). Back-ends that previously overrode method_table_view to build their own StackedMethodTable can usually collapse to a method_tables tuple instead.

@maleadt maleadt requested a review from vchuravy May 19, 2026 11:17
Re-lands #749. CPU-visible bodies of the runtime
intrinsic stubs no longer reference `extern gpu_*` symbols, so AOT pipelines
(`compile=all` sysimages, juliac, PrecompileTools workloads) can link cleanly.
The real ccall bodies move into overlays in a private `GLOBAL_METHOD_TABLE`.

Replaces the singular `method_table(job)` override with plural
`method_tables(job)` returning a tuple of `Core.MethodTable`s. The default
`method_table_view` stacks them on top of `GLOBAL_METHOD_TABLE`, so back-ends
inherit the runtime overlays without naming them. `GLOBAL_METHOD_TABLE` is
internal and back-ends must not `@overlay` it directly.

Back-end migration: `method_table(::MyJob) = mt` becomes
`method_tables(::MyJob) = (mt,)`. Back-ends that previously overrode
`method_table_view` to build their own `StackedMethodTable` can usually
collapse to a `method_tables` tuple instead.

Co-Authored-By: Anton Pozharskiy <apozharski@gmail.com>
@maleadt maleadt force-pushed the tb/method_tables branch from af31c5b to 403d00a Compare May 19, 2026 11:18
@maleadt
Copy link
Copy Markdown
Member Author

maleadt commented May 19, 2026

It's kinda unfortunate that this is breaking, but the migration to CompilerCaching.jl is going to be breaking anyway, so let's go with the cleaner API here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.10%. Comparing base (ef59201) to head (403d00a).

Files with missing lines Patch % Lines
src/runtime.jl 50.00% 1 Missing ⚠️
src/utils.jl 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #799      +/-   ##
==========================================
+ Coverage   75.05%   75.10%   +0.04%     
==========================================
  Files          25       25              
  Lines        3901     3912      +11     
==========================================
+ Hits         2928     2938      +10     
- Misses        973      974       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/interface.jl
target_type::Type
always_inline::Bool
method_table::Core.MethodTable
method_tables::Tuple{Vararg{Core.MethodTable}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uuf can we use SimpleVector here?

Comment thread src/interface.jl
[`method_table_view`](@ref) instead; that is an internal hook and most back-ends should
not need it.
"""
method_tables(@nospecialize(job::CompilerJob)) = ()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this non-breaking by defining method_tables(...) = (method_table(...),)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but there's going to be a breaking release anyway (probably).

Comment thread src/interface.jl
# GPUCompiler's runtime-intrinsic overlay table. Back-ends generally shouldn't override
# this; override `method_tables(job)` instead.
function method_table_view(@nospecialize(job::CompilerJob))
parent = CC.OverlayMethodTable(job.world, GLOBAL_METHOD_TABLE)
Copy link
Copy Markdown
Member

@vchuravy vchuravy May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an OverlayMethodTable,should probably be InternalMethodTable or

@maleadt maleadt marked this pull request as draft May 19, 2026 13:30
@maleadt
Copy link
Copy Markdown
Member Author

maleadt commented May 19, 2026

Alternatively, we could avoid this entirely by making the stub runtime functions not break the Julia JIT. But that's probably tricky.

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

Successfully merging this pull request may close these issues.

2 participants