Hide GPU runtime stubs from the native cache (v2.0)#799
Conversation
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>
|
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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
| target_type::Type | ||
| always_inline::Bool | ||
| method_table::Core.MethodTable | ||
| method_tables::Tuple{Vararg{Core.MethodTable}} |
There was a problem hiding this comment.
Uuf can we use SimpleVector here?
| [`method_table_view`](@ref) instead; that is an internal hook and most back-ends should | ||
| not need it. | ||
| """ | ||
| method_tables(@nospecialize(job::CompilerJob)) = () |
There was a problem hiding this comment.
Could we make this non-breaking by defining method_tables(...) = (method_table(...),)
There was a problem hiding this comment.
We could, but there's going to be a breaking release anyway (probably).
| # 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) |
There was a problem hiding this comment.
This isn't an OverlayMethodTable,should probably be InternalMethodTable or
|
Alternatively, we could avoid this entirely by making the stub runtime functions not break the Julia JIT. But that's probably tricky. |
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=allsysimages, juliac, PrecompileTools workloads) can link cleanly. The real ccall bodies move into overlays in a privateGLOBAL_METHOD_TABLE.Replaces the singular
method_table(job)override with pluralmethod_tables(job)returning a tuple ofCore.MethodTables. The defaultmethod_table_viewstacks them on top ofGLOBAL_METHOD_TABLE, so back-ends inherit the runtime overlays without naming them.GLOBAL_METHOD_TABLEis internal and back-ends must not@overlayit directly.Back-end migration:
method_table(::MyJob) = mtbecomesmethod_tables(::MyJob) = (mt,). Back-ends that previously overrodemethod_table_viewto build their ownStackedMethodTablecan usually collapse to amethod_tablestuple instead.