#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Rung 6's cases: the reference's rung-4 multiply cases with zaydlang's model's answers. The reference judges its multiplies by zaydlang's hardware-fuzzed Booth-array model (``tests/multiply_judge.py``: MUL, MLA, UMULL, UMLAL, SMULL, SMLAL with S set and Thumb MUL, 10^6 cases each, in 4 chunks with seeds ``1000 * form + chunk``, edges first). This script draws exactly those cases with the reference's own generator and asks the model (the shared library ``$MUL_MODEL``, built by the reference's scripts/build_referees.py) for each answer, writing ``DIR/FORM-CHUNK.bin``: per case `` str: form, index, part, count, out = job mj.LIBRARY = Path(os.environ["MUL_MODEL"]) judge = mj.Judge() rng = random.Random(1000 * index + part) op, extra, kind = mj.FORMS[form] accumulate = form in ("MLA", "UMLAL", "SMLAL") pack = struct.Struct(" int: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("out", type=Path) parser.add_argument("--count", type=int, default=1_000_000) parser.add_argument("--jobs", type=int, default=4) args = parser.parse_args() args.out.mkdir(parents=True, exist_ok=True) work = [ (form, index, part, args.count // CHUNKS, str(args.out)) for index, form in enumerate(mj.FORMS) for part in range(CHUNKS) if not (args.out / f"{form.replace(' ', '_')}-{part}.bin").exists() ] with ProcessPoolExecutor(args.jobs) as pool: for line in pool.map(chunk, work): print(line, flush=True) return 0 if __name__ == "__main__": sys.exit(main())