Fix SCHEMATIC nested-loop energy accounting and estimator FRAM costs - #85
Merged
Conversation
The shared propagation walkers costed a path crossing an analyzed inner loop as a single iteration; only the private copy inside the convergence loop applied the reference's (n-1)*E_loop charge, so the initial E_loop measurement never saw it. Fold the charge into the shared walkers (with the reference's seed-loop exclusion) and drop the private copy. SCHEMATIC O0 rsa at 50uF was under-costed ~4x; schematicO3 rsa at 5uF is now reported infeasible.
The paper's Algorithm 1 and the reference implementation size the back-edge checkpoint interval without the restore at the checkpoint that starts it, so a loop whose single iteration fits only without that cost is left with an oversized region. Subtract the restore, and when the corrected budget admits no full iteration, split the body at its first fixed inner-loop boundary and recompute the body energies.
The run measured sha256.c (sha256_fixed.c was already deleted in 1d2fc69), but an agent relabeled the output as sha256_fixed to match the stale benchmark list in summarize.py. Region boundaries and compile times of the CSVs match a fresh sha256 compile at the board capacitor, not the old sha256_fixed results.
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
Energy-model corrections for SCHEMATIC's nested-loop accounting and the
assembly estimator's FRAM stack costs, plus a new pass that repairs trip-count
metadata the compiler duplicates when it splits an annotated loop.
SCHEMATIC loop energy
restore cost in the loop iteration budget.
recomputeLoopBodyEnergyOnCFG(~230 lines) with calls to the shared ones. Theinline copy had already drifted: it skipped only the analyzed loop's own back
edge, while the shared walker skips every back edge it reaches.
Assembly estimator / FRAM stack
--stack-access-penalty) for the pipelines whoselinker script places the stack in FRAM (SCHEMATIC, RockClimb), counting only
memory-accessing stack operands.
Trip-count metadata
UnifyAnnotatedLoopPassmerges a loop pair thatLoopSimplifysplit apart.Loop::setLoopIDstamps the annotation on every latch of a multi-latch loop,so after
separateNestedLoopboth halves claim the full trip count. Verifiedon rsa: the latches of
while.cond.iandwhile.cond.i.outerboth carry!llvm.loop !21=tripcount.upper 96, so a consumer that multiplies sees9216 instead of 96.
MILP liveness
main— the only functionAllocaToGlobalPasstransforms.Robustness fixes from review
split:
splitLoopBodyAtFixedBoundaryreports whether every body path got aboundary (a path with no fixed boundary is infeasible, not ignorable), the
budget is re-checked after the split-and-recompute, and the
decision.final*diagnostics are recorded after the budget settles rather than before.
push/pop/callnow also charge their operand's access, sopush 4(r1)counts two FRAM accesses rather than one.UnifyAnnotatedLoopPassinitializes logging like every other pass; without itits only diagnostic was dropped whenever it ran first.
nvm_access_penalty. Thecompile path genuinely requires it, so the loader still fails loudly on a real
config that omits it.
Test plan
uv run pytest tests/— 257 passed.results/milp_debug.csvhad mixed provenance(a full run at
8c8c013with only the three rsa rows overwritten from a laterrsa-only rerun) and is being regenerated in full.