Repository navigation
Conversation
Every generated loop included <petsc.h>, which takes most of the time needed to compile a small kernel (0.14 s against 0.04 s without it for a trivial loop). Most loops (78 of 122 in the Reynolds demo) use no PETSc at all. The header is now only included for loops that have matrix arguments or call local kernels, and with_attach_debugger includes petscsys.h itself, like with_petsc_event already does for petsclog.h. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UGJuwu7dPzKbSmATxWo9Qc
This branch has not been deployed
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.
Summary
Every loop generated by pyop3 included
<petsc.h>, which took most of the time needed to compile a small kernel. Most loops use no PETSc: in thereynolds_robust_navier_stokes_hdivdemo, 78 of the 122 compiled loops have neither a matrix argument nor a local kernel. These are mostly the layout, map, sparsity and assignment loops.The header is now only included for loops that need it:
Evidence
Compiling the generated loop
idat_0[i] = iwith the flags of pyop3 (mpicc, GCC 15):<petsc.h><petsc.h>tests/firedrake/demos/test_demos_run.py -k reynolds, with fresh caches, run side by side:After: 268.5 s cold, 238 s warm
The warm difference is within the noise between runs.
Merge Danger
Door: two-way
Blast Radius: small
Only the preambles of generated loops change. A loop that uses a PETSc symbol without a matrix argument or a local kernel would now fail to compile. No such loop is generated in the demo. Cached kernels are keyed by their code, so they are recompiled once.
AI assistance: this PR was written with Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code