CHiLL is a source-to-source translator for composing high level loop transformations to improve the performance of nested loop calculations written in C. CHiLL’s operations are driven by a script which is generated or supplied by the user that specifies the location of the original source file, the function and loops to modify and the transformations to apply.
CHill can be built from two build systems, CMake or automake. (CMake is recomended for use with CLion)
git clone https://github.com/CtopCsUtahEdu/chill.git
mkdir build; cd build
cmake .. -DROSEHOME=<...> -DBOOSTHOME=<...> -DIEGENHOME=<...>
or cmake .. -DCHILLENV=<...>
make
Note: you can also create the build directory somewhere else and substitute ..
with where your source is located.
git clone https://echo12.cs.utah.edu/dhuth/chill-dev.git
.bootstrap
./configure --with-rose=<...> --with-boost=<...> --with-iegen=<...>
(optionally specify --enable-cuda=yes
to build cuda-chill intsead)Note that for both CMake and automake builds, all these extra variables may be specified in the environment so that they don't need to be specified each time. If something is wrong please following the error message, they usually provides a detailed report of what is missing or possibly misplaces.
CHiLL takes a single python script file as an argument, and the script file will reference a C source file.
For example, here is the script file fuse_distribute.script.py
# Basic illustration of loop fusion and distribution.
from chill import *
source('fuse_distribute.c')
destination('fuse_distributemodified.c')
procedure('foo')
loop(0)
# initially fused as much as possible
original()
print_code()
# distribute the first two statements
distribute([0,1], 2)
print_code()
# prepare the third statement for fusion
shift([2], 2, 1)
print_code()
# fuse the last two statements
fuse([1,2],2)
print_code()
And the source file fuse_distribute.c
void foo(double A[100], double B[100]) {
int i, j;
for(i = 0; i < 100; i++) {
for(j = 0; j < 100; j++) {
A[j] = 1.0;
}
for(j = 0; j < 100; j++) {
B[j] = 1.0;
}
for(j = 0; j < 99; j++) {
B[j] = B[j+1]*A[j];
}
}
}
chill fuse_distribute.script.py
will generate the destination source file fuse_distributemodified.c
void foo(double A[100], double B[100]) {
int t4;
int t2;
for (t2 = 0; t2 <= 99; t2 += 1) {
for (t4 = 0; t4 <= 99; t4 += 1)
A[t4] = 1;
B[0] = 1;
for (t4 = 1; t4 <= 99; t4 += 1) {
B[t4] = 1;
B[t4 - 1] = B[t4 - 1 + 1] * A[t4 - 1];
}
}
}
Additional examples and testcases for CHiLL can be found under examples/chill/testcases. Testcases and exemples for CUDA-CHiLL can be found under exaples/cuda-chill/testcases.
CHiLL and CUDA-CHiLL can operate with either Rose or Clang as its parser implementation. We recommend building with Rose first and try Clang if that doesn't work.
Rose will give more verbose parsing output that includes most information from the preprocessors whereas Clang will expand all includes and macros. Although we don't test result from Clang in our CI due to these minor differences, we expect it to run fine. However, Clang tends to be able to build on more platforms and is included in the official repositories of most mainstream distros, making it a good backup choice.
Building with Clang is currently only supported by the CMake build system. Pass "-DFRONTEND=Clang" to CMake when you are configuring, and build as above.