gem: simplifications supporting Jacobian product cancellation#255
Open
pbrubeck wants to merge 1 commit into
Open
gem: simplifications supporting Jacobian product cancellation#255pbrubeck wants to merge 1 commit into
pbrubeck wants to merge 1 commit into
Conversation
771f757 to
1989f22
Compare
- Fold Indexed(Identity, (i, j)) into Delta(i, j), so that Kronecker deltas introduced by UFL participate in delta elimination. Lower Delta via a Literal identity table in replace_delta, as Indexed(Identity, ...) now folds back into Delta. - COFFEE: iterate argument factorisation to a fixpoint, so that factorised subexpressions are grouped as common factors in subsequent rounds, and group monomials that share the same rest coefficient, so that c*a1 + c*a2 becomes c*(a1 + a2). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1989f22 to
05b4c0f
Compare
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.
Description
GEM-side companion of firedrakeproject/ufl#68, improving the code generated for PhysicallyMapped (zany) elements:
gem.py: foldIndexed(Identity, (i, j))intoDelta(i, j), so the Kronecker deltas introduced by the UFL Jacobian-product cancellation participate in delta elimination and unroll to 0/1 constants.optimise.py: lowerDeltavia aLiteralidentity table inreplace_delta, sinceIndexed(Identity, ...)now folds back intoDelta(this previously madereplace_deltaa no-op, leaking deltas into code generation).coffee.py: iterate argument factorisation to a fixpoint, so subexpressions factorised in one round are grouped as common factors in the next (resolving the long-standing TODO infactorise_atomics), and group monomials sharing the same rest coefficient, soc*a1 + c*a2 + c*a3becomesc*(a1 + a2 + a3). For the Johnson-Mercier div-div term this turns the element tensor accumulation into optimal rank-1 updates.Benchmark (JM mass + div-div, spectral mode, with the companion PRs): 3D flops 763527 -> 444574 (-42%), compile time 3.62s -> 1.81s (-51%), generated code 323kB -> 143kB (-56%).
🤖 Generated with Claude Code