Files
GR-raytracing/benchmarks/hip_psf_replay_2026-09-07/make_hotspot_fixture.py
T
wyj 7ddc58515a Doc: Record full-day parallel prebinning results and next steps
Document the producer-private adaptive path, the dummy support workload
diagnostics, the negative result of the old serial binning and the
2026-09-13 full-day comparison (splat 282.944 s vs atomic 481.417 s).
Add the corresponding raw logs, hotspot fixtures and runner evidence,
and lay out the staged plan toward a sub-240 s full-day render without
changing the default atomic path.
2026-09-14 19:16:00 -04:00

67 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Relocate captured event integer pixels to one 16px-aligned hotspot.
This is a counterfactual PSF workload, not a physical renderer output. The
fractional phase is retained up to double rounding; color, flux, and support
radius are preserved verbatim.
"""
from pathlib import Path
import hashlib
import math
import sys
def main() -> int:
if len(sys.argv) not in (3, 4) or (len(sys.argv) == 4 and sys.argv[3] != "jitter8"):
print("usage: make_hotspot_fixture.py SOURCE.events OUTPUT.events [jitter8]", file=sys.stderr)
return 2
source, output = map(Path, sys.argv[1:3])
jitter = len(sys.argv) == 4
if output.exists():
print(f"refusing to overwrite {output}", file=sys.stderr)
return 2
with source.open() as src:
header = src.readline()
fields = header.split()
if len(fields) != 7 or fields[0] != "PSFEVENTS1":
raise ValueError("unexpected event header")
width, height, count = map(int, fields[1:4])
center_x, center_y = 1928, 1080 # both have remainder 8 modulo 16
if not (47 <= center_x < width - 47 and
47 <= center_y < height - 47):
raise ValueError("fixture requires a 3840x2160-like frame")
with output.open("x") as dst:
dst.write(header)
state = 12345
for index in range(count):
row = src.readline().split()
if len(row) != 7:
raise ValueError(f"bad event {index}")
x, y, *rest = map(float, row)
support = rest[-1]
if not all(map(math.isfinite, (x, y, *rest))):
raise ValueError(f"nonfinite event {index}")
if not (48 <= x < width - 48 and 48 <= y < height - 48):
raise ValueError(f"source event {index} near image edge")
if not (0 <= support <= 47):
raise ValueError(f"unexpected support {index}")
if jitter:
state = (1664525 * state + 1013904223) & 0xffffffff
dx = ((state >> 16) & 7) - 4
state = (1664525 * state + 1013904223) & 0xffffffff
dy = ((state >> 16) & 7) - 4
else:
dx = dy = 0
dst.write(" ".join((format(center_x + dx + x % 1, ".17g"),
format(center_y + dy + y % 1, ".17g"),
*row[2:])) + "\n")
if src.readline():
raise ValueError("trailing event rows")
digest = hashlib.sha256(output.read_bytes()).hexdigest()
print(f"counterfactual hotspot: events={count} jitter8={jitter} output={output} sha256={digest}")
return 0
if __name__ == "__main__":
raise SystemExit(main())