from pathlib import Path from subprocess import run import click from speccpu import create_spec_env, find_build, get_benchspec_dir, x264 from speccpu.flaglib.perf import record as recordflags @click.command() @click.option( "--get-ref-vectorize/--no-get-ref-vectorize", default=True, help="Enable or disable mc.c `get_ref` vectorization", ) @click.option( "--spec", type=click.Path(), help="Path to SPEC CPU directory", required=True, ) @click.option( "--x264-run-id", type=str, required=True, ) @click.option( "--outputroot", type=click.Path(), required=True, ) def main( get_ref_vectorize: bool, spec, x264_run_id: str, outputroot, ): outputroot = Path(outputroot) spec = Path(spec) x264_dir = get_benchspec_dir(outputroot / x264_run_id) / "625.x264_s" x264_run = x264_dir / "run" / "run_base_refspeed_mytest-m64.0000" x264_exe = x264_run / "x264_s_base.mytest-m64" mc_builder = x264.MCBuilder() if not get_ref_vectorize: mc_builder.with_disabled_vectorize_get_ref() x264_exe = x264.recompile_mc_src( mc_builder.build(), find_build(x264_dir / "build"), create_spec_env(spec), ) run( [ "perf", "record", *recordflags( [ str(x264_exe), *x264.specinvoke_args["ref"], ], output=str(Path.cwd() / f"x264-{x264_run_id}.perf"), ), ], check=True, cwd=x264_run, ) if __name__ == "__main__": main()