Developed by Brian DeRenzi and Wenrui Gong
Owned by the Regents of the University of California
A zipped tarfile of this software as of 06/06/2005 is available here.
(Last updated 06/08/2005)
More SUIF passes here.
UCSB
ExPRESS Group
The JuanLoop is a compiler passes built on the SUIF 2 compiler infrastructure. For information on downloading, compiling and installing the SUIF infrastructure see this step by step guide. Juan comes from the Chinese word meaning Happiness.
The Loop pass allows full or partial loop unrolling. Currently, the pass supports unrolling
either for or while loops. The pass by default will do complete
loop unrolls of all while and for loops. To enable partial loop
unrolling, the code must be edited. On line 49 of loop.c there is a single line
of code deciding how many loop unrolls to do. By changing the #define NUM_UNROLLS 0
line to a positive, non-zero number, the pass will unroll that many times. After the change is
made, the code must be recompiled for the change to take effect. There is currently no
command line option, or other runtime specifier, to decide how many loop unrolls to perform.
To install the Juan passes, first double check that SUIF environment is completely setup and working
on your system. Once you are familiar with how the system works and have confirmed that all
environment variables and paths are setup correctly, extract the file in the usual way:
tar -xzf juan_06_06_2005.tar.gz
This will create a directory called Juan in the current working directory.
Change into the Juan directory and type make to make all of the passes. This makefile
will traverse into the subdirectories to execute the individual makefiles for each pass, ultimately
building each module.
NOTE: This will not work if the SUIF environment--and subsequent environment variables--is not setup correctly. If there are any problems compiling, please double check your SUIF installation to ensure that it is properly configured.
The easiest way to use the JuanLoop pass is to create simple shell script to execute a series of SUIF
commands. The order of commands looks something like this:
c2suifsuifdriversuif2cc2suif command will compile the C programming file into the SUIF intermediate
representation. It is this representation (denoted by files ending in .suif) that the JuanLoop pass
operates on. An example is show below:bash$ c2suif test.c
The second step, executing suifdriver will be used to execute the various compiler passes
on the SUIF code. Each pass described below shows an example of how to use the suifdriver
program to inmport all of the necessary modules and execute the pass. In addition to executing the
suifdriver application in a multiple lined manner (as is described below), it is possible
to supply the execution string immediatly using the following syntax:
bash$ suifdrive -e "..."
Where the ... is replaced by the neccessary import, load, execute and save commnads.
To see the resulting C code, it is necessary to convert the SUIF code back to C code. This is done
using the suif2c program. The following example illustrates how easy this is to use:
bash$ c2suif -o test.out.c test.out.suif
The -o option merely allows the user to specify an output filename. Once the C code
is generated, it can be checked for accuracy. See the following sections for more specific
information about each pass.
The Loop pass is used by importing the JuanLoop module into the suifdriver
application and executing the juan_loop_full_unrolling pass to unroll all
for and while loops either partially or completely. Example:
bash$ suifdriver
import suifnodes basicnodes cfenodes utils transforms usefulpasses;
import JuanLoop;
load test.suif;
juan_loop_full_unrolling;
save test.lu.suif
(CTRL-D to terminate)
This will import the necessary modules and passes, load in the test.suif file and execute
the loop unrolling pass on the code, before finally saving the suif file to test.lu.suif. As
mentioned above, the suif2c program can be used to convert the resulting suif file
back to a C file to check the accuracy of the pass.
To test the pass to make sure that it is working properly, simply write a very simple program
with a single loop. Executing the pass on that code will completely unroll the loop (unless the
NUM_UNROLLS parameter is changed). The results can be seen by using the suif2c program to
output the suif intermediate file as a C programming file again. Below is an example program.
int
test() {
int i=0, j=3, result=0;
for( i=0; i<5; i++ )
result += i*j;
}
The function does nothing useful, but provides a small for loop which can be completely unrolled.
To run this test, download the input test file, the
shell script, and the expected output.
In the future, the loop unrolling pass will hopefully be expanded to take in command line arguments to determine the degree of unrolling to perform. There may also be a feature to allow the user to choose the level of unrolling at each loop, allowing loops under a certain threshold to unrolled completely, while other prompt for user input on the level of unrolling to perform.