openaccel-lab
aien-dev/openaccel-lab
Brought by drakestapleton
openaccel-lab / bin / oal-matrix
| 1 | #!/usr/bin/env python3 |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # oal-matrix [--backends B,..] [--workloads W,..] [--controls] [--seeds 1,2,3] |
| 4 | # Run every (workload, case, seed, backend) and print one oal-result/1 JSON line each (docs/RESULTS.md). |
| 5 | # Exit 0 when every line was written, whatever the verdicts; judging is oal-gate's job. |
| 6 | # INTERIM host glue (Python). Successor: oal-matrix in seeded Omega. |
| 7 | import os |
| 8 | import sys |
| 9 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) |
| 10 | import argparse |
| 11 | import json |
| 12 | from oal import manifest, matrix, run |
| 13 | |
| 14 | ap = argparse.ArgumentParser(prog="oal-matrix") |
| 15 | ap.add_argument("--backends", default=",".join(run.BACKENDS)) |
| 16 | ap.add_argument("--workloads", default="") |
| 17 | ap.add_argument("--controls", action="store_true", help="also run controls/") |
| 18 | ap.add_argument("--only-controls", action="store_true") |
| 19 | ap.add_argument("--seeds", default="1,2,3") |
| 20 | ap.add_argument("--timeout", type=int, default=600) |
| 21 | a = ap.parse_args() |
| 22 | names = [w for w in a.workloads.split(",") if w] or manifest.all_names(include_controls=a.controls or a.only_controls) |
| 23 | if a.only_controls: |
| 24 | names = [n for n in names if manifest.load(n)["_control"]] |
| 25 | seeds = [int(s) for s in a.seeds.split(",") if s] |
| 26 | cache = {} |
| 27 | for name in names: |
| 28 | m = manifest.load(name) |
| 29 | for over in matrix.cases_of(m): |
| 30 | for seed in seeds: |
| 31 | for b in a.backends.split(","): |
| 32 | rec = matrix.run_one(b, m, over, seed, a.timeout, cache) |
| 33 | sys.stdout.write(json.dumps(rec, sort_keys=True) + "\n") |
| 34 | sys.stdout.flush() |
| 35 | sys.stderr.write("%-16s %-7s seed %-3d %s %s\n" % (name, b, seed, json.dumps(over), rec["status"])) |