#!/usr/bin/env python3 """Run current-source W12 L77 route/phase and exact-call censuses.""" from __future__ import annotations import json import subprocess import time from pathlib import Path ROOT = Path(__file__).resolve().parents[4] OUT = ROOT / "Saved/Linux/l103/census" DATA = ROOT / "Standalone/data/owner_world.json" BINARY = ROOT / "Saved/Linux/l103/profile-bin/VoxelForgeCoreHeadless-l103-profile-clang" CAMERAS = { "SW": (8.0, 16.0, -372.2626953125), "FI": (25.8369140625, 3.19921875, -737.0), "TN": (19.166015625, -14.2001953125, -753.3740234375), "VS": (-20.0625, -5.068359375, -900.353515625), } def run(stratum: str, replicate: int) -> dict: OUT.mkdir(parents=True, exist_ok=True) log = OUT / f"{stratum.lower()}-r{replicate}.log" camera = ",".join(f"{value:.12f}" for value in CAMERAS[stratum]) + ",0,0" command = [ "taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--", "timeout", "1740s", str(BINARY), str(DATA), "--world-assembler-prototype", "--stream-benchmark", "--stream-pipeline", "--workers=12", "--clip-radius=3", "--max-clip-level=8", "--max-level=8", f"--camera={camera}", "--profile-lod-work", "--profile-passage-composer", "--linux77-profile", ] started = time.monotonic() with log.open("w", encoding="utf-8") as stream: result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, check=False, timeout=1740) row = {"stratum": stratum, "replicate": replicate, "workers": 12, "exit_code": result.returncode, "wall_s": round(time.monotonic() - started, 3), "log": str(log.relative_to(ROOT))} print("[L103CensusRun] " + json.dumps(row, sort_keys=True), flush=True) if result.returncode: raise RuntimeError(f"census run failed: {log}, exit={result.returncode}") return row def main() -> int: if not BINARY.is_file() or not DATA.is_file(): raise SystemExit(f"missing input: {BINARY} or {DATA}") runs = [] # Three balanced rounds cover every stratum; reverse order in the middle. orders = (("SW", "FI", "TN", "VS"), ("VS", "TN", "FI", "SW"), ("FI", "SW", "VS", "TN")) for replicate, order in enumerate(orders, 1): for stratum in order: runs.append(run(stratum, replicate)) (OUT / "runs-partial.json").write_text( json.dumps(runs, indent=2) + "\n", encoding="utf-8") (OUT / "runs.json").write_text(json.dumps(runs, indent=2) + "\n", encoding="utf-8") return 0 if __name__ == "__main__": raise SystemExit(main())