Skip to content

Commit

Permalink
Merge pull request #164 from facebookresearch/release-v0.1.7
Browse files Browse the repository at this point in the history
Release v0.1.7
  • Loading branch information
ChrisCummins authored Apr 2, 2021
2 parents af92064 8f2c849 commit c728073
Show file tree
Hide file tree
Showing 63 changed files with 2,099 additions and 255 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 1 @@
3.1.0
4.0.0
28 changes: 18 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 18,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: [3.6, 3.7, 3.8]
python: [3.6, 3.7, 3.8, 3.9]
exclude:
# Only test recent python versions on macOS.
- os: macos-latest
Expand All @@ -36,25 36,29 @@ jobs:

- name: Install dependencies (linux)
run: |
curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64" > bazel.tmp
sudo mv bazel.tmp /usr/local/bin/bazel
chmod x /usr/local/bin/bazel
curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64" > bazel
chmod x bazel
sudo mv bazel /usr/local/bin/bazel
sudo apt install clang-9 patchelf
python -m pip install -r compiler_gym/requirements.txt -r examples/requirements.txt -r leaderboard/requirements.txt -r tests/requirements.txt
if: matrix.os == 'ubuntu-latest'

- name: Install dependencies (macOS)
run: |
brew install bazelisk
brew install bazelisk zlib
python -m pip install -r compiler_gym/requirements.txt -r examples/requirements.txt -r leaderboard/requirements.txt -r tests/requirements.txt
env:
LDFLAGS: -L/usr/local/opt/zlib/lib
CPPFLAGS: -I/usr/local/opt/zlib/include
PKG_CONFIG_PATH: /usr/local/opt/zlib/lib/pkgconfig
if: matrix.os == 'macos-latest'

- name: Test
run: make test
env:
CC: clang
CXX: clang
BAZEL_TEST_OPTS: --config=ci
BAZEL_TEST_OPTS: --config=ci --test_timeout=300,900,1800,7200


install_test:
Expand All @@ -76,17 80,21 @@ jobs:

- name: Install dependencies (linux)
run: |
curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64" > bazel.tmp
sudo mv bazel.tmp /usr/local/bin/bazel
chmod x /usr/local/bin/bazel
curl -L "https://github.com/bazelbuild/bazelisk/releases/download/v1.6.1/bazelisk-linux-amd64" > bazel
chmod x bazel
sudo mv bazel /usr/local/bin/bazel
sudo apt install clang-9 patchelf
python -m pip install -r compiler_gym/requirements.txt -r examples/requirements.txt -r leaderboard/requirements.txt -r tests/requirements.txt
if: matrix.os == 'ubuntu-latest'

- name: Install dependencies (macos)
run: |
brew install bazelisk
brew install bazelisk zlib
python -m pip install -r compiler_gym/requirements.txt -r examples/requirements.txt -r leaderboard/requirements.txt -r tests/requirements.txt
env:
LDFLAGS: -L/usr/local/opt/zlib/lib
CPPFLAGS: -I/usr/local/opt/zlib/include
PKG_CONFIG_PATH: /usr/local/opt/zlib/lib/pkgconfig
if: matrix.os == 'macos-latest'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: [3.8]
python: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 39,10 @@ jobs:
wget -O hadolint https://github.com/hadolint/hadolint/releases/download/v1.19.0/hadolint-Linux-x86_64
chmod x hadolint
sudo mv hadolint /usr/local/bin
- name: Install Python 3.8
- name: Install Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install Python dependencies
run: |
sudo apt-get install python3-setuptools
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python: [3.8]
python: [3.9]

steps:
- uses: actions/checkout@v2
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 1,29 @@
## Release 0.1.7 (2021-04-01)

