interplane.Get Omega
Read in your language

omega-feel

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

omega-feel / tests / round40 / compose.py

32 lines · 1568 bytes Raw Blame History
1"""Compose a test executable from the exact CPU engine and decision core used in this study."""
2import hashlib
3import re
4import sys
5from pathlib import Path
6
7here = Path(__file__).resolve().parent
8engine = Path(sys.argv[1]).read_bytes()
9if hashlib.sha256(engine).hexdigest() != "c7ea882b0545bfec59beb6ff2d41c85364e32ad136da6f212dc9b9a9975353f2":
10 sys.exit("The engine source must match the pinned CPU build in README.md")
11engine = engine.decode()
12core = (here.parent.parent / "feel.om").read_text()
13core, delimiter, _ = core.partition("fn step ")
14if not delimiter:
15 sys.exit("Missing trace-driver boundary")
16
17core = re.sub(r"\boflush\b", "fflush", core)
18core = re.sub(r"\bout\b", "outcome", core)
19adapter = (here / "adapter.om").read_text()
20if len(sys.argv) == 3 and sys.argv[2] == "--wrong-arm":
21 # Change one output bit only in the candidate. All timing and comparison code is identical.
22 term = "put oa add po c kdot1 z add z d mul c d"
23 if adapter.count(term) != 1:
24 sys.exit("Could not locate candidate output")
25 adapter = adapter.replace(term, term + "\nif eq c 0\nput oa po bitcast f64 xor bitcast ulong get oa po 1\nend")
26elif len(sys.argv) != 2:
27 sys.exit("usage: compose.py ENGINE_SOURCE [--wrong-arm]")
28anchor = "fn olast to void\n"
29original = "klogit z get og 27 get og 0 d"
30if engine.count(anchor) != 1 or engine.count(original) != 1:
31 sys.exit("Could not locate the unique CPU logits call")
32sys.stdout.write(engine.replace(anchor, core + "\n" + adapter + "\n" + anchor).replace(original, "fkernel z get og 27 get og 0 d"))