Skip to content

ucd-plse/Precimonious-Clang-Plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Precimonious-Clang-Plugins

1. Setup

Required Prerequisites

Hardware:

  • 40GB free disk space recommended (At lease more than 30GB to download the docker image and the github repo.)

Software:

  • Ubuntu
    • Recommended version: 20.04 with kernel version 5.14.0 (The reproduction package has not been tested on other operating systems.)
  • Docker
    • Recommended version: 23.0.1 (The reproduction package has not been tested with other Docker versions.)

Steps to Set Up

In the following steps, please replace <YOUR LOCAL PATH TO THIS REPO> to your local path of this github repository.

Step 1: Git clone the repo (approx. a few secs)

Clone this GitHub repository to your local directory.

git clone https://github.com/ucd-plse/Precimonious-Clang-Plugins.git <YOUR LOCAL PATH TO THIS REPO>
Step 2: Pull the Docker image (approx. 15min)

Please note that the docker image size is 28.3GB.

docker pull ucdavisplse/fplearner
Step 3: Run a Docker container (approx. a few secs)
docker run -v <YOUR LOCAL PATH TO THIS REPO>:/root/home -ti  --name precimonious ucdavisplse/fplearner

If necessary, you can also change the container's name.

In the subsequent process of experiments reproduction, the first step is always to make sure you are inside the docker container. If you are not, please run the following command (approx. a few secs):

docker start -i precimonious

To exit and stop the container, press Ctrl+D.

Check if you are in the docker container
root@<container_id>:~/home# ls
Precimonious  README.md
root@<container_id>:~/home# pwd
/root/home

2. Run Precimonious

Funarc

we first provide a toy example to show how to use Precimonious to tune the precision of a small benchmark, funarc.

Run the following commands (approx. 2min)

cd /root/home/Precimonious
python3 run.py funarc 10

Note that the second argument 10 indicates the timeout in seconds to run the benchmark funarc once. To get an idea of how to compile and run funarc, check the file /root/home/Precimonious/funarc/scripts/Makefile and run make under the same directory.

Expected results:

After the precision tuning is done, you can find a folder in /root/home/Precimonious/funarc/run/results-eps==4-A which contains the following files:

  • *.json: all precision configurations in the search
  • .log: a log file containing model prediction results for each configuration and the corresponding verification results
  • dd2_valid_{BENCH}_{IDX}.json: the best precision configuration found by our tool
  • best_speedup_{BENCH}_{IDX}.txt: the corresponding best speed up

NAS CG

Run the following commands. (approx. 1h) cg specifies the name of the benchmark, and 10 indicates the timeout in seconds to run the benchmark cg.

cd /root/home/Precimonious
python3 run.py cg 10

Expected results are the same as funarc.

3. How to Use Clang Plugins Separately

There are two Clang plugins CreateSearchSpace.so and TransformType.so which can be found in Precimonious-Clang-Plugins/Precimonious/plugin/. CreateSearchSpace.so is used to create the search space of a benchmark and TransformType.so is to transform a benchmark based on a specific precision configuration.

Compile Clang Plugins

First, you need to compile the clang plugins. The repository contains the clang plugin codes CreateSearchSpace.cpp and TransformType.cpp. The repository already has compiled clang plugins CreateSearchSpace.so and TransformType.so. To compile them mannually, run the following commands.

cd /root/home/Precimonious/plugin
make PLUGIN=CreateSearchSpace
make PLUGIN=TransformType

Use Clang Plugins on NAS CG

  1. Generate search space of cg
cd /root/home/Precimonious/cg/run
python3 generate-include.py
python3 setup.py cg
python3 create-search-space.py cg
  1. Apply a precision configuration on cg
python3 trans-type.py example.json cg

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published