Derive parallel-axis bounds interprocedurally and from dominating guards - #2991
Open
wsmoses wants to merge 1 commit into
Open
Derive parallel-axis bounds interprocedurally and from dominating guards#2991wsmoses wants to merge 1 commit into
wsmoses wants to merge 1 commit into
Conversation
MFEM's runtime-dispatch fallback kernels carry no min-clamp of their own: the ceiling lives in a dispatcher MFEM_VERIFY, the extent crosses the noinline launch-stub boundary as a plain argument, and LLVM deletes any source-level clamp it can prove redundant from those very guards. derivedExtentBound therefore learns to - walk call sites: a stub argument's bound is the max over what direct callers pass (registration addressofs are skipped), with the call site as the anchor so caller-side guards apply to the launch inside - read dominating guards: a noreturn verify arm or the enclosing surviving scf.if branch pins the complementary relation - see through staged scalars (the gpu.alloc + memcpy hoisting), dim3 packing (the 0x100000001 replication, or-with-constant, trunc/shrui halves), llvm.intr.smin/smax forms, extension, bounded sums and products, and selects - fall back to the shapes of static scratch an axis unconditionally indexes, which bound the axis on pain of out-of-bounds boundParallelFors applies the same batching to a parallel-marked affine.for that never became an affine.parallel (identified by its iv appearing as a barrier operand), and a barrier whose iv belongs to a constant-trip affine.for is a no-op exactly like a batched parallel axis. Upper-bound maps using a dim expr instead of a symbol are accepted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
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.
Follow-up to #2981. The bounded-axis batching only helped kernels whose clamp is in the same function as the launch. MFEM's runtime-dispatch fallback families (quadinterpolator, lininteg, restriction) break that assumption three ways: the ceiling lives in a dispatcher
MFEM_VERIFYrather than a min; the extent crosses the noinline device-stub boundary as a plain argument; and LLVM deletes source-level clamps it can prove redundant from those very verifies (addingmin(q1d, MAX_Q1D)at the launch literally compiles away).derivedExtentBoundtherefore learns to:addressofuses are skipped), and the recursion anchors at the call site so caller-side guards apply to the launch inside;cmp+noreturn verify arm, or the surviving branch of an enclosingscf.if, pins the complementary relation (if (d < 25)bounds the axis at 24);gpu.alloc+memcpy hoisting), dim3 packing (x * 0x100000001replication, disjoint-or with a constant, trunc/shrui halves),llvm.intr.smin/smax, extension, bounded sums/products (dof counts like2*(D1D-1)*D1D), and selects;boundParallelForsapplies the same batching to a parallel-markedaffine.forthat never became anaffine.parallel(identified by its iv appearing as a barrier operand), and the #2980 check now accepts a barrier whose iv belongs to a constant-tripaffine.for— lockstep raising gives it the same whole-tensor ordering as a batched parallel axis. Dim-expr upper-bound maps are accepted alongside symbols.On the MFEM sweep this class went from 23 dynamic-barrier TU failures to zero: quadinterpolator.cpp and the lininteg family fully raise, and the QuadratureInterpolator-adjacent runtime battery stays exact.
🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD