Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥🚒🧯 Put out the fire #593

Merged
merged 7 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,12 @@ http_archive(
http_archive(
name = "csmith",
build_file_content = all_content,
sha256 = "ba871c1e5a05a71ecd1af514fedba30561b16ee80b8dd5ba8f884eaded47009f",
sha256 = "86d08c19a1f123054ed9350b7962edaad7d46612de0e07c10b73e578911156fd",
strip_prefix = "csmith-csmith-2.3.0",
urls = ["https:/csmith-project/csmith/archive/refs/tags/csmith-2.3.0.tar.gz"],
urls = [
"https:/ChrisCummins/csmith/archive/refs/tags/csmith-2.3.0.tar.gz",
"https:/csmith-project/csmith/archive/refs/tags/csmith-2.3.0.tar.gz",
],
)

# === DeepDataFlow ===
Expand Down
2 changes: 1 addition & 1 deletion examples/example_compiler_gym_service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
15 changes: 8 additions & 7 deletions examples/loop_optimizations_service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
),
Expand Down Expand Up @@ -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")

Expand Down
2 changes: 2 additions & 0 deletions tests/llvm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ py_test(
"//compiler_gym/envs",
"//compiler_gym/service/proto",
"//tests:test_main",
"//tests/pytest_plugins:common",
"//tests/pytest_plugins:llvm",
],
)
Expand Down Expand Up @@ -232,6 +233,7 @@ py_test(
deps = [
"//compiler_gym/envs",
"//tests:test_main",
"//tests/pytest_plugins:common",
"//tests/pytest_plugins:llvm",
],
)
Expand Down
2 changes: 2 additions & 0 deletions tests/llvm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -230,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
)
Expand Down
4 changes: 4 additions & 0 deletions tests/llvm/gym_interface_compatability.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down