Switch to CompilerCaching.jl#777
Draft
maleadt wants to merge 6 commits into
Draft
Conversation
Replace `cached_compilation` with a `MetalResults` struct attached to each `CodeInstance` via `CompilerCaching`: `metallib` + entry name are session-portable (cached through precompilation), and the `MTLComputePipelineState` is materialized lazily per session. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds a `bitcode` field to `MetalResults` and overrides `GPUCompiler.bitcode` / `bitcode!`. Per-function runtime library bitcode now rides on the same precompilation path as `metallib`/`entry`, so cross-session loads can skip the runtime rebuild. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the single `pipeline` slot on `MetalResults` with a small linear cache of `(MTLDevice, MTLComputePipelineState)` pairs. The cache partition already covers the macOS / AIR / Metal versions that affect codegen, but two `MTLDevice`s on a single Mac (e.g. integrated + discrete) share the same `metallib` and need separate `MTLComputePipelineState`s. Hot-path cost is unchanged: one field load + one `===` compare. The common case (single device) stays at n=1. `link_pipeline` now takes the target `MTLDevice` explicitly instead of calling `device()` internally, so the call site captures the device once under `mtlfunction_lock`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`something(lookup(...), compile_metal!(...))` evaluated `compile_metal!` eagerly even on a cache hit, so every kernel launch silently re-ran the full LLVM compile pipeline. Branch explicitly on the lookup result. Warm-cache `mtlfunction` cost: ~3.4 ms → ~380 ns. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
x-ref JuliaGPU/GPUCompiler.jl#794