From cTuning.org
Scripts
A set of scripts have been writen to automate the installation and compilation process.
These scripts can be placed in other directories as long as they are in the same directory, here's an overview of their functionalities:
- ici-adapt-compile.sh: compile with adapt plugin
- ici-build-adapt-plugin.sh: build and install plugin
- ici-build-gcc-{adapt,tuning}.sh: build and install gcc-ici
- ici-check-environment.sh: print environment variables
- ici-rebuild-gcc-{adapt,tuning}-debug.sh: build gcc for debug
- ici-set-environment.sh: set environment variables
- ici-xml-util.py: modify XMLs automaticly
A step by step description will be given below to demostrate how you can use ICI easily with them:
Build and Install GCC-ICI and Adapt Plugin
1. Modify ici-set-environment.sh to specify important paths:
- ICI_PREFIX: where you want to install everything
- ICI_BUILD: where you would like to build libs and GCC
- ICI_SOURCE: where gcc-ici/branches lies
Please use absolute path for these three variables
To config the place of XML files, you can set ICI_ADAPT_XMLDIR variable to where you save temporary XML files, If you set an relative path, the files will be generated relative to the current/working directory. For example, if you set ICI_ADAPT_XMLDIR="xmls" and your current/working dir is /somepath/, then XML files will be stored to /somepath/xmls/.
Remeber to extract the src-third-party tarball.
2. Build and install gcc-4.4.0-ici-2.0-adapt by runing:
$ ./ici-build-gcc-adapt.sh 0
This script would remove everything and perform clean build from souce given parameter 0, run this script without any parameters to access usage:
$ ./ici-build-gcc-adapt.sh Usage: ici-build-gcc-adapt.sh <build> build: 0 - remove all and build everything from source 1 - remove gcc objects and rebuild gcc 2 - rebuild gcc
3. Build and install adapt plugin:
</pre>
$ ./ici-build-adapt-plugin.sh
</pre>
This script would build and install libmxml, adapt plugin. Remember to run this script after the first step, because the plugin will be removed with gcc and other libs. It will build adapt plugin with Makefile2 in adapt-1.0 direcotry, in which ICI_SOURCE and ICI_PREFIX environment varibles are employed to specify paths.
(Optional) A stage 1 gcc for debugging can be generated with the following script:
$ ./ici-rebuild-gcc-tuning-debug.sh
Remember to run this script after a clean all build of GCC-ICI.
Compile with ICI and Adapt Plugin
The compilation can be devided into three steps, and a script is provided to automate the process below:
1. Create current XML with the compilation flow and info
$ ./ici-adapt-compile.sh 1
All xml files will be put in a directory specified by $ICI_ADAPT_XMLDIR variable in ici-set-environment script. This script can be used to compile with a make file or call gcc directly. A script which contains the compilation follow with stage1 gcc can be generated for debug too.
Run this script without any parameters to access usage:
$ ./ici-adapt-compile.sh Usage: ici-adapt-compile.sh <ctrl> [func] [vrbs] ctrl: 1 - record XML 2 - reuse XML func: 1 - compile with make file 2 - compile with gcc -c *.c 3 - compile with stage1 gcc -c *.c 4 - generate asm with gcc -S *.c 5 - generate asm with stage1 gcc -S *.c 9 - generate a script to debug stage1 gcc vrbs: 1 ~ 3 verbose level
2. Modify xml files based on an ini format file to turn on function cloning pass or/and instrumentation pass
$ ./ici-xml-util.py [option] file.ini xmldir
- file.ini:controls how to perform function cloning and instrumentation,
- xmldir: dicrectory which contain XML files to be modified to enable cloning
- option -i: enable instrumentation
- option -t <filename>: generate external library template
3. Compiles program, clone functions, apply optimization flags to clones
$ ./ici-adapt-compile.sh 2
A script is provided to automate the process above:
$ ./ici-adapt-autorun.sh
This script is designed to run in the benchmark source directory with an ini file providing instructions to modify XML files named "adapt.ini", and if there is a file named "__ici_run.sh", it will be called at the end of compilation.