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

Get Loop Unrolling Example Working out of Tree #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mostafaelhoushi
Copy link
Owner

@mostafaelhoushi mostafaelhoushi commented Mar 7, 2022

Tried to copy and paste the example_loop_unrolling from the CompilerGym repo to a standalone repo, and get it to by just following 2 steps:

  1. pip install compiler_gym
  2. python example_unrolling_service/example_without_bazel.py

Here are some caveats/discussions:

  • Maybe we should move this examples repo to facebookresearch GitHub account?
  • Had to modify the code (see all the lines with FIXME) from the top-of-trunk in CompilerGym development branch to instead be compatible with the latest release of CompilerGym uploaded to PyPi
  • To run clang commands, llvm.clang_path() didn't work so had to just use "clang" for now. But maybe that's OK as we expect people to use their own clang?
  • As of now, when running the example, I am getting this error:
Traceback (most recent call last):
  File "example_unrolling_service/example_without_bazel.py", line 162, in <module>
    with compiler_gym.make(
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/util/registration.py", line 16, in make
    return gym.make(id, **kwargs)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/gym/envs/registration.py", line 200, in make
    return registry.make(id, **kwargs)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/gym/envs/registration.py", line 105, in make
    env = spec.make(**kwargs)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/gym/envs/registration.py", line 75, in make
    env = cls(**_kwargs)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/envs/compiler_env.py", line 287, in __init__
    self.benchmark = benchmark or next(self.datasets.benchmarks())
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/envs/compiler_env.py", line 460, in benchmark
    benchmark_object = self.datasets.benchmark(benchmark)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/datasets/datasets.py", line 270, in benchmark
    return self.benchmark_from_parsed_uri(BenchmarkUri.from_string(uri))
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/datasets/datasets.py", line 303, in benchmark_from_parsed_uri
    return dataset.benchmark_from_parsed_uri(uri)
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/datasets/dataset.py", line 427, in benchmark_from_parsed_uri
    raise NotImplementedError("abstract class")
NotImplementedError: abstract class

Closes !facebookresearch/CompilerGym#532

@mostafaelhoushi mostafaelhoushi changed the title Get-something-running Get Loop Unrolling Example Working out of Tree Mar 7, 2022
@ChrisCummins ChrisCummins marked this pull request as ready for review March 7, 2022 09:54
Copy link
Collaborator

@ChrisCummins ChrisCummins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Maybe we should move this examples repo to facebookresearch GitHub account?

Yes. For now, let's make this repo private.

  • Had to modify the code (see all the lines with FIXME) from the top-of-trunk in CompilerGym development branch to instead be compatible with the latest release of CompilerGym uploaded to PyPi

This is actually really useful as a canary for finding breaking changes 🙂

  • To run clang commands, llvm.clang_path() didn't work so had to just use "clang" for now. But maybe that's OK as we expect people to use their own clang?

Odd. What was the error?

  • As of now, when running the example, I am getting this error:

Comment left inline to fix that.

Cheers,
Chris

example_unrolling_service/example_without_bazel.py Outdated Show resolved Hide resolved

def __init__(self):
super().__init__(
id="size", # name="size", #FIXME
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this one to my attention! I've added a workaround so that the old Reward.id won't break when we next push a release: facebookresearch/CompilerGym#612

# FIXME: yield from (f"benchmark://unrolling-v0{k}" for k in self._benchmarks.keys())
yield from self._benchmarks.keys()

def benchmark(self, uri: str) -> Benchmark:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename benchmark_from_parsed_uris to fix this

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris. It fixed it, but then got another error down the line:

Traceback (most recent call last):
  File "example_unrolling_service/example_without_bazel.py", line 171, in <module>
    observation = env.reset()
  File "/Users/melhoushi/opt/anaconda3/envs/compiler_gym_examples/lib/python3.8/site-packages/compiler_gym/envs/compiler_env.py", line 812, in reset
    self._benchmark_in_use_proto.uri = str(self._benchmark_in_use.uri)
AttributeError: 'generator' object has no attribute 'uri'

@ChrisCummins
Copy link
Collaborator

Hit the wrong UI button and did this:
CleanShot 2022-03-07 at 09 56 55@2x
Not sure how to undo, sorry!

@mostafaelhoushi
Copy link
Owner Author

To run clang commands, llvm.clang_path() didn't work so had to just use "clang" for now. But maybe that's OK as we expect people to use their own clang?
Odd. What was the error?

Strange, when I reverted it to llvm.clang_path(), it works fine now :)

@mostafaelhoushi
Copy link
Owner Author

Hit the wrong UI button and did this: CleanShot 2022-03-07 at 09 56 55@2x Not sure how to undo, sorry!

No worries... Me too I can't revert it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants