Reinforcement learning environments for compiler research
Project description
CompilerGym is a toolkit for exposing compiler optimization problems for reinforcement learning. It allows machine learning researchers to experiment with program optimization techniques without requiring any experience in compilers, and provides a framework for compiler developers to expose new optimization problems for AI.
Getting Started
Starting with CompilerGym is simple if you are familiar with other gym environments.
Installation
Install the latest CompilerGym release using:
$ pip install compilergym
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:
$ sudo apt install clang libtinfo5 patchelf
$ export CC=clang
$ export CXX=clang++
We recommend using conda 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
Then clone the CompilerGym source code using:
$ git clone https://github.com/facebookresearch/CompilerGym.git
$ cd CompilerGym
Install the python development dependencies using:
$ make init
Then run the test suite to confirm that everything is working:
$ make test
To build and install the python package, run:
$ make install
When you are finished, you can deactivate and delete the conda environment using:
$ conda deactivate
$ conda env remove -n compiler_gym
Trying it out
To use the environments, import compiler_gym
:
>>> import gym
>>> import compiler_gym
>>> env = gym.make("llvm-autophase-ic-v0")
>>> env.require_dataset("npb-v0") # download a dataset of benchmarks
>>> env.reset() # calling reset starts a new compilation episode
>>> env.step(env.action_space.sample()) # apply a random optimization
See the documentation website for tutorials, further details, and API reference.
Contributing
We welcome contributions to CompilerGym. If you are interested in contributing please see this document.
Citation
If you use CompilerGym in any of your work, please cite:
@Misc{CompilerGym,
author = {Cummins, Chris and Leather, Hugh and Steiner, Benoit and He, Horace and Chintala, Soumith},
title = {{CompilerGym}: A Reinforcement Learning Toolkit for Compilers},
howpublished = {\url{https://github.com/facebookresearch/CompilerGym/}},
year = {2020}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for compiler_gym-0.1.0-py3-none-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 702d83624140bf0e13cbf0cd6d6a77296ecd36977b974935a2075ecd7bc1a0c9 |
|
MD5 | 076dcf8359173cc05f69f800e589fad4 |
|
BLAKE2b-256 | f542a96ddac15ac27fbd7405f19f3a4c71dd4fccd74328a9b72a1128e8ff751c |
Hashes for compiler_gym-0.1.0-py3-none-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c6f166be97798cf51d01b27ce2337fd4b16d208a7e11a33c52edebaa3e800db |
|
MD5 | a34e8240caf9ae0a2bf16c46f399bd39 |
|
BLAKE2b-256 | bde2d8f169c5fcad65202caf591f32fe8c411f0ea6292e24cbeb207de7213f03 |