mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 17:18:38 +00:00
Twelve test files failed on main at2d53a8055(CI's check and semantic-tests steps, run locally): most are a test and the code it checks changed by different pull requests in the same merge round. Each fix below is either taken from a closed pull request that already had it, or restores what an earlier merged change intended. From closed pull requests: - test_make_game_resume: FakeProc gets poll(), which translate() now calls (#7018) - test_make_game_empty_translation: the Exited stub gets poll() and the failed-shard path is checked (#7214) - test_shader_checks: stub table_fetch_test in the Wave64Checks harness and count it (#7433) - test_runtime_paths: runtime.yml's path filter lists tools/replace_retry.py, which rdna2spirv.py imports (#7029) - test_psin_names: patch the same_report_path helpers that report_paths now calls (#8719) - test_report_source_collision: the fixture is a real Bink 2 header; bink_index refuses other files (#7408) - test_missing_input_exit_codes: tile_probe checks its inputs before it asks for numpy (#4771) Restored: - merge_check: a failed `git show` is an error again (5b88d58);21016cfbrought back the lenient read that treated it as a new file, while new files are already left out when the diff is read - rpf_probe: a symlinked --out updates its target again (44d3595); 55d21cc's staged write replaced the link Updated to the code: - test_shader_stage_resume: TRANSLATION_SOURCES lists fssm_unpack.py and shader_stage_manifest.py, which the translator imports; existing work folders translate once more after this - test_tool_stdout_encoding: the 15 programs merged without the stdout guard get the same block as the others - test_rdna2spirv_decode: drop the test of decode_any_format, which SHADER-849 replaced with the table decode that tests/semantic/test_format_decode_table.py checks Co-authored-by: jewmaster1337 <102986566+jewmaster1337@users.noreply.github.com> Co-authored-by: TanmaySatyam <248538550+TanmaySatyam@users.noreply.github.com> Co-authored-by: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com> Co-authored-by: slint6614-dev <359954236+slint6614-dev@users.noreply.github.com> Co-authored-by: BlackNife <108077267+Poussistar@users.noreply.github.com> Co-authored-by: fiestorra <65175643+fiestorra@users.noreply.github.com> Co-authored-by: fearkov <289226582+fearkov@users.noreply.github.com> Co-authored-by: DoubleD17 <48109637+DoubleD17@users.noreply.github.com>
110 lines
4.4 KiB
Python
110 lines
4.4 KiB
Python
"""Write an offline comparison report for the prefixes of one synthetic wave32 case."""
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import random
|
|
import sys
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(HERE))
|
|
|
|
import wave_diff # noqa: E402
|
|
|
|
|
|
WAVE = 32
|
|
COLUMNS = [f"v{r}" for r in wave_diff.VREGS] + ["s6 mask", "s8 mask", "EXEC", "VCC"] + [
|
|
f"s{r}" for r in wave_diff.SREGS
|
|
]
|
|
|
|
|
|
def select_case(seed, case_index, max_ops):
|
|
"""Advance the same RNG stream as `wave_diff --wave 32`."""
|
|
rng = random.Random(seed)
|
|
for _ in range(case_index + 1):
|
|
case = wave_diff.generate_case(rng, rng.randrange(1, max_ops + 1), WAVE)
|
|
return case
|
|
|
|
|
|
def words_by_lane(rows):
|
|
return [[None if value is None else value & wave_diff.M32 for value in row] for row in rows]
|
|
|
|
|
|
def inspect_checkpoint(name, lines, instruction):
|
|
reference = translated = reason = mismatch = None
|
|
phase = "reference"
|
|
try:
|
|
reference = words_by_lane(wave_diff.run_model(lines, WAVE))
|
|
phase = "translator"
|
|
spirv = wave_diff.translate(name, lines, WAVE)
|
|
phase = "SPIR-V interpreter"
|
|
translated = words_by_lane(wave_diff.run_spirv(spirv, WAVE))
|
|
except (wave_diff.cpu_ref.Unsupported, wave_diff.rdna2spirv.Unsupported,
|
|
wave_diff.si.UnsupportedConstruct) as exc:
|
|
reason = f"{phase}: {exc}"
|
|
if translated is not None:
|
|
first = next(wave_diff.differences(reference, translated), None)
|
|
if first is not None:
|
|
lane, column, expected, actual = first
|
|
mismatch = {"lane": lane, "column": column, "expected": expected, "actual": actual}
|
|
return {"instruction": instruction, "reference": reference, "translated": translated,
|
|
"unavailable": reason, "mismatch": mismatch}
|
|
|
|
|
|
def inspect_case(seed, case_index, max_ops):
|
|
lines, body_start, body_end = select_case(seed, case_index, max_ops)
|
|
name = f"cs_wdiff_{case_index:04d}"
|
|
steps = []
|
|
for stop in range(body_start, body_end + 1):
|
|
instruction = None if stop == body_start else lines[stop - 1]
|
|
prefix = lines if stop == body_end else wave_diff.observed(lines[:stop], WAVE)
|
|
steps.append(inspect_checkpoint(name, prefix, instruction))
|
|
first = next((i for i, step in enumerate(steps) if step["mismatch"] is not None), None)
|
|
return {"seed": str(seed), "case": case_index, "wave": WAVE, "max_ops": max_ops,
|
|
"columns": COLUMNS, "steps": steps, "first_mismatch": first}
|
|
|
|
|
|
def render_report(report):
|
|
template = HERE.joinpath("wave_trace.html").read_text(encoding="utf-8")
|
|
payload = json.dumps(report, separators=(",", ":")).replace("<", "\\u003c")
|
|
return template.replace("<!-- WAVE_TRACE_DATA -->", payload, 1)
|
|
|
|
|
|
def main(argv=None):
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--seed", type=int, default=1)
|
|
parser.add_argument("--case", type=int, default=0, help="zero-based index in the seeded wave32 run")
|
|
parser.add_argument("--max-ops", type=int, default=12, help="same generator bound as wave_diff")
|
|
parser.add_argument("--out", type=Path, required=True, help="new HTML report path")
|
|
args = parser.parse_args(argv)
|
|
if args.case < 0:
|
|
parser.error("--case must be nonnegative")
|
|
if args.max_ops < 1:
|
|
parser.error("--max-ops must be at least 1")
|
|
try:
|
|
report = inspect_case(args.seed, args.case, args.max_ops)
|
|
html = render_report(report)
|
|
with args.out.open("x", encoding="utf-8", newline="\n") as stream:
|
|
stream.write(html)
|
|
except (OSError, wave_diff.cf_ref.ProgramError) as exc:
|
|
print(f"wave_trace: {exc}", file=sys.stderr)
|
|
return 2
|
|
|
|
skipped = sum(step["unavailable"] is not None for step in report["steps"])
|
|
first = report["first_mismatch"]
|
|
print(f"{args.out} ({len(report['steps'])} checkpoints, {skipped} unavailable)")
|
|
if first is not None:
|
|
mismatch = report["steps"][first]["mismatch"]
|
|
column = report["columns"][mismatch["column"]]
|
|
print(f"First observed mismatch at checkpoint {first}, lane {mismatch['lane']}, {column}")
|
|
return 1
|
|
return 2 if skipped else 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
|
|
sys.stdout.reconfigure(errors="replace")
|
|
except (AttributeError, ValueError, OSError):
|
|
pass
|
|
sys.exit(main())
|