This release introduces [public
leaderboards](https://github.com/facebookresearch/CompilerGym#leaderboards) to
track the performance of user-submitted algorithms on compiler optimization
tasks.

- Added a new `compiler_gym.leaderboard` package which contains utilities for
preparing leaderboard submissions
[(#161)](https://github.com/facebookresearch/CompilerGym/pull/161).
- Added a LLVM instruction count leaderboard and seeded it with a random search
baseline [(#117)](https://github.com/facebookresearch/CompilerGym/pull/117).
- Added support for Python 3.9, extending the set of supported python versions to
3.6, 3.7, 3.8, and 3.9
[(#160)](https://github.com/facebookresearch/CompilerGym/pull/160).
- [llvm] Added a new `InstCount` observation space that contains the counts of
each type of instruction
[(#159)](https://github.com/facebookresearch/CompilerGym/pull/159).

**Build dependencies update notice:** If you are building from source and
upgrading from an older version of CompilerGym, your build environment will need
to be updated. The easiest way to do that is to remove your existing conda
environment using `conda remove --name compiler_gym --all` and to repeat the
steps in [building from
source](https://github.com/facebookresearch/CompilerGym#building-from-source).

## Release 0.1.6 (2021-03-22)

This release focuses on hardening the LLVM environments, providing improved
Expand Down
34 changes: 20 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 37,26 @@ We actively welcome your pull requests.
("CLA").


## Leaderboard Submissions

To add a new result to the leaderboard, add a new entry to the leaderboard table
and file a [Pull Request](#pull-requests). Please include:

1. A list of all authors.
2. A CSV file of your results. The
[compiler_gym.leaderboard](https://facebookresearch.github.io/CompilerGym/compiler_gym/leaderboard.html)
package provides utilities to help generate results using your agent.
3. A write-up of your approach. You may use the
[submission template](/leaderboard/SUBMISSION_TEMPLATE.md) as a guide.

We do not require that you submit the source code for your approach. Once you
submit your pull request we will validate your results CSV files and may ask
clarifying questions if we feel that those would be useful to improve
reproducibility. Please [take a look
here](https://github.com/facebookresearch/CompilerGym/pull/117) for an example
of a well-formed pull request submission.


## Code Style

We want to ease the burden of code formatting using tools. Our code style
Expand All @@ -62,20 82,6 @@ Other common sense rules we encourage are:
easy-to-write.


## Leaderboard Submissions

To add a new result to the leaderboard, add a new entry to the leaderboard table
and file a [Pull Request](#pull-requests). Please include:

1. A list of all authors.
2. A CSV file of your results.
3. A write-up of your approach. You may use the
[submission template](/leaderboard/SUBMISSION_TEMPLATE.md) as a guide.

Please [take a look
here](https://github.com/facebookresearch/CompilerGym/pull/127) for an example
of a well-formed pull request submission.

## Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA. You
Expand Down
104 changes: 64 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 32,15 @@ developers to expose new optimization problems for AI.

**Table of Contents**

<!-- MarkdownTOC -->

- [Getting Started](#getting-started)
- [Installation](#installation)
- [Building from Source](#building-from-source)
- [Trying it out](#trying-it-out)
- [Leaderboards](#leaderboards)
- [llvm-ic-v0](#llvm-ic-v0)
- [cBench-v1](#cBench-v1)
- [LLVM Instruction Count](#llvm-instruction-count)
- [Contributing](#contributing)
- [Citation](#citation)

<!-- /MarkdownTOC -->

# Getting Started

Expand All @@ -58,55 54,82 @@ for an overview of the key concepts.

Install the latest CompilerGym release using:

$ pip install compiler_gym
pip install -U compiler_gym

The binary works on macOS and Linux (on Ubuntu 18.04, Fedora 28, Debian 10 or
newer equivalents).

### Building from Source

If you prefer, you may build from source. This requires a modern C toolchain.
On macOS you can use the system compiler. On linux, install the required
toolchain using:
If you prefer, you may build from source. This requires a modern C toolchain
and bazel.

#### macOS <!-- omit in toc -->

On macOS the required dependencies can be installed using
[homebrew](https://docs.brew.sh/Installation):

```sh
brew install bazelisk zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
```

Now proceed to [All platforms](#all-platforms) below.

#### Linux <!-- omit in toc -->

$ sudo apt install clang libtinfo5 patchelf
$ export CC=clang
$ export CXX=clang
On debian-based linux systems, install the required toolchain using:

```sh
sudo apt install clang libtinfo5 libjpeg-dev patchelf
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.7.5/bazelisk-linux-amd64 -O bazel
chmod x bazel && mkdir -p ~/.local/bin && mv -v bazel ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
export CC=clang
export CXX=clang
```

#### All platforms <!-- omit in toc -->

We recommend using
[conda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/)
to manage the remaining build dependencies. First create a conda environment
with the required dependencies:

$ conda create -n compiler_gym python=3.8 bazel=3.1.0 cmake pandoc
$ conda activate compiler_gym
conda create -n compiler_gym python=3.9 cmake pandoc
conda activate compiler_gym

Then clone the CompilerGym source code using:

$ git clone https://github.com/facebookresearch/CompilerGym.git
$ cd CompilerGym
git clone https://github.com/facebookresearch/CompilerGym.git
cd CompilerGym

Install the python development dependencies using:

$ make init
make init

The `make init` target only needs to be run once on initial setup, or when
upgrading to a different CompilerGym release.

Then run the test suite to confirm that everything is working:
Run the test suite to confirm that everything is working:

$ make test
make test

To build and install the python package, run:
To build and install the `compiler_gym` python package, run:

$ make install
make install

**NOTE:** To use the python code that is installed by `make install` you must
leave the root directory of this repository. Attempting to import `compiler_gym`
while in the root of this repository will cause import errors.
**NOTE:** To use the `compiler_gym` package that is installed by `make install`
you must leave the root directory of this repository. Attempting to import
`compiler_gym` while in the root of this repository will cause import errors.

When you are finished, you can deactivate and delete the conda
environment using:

$ conda deactivate
$ conda env remove -n compiler_gym
conda deactivate
conda env remove -n compiler_gym


## Trying it out
Expand All @@ -130,32 153,33 @@ tutorials, further details, and API reference.

# Leaderboards

🚧 **Under construction** 🚧 As of CompilerGym v0.1.6 we are not yet accepting
submissions for these leaderboards. Please check back soon!

These leaderboards track the performance of user-submitted algorithms for
CompilerGym tasks. To submit a result please see
[this document](https://github.com/facebookresearch/CompilerGym/blob/development/CONTRIBUTING.md#leaderboard-submissions).


## llvm-ic-v0

LLVM is a popular open source compiler used widely in industry and research.
This environment exposes the optimization pipeline as a set of actions that can
be applied to a particular program. The goal of the agent is to select the
sequence of optimizations that lead to the greatest reduction in instruction
count in the program being compiled. Reward is the reduction in codesize
achieved scaled to the reduction achieved by LLVM's builtin `-Oz` pipeline.
## LLVM Instruction Count

### cBench-v1
LLVM is a popular open source compiler used widely in industry and research. The
`llvm-ic-v0` environment exposes LLVM's optimizing passes as a set of actions
that can be applied to a particular program. The goal of the agent is to select
the sequence of optimizations that lead to the greatest reduction in instruction
count in the program being compiled. Reward is the reduction in instruction
count achieved scaled to the reduction achieved by LLVM's builtin `-Oz`
pipeline.

This leaderboard tracks the results achieved by algorithms on the `llvm-ic-v0`
environment on the 23 benchmarks in the `cBench-v1` dataset.

| Author | Algorithm | Links | Date | Walltime (mean) | Codesize Reduction (geomean) |
| --- | --- | --- | --- | --- | --- |
| Facebook | Greedy search | [write-up](leaderboard/llvm_codesize/e_greedy/README.md), [results](leaderboard/llvm_codesize/e_greedy/results_e0.csv) | 2021-03 | 169.237s | 1.055× |
| Facebook | e-Greedy search (e=0.1) | [write-up](leaderboard/llvm_codesize/e_greedy/README.md), [results](leaderboard/llvm_codesize/e_greedy/results_e10.csv) | 2021-03 | 152.579s | 1.041× |
| Facebook | Random search (t=10800) | [write-up](leaderboard/llvm_instcount/random_search/README.md), [results](leaderboard/llvm_instcount/random_search/results_p125_t10800.csv) | 2021-03 | 10,512.356s | **1.062×** |
| Facebook | Random search (t=3600) | [write-up](leaderboard/llvm_instcount/random_search/README.md), [results](leaderboard/llvm_instcount/random_search/results_p125_t3600.csv) | 2021-03 | 3,630.821s | 1.061× |
| Facebook | Greedy search | [write-up](leaderboard/llvm_instcount/e_greedy/README.md), [results](leaderboard/llvm_instcount/e_greedy/results_e0.csv) | 2021-03 | 169.237s | 1.055× |
| Facebook | Random search (t=60) | [write-up](leaderboard/llvm_instcount/random_search/README.md), [results](leaderboard/llvm_instcount/random_search/results_p125_t60.csv) | 2021-03 | 91.215s | 1.045× |
| Facebook | e-Greedy search (e=0.1) | [write-up](leaderboard/llvm_instcount/e_greedy/README.md), [results](leaderboard/llvm_instcount/e_greedy/results_e10.csv) | 2021-03 | 152.579s | 1.041× |
| Facebook | Random search (t=10) | [write-up](leaderboard/llvm_instcount/random_search/README.md), [results](leaderboard/llvm_instcount/random_search/results_p125_t10.csv) | 2021-03 | **42.939s** | 1.031× |


# Contributing

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 1 @@
0.1.6
0.1.7
7 changes: 4 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 118,13 @@ rules_proto_toolchains()

# === GRPC ===

# Version should be kept in step with compiler_gym/requirements.txt.
http_archive(
name = "com_github_grpc_grpc",
sha256 = "7372a881122cd85a7224435a1d58bc5e11c88d4fb98a64b83f36f3d1c2f16d39",
strip_prefix = "grpc-1.34.0",
sha256 = "1a5127c81487f4e3e57973bb332f04b9159f94d860c207e096d8a587d371edbd",
strip_prefix = "grpc-1.36.0",
urls = [
"https://github.com/grpc/grpc/archive/v1.34.0.tar.gz",
"https://github.com/grpc/grpc/archive/v1.36.0.tar.gz",
],
)

Expand Down
3 changes: 2 additions & 1 deletion compiler_gym/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 15,15 @@ py_library(
":random_search",
":validate",
"//compiler_gym/envs",
"//compiler_gym/leaderboard",
"//compiler_gym/util",
],
)

py_library(
name = "compiler_env_state",
srcs = ["compiler_env_state.py"],
visibility = ["//compiler_gym/envs:__subpackages__"],
visibility = ["//compiler_gym:__subpackages__"],
)

py_library(
Expand Down
Loading

0 comments on commit c728073

Please sign in to comment.