AutoPhase is a framework that uses deep reinforcement learning (RL) to optimize the order of the passes that increase the performance of the programs by minimizing the clock cycle count. For more details, please see:
AutoPhase takes a program as an input and compiles into LLVM IR. The neural network agent takes as input the features of the program (using IR Feature Extractor), clock cycle count (using Clock-cycle Profiler), and histogram of previously applied passes. Then it outputs the prediction of the best next optimization pass to apply, which is used to generate a new LLVM IR.
AutoPhase depends on the following open-source tools, LegUp (HLS compiler), and Ray (RL framework). Dependencies:
- Ray[rllib] (
pip3 install ray[rllib]
) - Tensorflow (https://www.tensorflow.org/install/pip)
- LegUp4.0 (https://legup.eecg.utoronto.ca/docs/4.0/gettingstarted.html#getstarted)
- LLVM (comes with LegUp)
- Clang (comes with LegUp)
Please refer to (patch/README.md) to install the LLVM patches.
We also compare RL against:
- Insertion-based greedy search / beam search (algos/greedy/greedy_search.py)
- DEAP (
pip install deap
) - OpenTuner (
pip install opentuner
)
git clone https://github.com/ucb-bar/autophase.git
export LEGUP_PATH=$(realpath "/path/to/legup-4.0")
export AUTOPHASE_PATH=$(realpath "/path/to/autophase")
cd autophase/gym-hls/
pip install -e .
cd ../algos/rl
python ppo_ray.py