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 / gen.py

46 lines · 2978 bytes Raw Blame History
1#!/usr/bin/env python3
2# gen.py NAME: write one synthetic timing trace to stdout. A measuring instrument for the gate, not
3# part of the tuner. It must produce, byte for byte, the trace tests/oracle.wl made in Wolfram: the
4# gate checks each trace's SHA-256 against the one Wolfram printed (tests/expected-wolfram.txt).
5import sys
6A, C, M = 6364136223846793005, 1442695040888963407, 1 << 64
7# name: seed, K, L, baseA, baseB, switch, spread, tailp, tailadd, wrongmod (same table as oracle.wl)
8S = {
9 "fast5": (1, 2, 6000, [100000, 95000], [100000, 95000], 0, [6000, 6000], [0, 0], [0, 0], [0, 0]),
10 "slow10": (2, 2, 40000, [100000, 110000], [100000, 110000], 0, [6000, 6000], [0, 0], [0, 0], [0, 0]),
11 "wrongfast": (3, 3, 12000, [100000, 50000, 93000], [100000, 50000, 93000], 0, [6000] * 3, [0] * 3, [0] * 3, [0, 2, 0]),
12 "equal": (4, 2, 30000, [100000, 100000], [100000, 100000], 0, [6000, 6000], [0, 0], [0, 0], [0, 0]),
13 "tailC": (5, 2, 20000, [100000, 95000], [100000, 95000], 0, [2000, 2000], [0, 8], [0, 900000], [0, 0]),
14 "drift": (6, 2, 34000, [100000, 108000], [100000, 92000], 20000, [6000, 6000], [0, 0], [0, 0], [0, 0]),
15 "tailI": (7, 2, 20000, [100000, 105000], [100000, 105000], 0, [2000, 2000], [8, 0], [900000, 0], [0, 0]),
16 "twoA": (8, 2, 6000, [100000, 95000], [100000, 95000], 0, [6000, 6000], [0, 0], [0, 0], [0, 0]),
17 "twoB": (9, 3, 6000, [40000, 44000, 30000], [40000, 44000, 30000], 0, [3000] * 3, [0] * 3, [0] * 3, [0, 0, 3]),
18 "ties": (10, 2, 12000, [1000, 1000], [1000, 1000], 0, [3, 3], [0, 0], [0, 0], [0, 0]),
19 "cap": (11, 2, 210000, [100000, 110000], [100000, 110000], 0, [6000, 6000], [0, 0], [0, 0], [0, 0]),
20 "lateGain": (12, 2, 579, [100, 100], [100, 90], 323, [1, 1], [0, 0], [0, 0], [0, 0]),
21 "earlyGain": (13, 2, 579, [100, 90], [100, 100], 323, [1, 1], [0, 0], [0, 0], [0, 0]),
22 "equalSum": (14, 2, 131, [100, 69], [100, 101], 69, [1, 1], [0, 0], [0, 0], [0, 0]),
23 "lateWrong": (25, 2, 3000, [100000, 95000], [100000, 95000], 0, [6000, 6000], [0, 0], [0, 0], [0, 500]),
24 "meanWin": (17, 2, 3000, [100, 80], [100, 80], 0, [1, 1], [0, 2], [0, 21], [0, 0]),
25}
26def rows(name):
27 seed, K, L, bA, bB, sw, spread, tailp, tailadd, wrong = S[name]
28 x = seed
29 for i in range(1, L + 1):
30 ns = []
31 for j in range(K):
32 x = (A * x + C) % M; r = x >> 33
33 x = (A * x + C) % M; r2 = x >> 33
34 t = (bB[j] if sw > 0 and i > sw else bA[j]) + r % spread[j]
35 if tailp[j] > 0 and r2 % tailp[j] == 0: t += tailadd[j]
36 ns.append(t)
37 ok = sum(0 if wrong[j] > 0 and i % wrong[j] == 0 else 1 << j for j in range(K))
38 yield ns, ok
39def line(c, r): return "t %d %s %d\n" % (c, " ".join(map(str, r[0])), r[1])
40name = sys.argv[1]; w = sys.stdout.write
41if name == "two":
42 w("c 0 %d\nc 1 %d\n" % (S["twoA"][1], S["twoB"][1]))
43 for a, b in zip(rows("twoA"), rows("twoB")): w(line(0, a)); w(line(1, b))
44else:
45 w("c 0 %d\n" % S[name][1])
46 for r in rows(name): w(line(0, r))