cosim: key checkpoints on retired-instruction count, not guest cycles - #270
Merged
Merged
Conversation
The cycle-keyed design hashed+parked at the first cosim_instr boundary AFTER the stride cycle was crossed; the two backends can reach that crossing at different retirement positions, so the oracle compared different architectural states (observed as a +5-cycle park skew and phantom CPU-register divergences mid-CPS). Checkpoints are now taken inside cosim_instr, keyed on the retirement count itself (a branch and its delay slot retire as one event in both backends). Checkpoint k = state after k*stride retirements in BOTH instances by construction. The guest-cycle clock stays inside the state hash, so real cycle-accounting drift is still detected -- now pinned to an exact instruction window instead of corrupting the alignment. cosim.py: stride/--max/--start-cycle now in retirement units; the cycle skew warning is now reported as a real timing divergence. launch() gives instance B its own exe (the mods root is exe-dir-relative, so a shared exe races on mods/state.toml publish regardless of cwd separation) and refuses a stale COSIM_CWD_B exe. Gates on CMR2 (SLUS-01222): compiled/compiled and interp/interp both clean over 100M retirements with identical cross-pair chains; injected 1-bit RAM fault detected at the next checkpoint.
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.
Problem
The first-divergence oracle keyed checkpoints on guest cycles, but the
hash/park happened at the first
cosim_instrboundary AFTER the stridecycle was crossed. The two backends can reach that crossing at different
retirement positions (charges land in different lumps mid-instruction),
so the oracle compared different architectural states. Observed on CMR2
as a +5-cycle park skew and phantom CPU-register divergences; the WARN
in cosim.py fired on every run past ~6.7e9 cycles, making verdicts
untrustworthy on mixed-mode titles.
Fix
Checkpoints are now taken inside
cosim_instr, keyed on the retirementcount itself. Both backends call
cosim_instrexactly once perretirement event (a branch and its delay slot retire as ONE event in
both the dirty-RAM interp and the emitted code), so checkpoint k is
"the state after k*stride retirements" on both sides by construction.
The guest-cycle clock stays inside the state hash, so real
cycle-accounting drift still flags — now pinned to an exact instruction
window instead of corrupting the alignment.
cosim.py: stride/--max/--start-cycle are now retirement units; the
cycle-skew warning reports a real timing divergence;
launch()givesinstance B its own exe copy (the mods root is exe-dir-relative —
exe_dir_from_argv(argv[0]) / "mods"— so a shared exe races onmods/state.toml publish regardless of cwd separation) and refuses a
stale
COSIM_CWD_Bexe.Validation (CMR2, SLUS-01222)
retirements — with IDENTICAL chain values across the two pairs
(compiled==interp through ~465 frames).
3,203,596,289 that the cycle-keyed design had been mislocating — the
stale-static overlay bug fixed in the companion PR.