import os from pathlib import Path from subprocess import Popen from speccpu import SPEC, check_bench_dir, find_build, get_benchspec_dir, x264 def x264_disable_mc_mul( spec_dir: Path, spec_config: str, spec_outputroot: Path, ): spec = SPEC(spec_dir) x264_dir = get_benchspec_dir(spec_outputroot) / "625.x264_s" check_bench_dir(x264_dir) x264_build = find_build(x264_dir / "build") assert x264_build.exists() assert "x264_src" in os.listdir(x264_build) mc_path = x264.get_mc_path(x264_build) assert mc_path.exists() mc_src = x264.MCBuilder().with_disabled_iscale_mul().build() # Write mc_src to mc_path, recompile it, and replace resulting exe with open(mc_path, "w") as f: f.write(mc_src) # Recompile recompiled_x264_path = x264.recompile_mc(mc_path, x264_build, spec.env()) assert recompiled_x264_path.exists() assert recompiled_x264_path.is_file() # Execute that new binary x264.update_exe(recompiled_x264_path, x264_dir / "exe") with Popen( spec.mkcmd_runcpu( spec_config, ["x264"], setprocgroup=True, workload="ref", output_root=spec_outputroot, ) ) as process: process.wait() def main(): spec_path = Path("/home/lyc/spec2017-1.1.8-new") x264_run_id = "f7e8503c-b8ca-47c9-879f-d1e73bbedc99" x264_config = spec_path / "config" / f"{x264_run_id}.cfg" x264_outputroot = Path("/home/lyc/work-ts/local/specOutput") / x264_run_id x264_disable_mc_mul( spec_path, str(x264_config), x264_outputroot, ) if __name__ == "__main__": main()