From 9c4c0cb8da3f56a447c4c2fe0d2b01bd57207d84 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:28:01 +0000 Subject: [PATCH 1/7] [tests] Add missing test dependency. --- tests/llvm/BUILD | 1 + tests/llvm/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/llvm/BUILD b/tests/llvm/BUILD index 32280ec76..173434908 100644 --- a/tests/llvm/BUILD +++ b/tests/llvm/BUILD @@ -177,6 +177,7 @@ py_test( "//compiler_gym/envs", "//compiler_gym/service/proto", "//tests:test_main", + "//tests/pytest_plugins:common", "//tests/pytest_plugins:llvm", ], ) diff --git a/tests/llvm/CMakeLists.txt b/tests/llvm/CMakeLists.txt index bfe26234d..ec28d6d57 100644 --- a/tests/llvm/CMakeLists.txt +++ b/tests/llvm/CMakeLists.txt @@ -173,6 +173,7 @@ cg_py_test( DEPS compiler_gym::envs::envs compiler_gym::service::proto::proto + tests::pytest_plugins::common tests::pytest_plugins::llvm tests::test_main ) From 7144057513bbec46522f6fdb10828a207c22eac7 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:28:45 +0000 Subject: [PATCH 2/7] [examples] Fix benchmark URI. --- examples/example_compiler_gym_service/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/example_compiler_gym_service/__init__.py b/examples/example_compiler_gym_service/__init__.py index 4d8965334..8cb7ab614 100644 --- a/examples/example_compiler_gym_service/__init__.py +++ b/examples/example_compiler_gym_service/__init__.py @@ -74,7 +74,7 @@ def benchmark_uris(self) -> Iterable[str]: def benchmark_from_parsed_uri(self, uri: BenchmarkUri) -> Benchmark: if uri.path in self._benchmarks: - return self._benchmarks[uri] + return self._benchmarks[uri.path] else: raise LookupError("Unknown program name") From bce2a9df134157f96fab8699a51a0bd34abf3cb7 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:29:41 +0000 Subject: [PATCH 3/7] Update checksum of csmith tarball. --- WORKSPACE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 941d88963..6e299b51f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -277,7 +277,7 @@ http_archive( http_archive( name = "csmith", build_file_content = all_content, - sha256 = "ba871c1e5a05a71ecd1af514fedba30561b16ee80b8dd5ba8f884eaded47009f", + sha256 = "86d08c19a1f123054ed9350b7962edaad7d46612de0e07c10b73e578911156fd", strip_prefix = "csmith-csmith-2.3.0", urls = ["https://github.com/csmith-project/csmith/archive/refs/tags/csmith-2.3.0.tar.gz"], ) From 1af5eaa464ca40511a7df91aa0c4d7002e315108 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:29:51 +0000 Subject: [PATCH 4/7] Add alternate URL for csmith tarball. --- WORKSPACE | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 6e299b51f..5993dc07d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -279,7 +279,10 @@ http_archive( build_file_content = all_content, sha256 = "86d08c19a1f123054ed9350b7962edaad7d46612de0e07c10b73e578911156fd", strip_prefix = "csmith-csmith-2.3.0", - urls = ["https://github.com/csmith-project/csmith/archive/refs/tags/csmith-2.3.0.tar.gz"], + urls = [ + "https://github.com/ChrisCummins/csmith/archive/refs/tags/csmith-2.3.0.tar.gz", + "https://github.com/csmith-project/csmith/archive/refs/tags/csmith-2.3.0.tar.gz", + ], ) # === DeepDataFlow === From 2fe4a848a03355e8b581c714afd1f06715d74e31 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:30:51 +0000 Subject: [PATCH 5/7] [tests] Add missing test dependency. --- tests/llvm/BUILD | 1 + tests/llvm/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/llvm/BUILD b/tests/llvm/BUILD index 173434908..c94d4fa98 100644 --- a/tests/llvm/BUILD +++ b/tests/llvm/BUILD @@ -233,6 +233,7 @@ py_test( deps = [ "//compiler_gym/envs", "//tests:test_main", + "//tests/pytest_plugins:common", "//tests/pytest_plugins:llvm", ], ) diff --git a/tests/llvm/CMakeLists.txt b/tests/llvm/CMakeLists.txt index ec28d6d57..c541bd091 100644 --- a/tests/llvm/CMakeLists.txt +++ b/tests/llvm/CMakeLists.txt @@ -231,6 +231,7 @@ cg_py_test( "observation_spaces_test.py" DEPS compiler_gym::envs::envs + tests::pytest_plugins::common tests::pytest_plugins::llvm tests::test_main ) From 13fa5a3b5be926943af43ced456a359a609ef897 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 20:31:43 +0000 Subject: [PATCH 6/7] [tests] Set observation and reward space for type test. --- tests/llvm/gym_interface_compatability.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/llvm/gym_interface_compatability.py b/tests/llvm/gym_interface_compatability.py index 7b385a01b..ac22b164c 100644 --- a/tests/llvm/gym_interface_compatability.py +++ b/tests/llvm/gym_interface_compatability.py @@ -12,6 +12,10 @@ def test_type_classes(env: LlvmEnv): + env.observation_space = "Autophase" + env.reward_space = "IrInstructionCount" + env.reset() + assert isinstance(env, gym.Env) assert isinstance(env, LlvmEnv) assert isinstance(env.unwrapped, LlvmEnv) From 207dbb9b63fabbb4c179300e78ff1f4e27e55d7f Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Wed, 2 Mar 2022 22:05:19 +0000 Subject: [PATCH 7/7] [examples] Update loop optimizations service dataset API. --- examples/loop_optimizations_service/__init__.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/loop_optimizations_service/__init__.py b/examples/loop_optimizations_service/__init__.py index 45ab1055a..b6866f07b 100644 --- a/examples/loop_optimizations_service/__init__.py +++ b/examples/loop_optimizations_service/__init__.py @@ -8,6 +8,7 @@ from typing import Iterable from compiler_gym.datasets import Benchmark, Dataset +from compiler_gym.datasets.uri import BenchmarkUri from compiler_gym.envs.llvm.llvm_benchmark import get_system_library_flags from compiler_gym.spaces import Reward from compiler_gym.third_party import llvm @@ -86,15 +87,15 @@ def __init__(self, *args, **kwargs): ) self._benchmarks = { - "benchmark://loops-opt-v0/add": Benchmark.from_file_contents( + "/add": Benchmark.from_file_contents( "benchmark://loops-opt-v0/add", self.preprocess(BENCHMARKS_PATH / "add.c"), ), - "benchmark://loops-opt-v0/offsets1": Benchmark.from_file_contents( + "/offsets1": Benchmark.from_file_contents( "benchmark://loops-opt-v0/offsets1", self.preprocess(BENCHMARKS_PATH / "offsets1.c"), ), - "benchmark://loops-opt-v0/conv2d": Benchmark.from_file_contents( + "/conv2d": Benchmark.from_file_contents( "benchmark://loops-opt-v0/conv2d", self.preprocess(BENCHMARKS_PATH / "conv2d.c"), ), @@ -122,11 +123,11 @@ def preprocess(src: Path) -> bytes: ) def benchmark_uris(self) -> Iterable[str]: - yield from self._benchmarks.keys() + yield from (f"benchmark://loops-opt-v0{k}" for k in self._benchmarks.keys()) - def benchmark(self, uri: str) -> Benchmark: - if uri in self._benchmarks: - return self._benchmarks[uri] + def benchmark_from_parsed_uri(self, uri: BenchmarkUri) -> Benchmark: + if uri.path in self._benchmarks: + return self._benchmarks[uri.path] else: raise LookupError("Unknown program name")