diff --git a/pyproject.toml b/pyproject.toml index d9c9b93..9ba829f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,9 @@ version = "0.1.0" description = "Scripts that helps debugging SPEC CPU benchmark suite." readme = "README.md" requires-python = ">=3.12" -dependencies = [] +dependencies = [ + "click>=8.1.8", +] [tool.setuptools] packages = { find = { where = ["src"] } } diff --git a/tools/x264_perf_O3.py b/tools/x264_perf_O3.py index d4e7fe4..d637c7d 100644 --- a/tools/x264_perf_O3.py +++ b/tools/x264_perf_O3.py @@ -1,27 +1,64 @@ from pathlib import Path from subprocess import run -from speccpu import get_benchspec_dir, x264 +import click + +from speccpu import create_spec_env, find_build, get_benchspec_dir, x264 from speccpu.flaglib.perf import record as recordflags -def main(): - x264_run_id = "c56635a4-9f49-4d2b-be79-38d9e08097c5" - x264_outputroot = Path("/home/lyc/work-ts/local/specOutput") / x264_run_id - - - x264_dir = get_benchspec_dir(x264_outputroot) / "625.x264_s" +@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_run / "x264_s_base.mytest-m64"), + str(x264_exe), *x264.specinvoke_args["ref"], ], output=str(Path.cwd() / f"x264-{x264_run_id}perf"), @@ -31,5 +68,6 @@ def main(): cwd=x264_run, ) + if __name__ == "__main__": main() diff --git a/uv.lock b/uv.lock index 0596e5d..f07ce00 100644 --- a/uv.lock +++ b/uv.lock @@ -2,6 +2,18 @@ version = 1 revision = 1 requires-python = ">=3.12" +[[package]] +name = "click" +version = "8.1.8" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 }, +] + [[package]] name = "colorama" version = "0.4.6" @@ -57,6 +69,9 @@ wheels = [ name = "speccpulib" version = "0.1.0" source = { virtual = "." } +dependencies = [ + { name = "click" }, +] [package.dev-dependencies] dev = [ @@ -64,6 +79,7 @@ dev = [ ] [package.metadata] +requires-dist = [{ name = "click", specifier = ">=8.1.8" }] [package.metadata.requires-dev] dev = [{ name = "pytest", specifier = ">=8.3.5" }]