EECS 583 Homework 1: Implementing an If-Converter for Sequential, Predicated Code - Prof. , Assignments of Electrical and Electronics Engineering

The instructions for homework 1 in eecs 583, a course focused on compiler design. Students are required to implement an if-converter to convert branching code into sequential, predicated code using the algorithms discussed in class. Details on the setup, installation of the trimaran compiler system, and the steps to complete the assignment, including computing control dependences, creating predicates, constructing and inserting cmpps, and guarding all operations. Submission instructions and grading criteria are also provided.

Typology: Assignments

Pre 2010

Uploaded on 09/17/2009

koofers-user-rh0-1
koofers-user-rh0-1 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 583 – Homework 1
Winter 2002
Assigned: Wednesday, January 23, 2002
Due: Wednesday, February 6, 2002
Warmup
Setup and install the Trimaran compiler system under Linux. You can do this either on
your CAEN account or own system. Source code available on course webpage, this has
some fixes for gcc 2.96, plus some code to get you started. If you have already installed
trimaran from http://www.trimaran.org , then you should get the code from the course
webpage and extract the following files, overwrite your files with these.
trimaran/elcor/src/GNUmakefile, trimaran/elcor/src/Main/eecs583.cpp,
trimaran/elcor/src/Main/process_function.cpp, trimaran/elcor/src/Main/el_driver_init.h
and .cpp, trimaran/elcor/parms/DRIVER_DEFAULTS, trimaran/envrc
After untarring, modify first line of envrc appropriately, then add to your .cshrc, source
…/trimaran/envrc. This sets all the enviroment variables that trimaran requires. Then, cd
trimaran, run ./install (fix errors that come up )
Problem #1
Implement an if-converter to convert branching code into sequential, predicated code
using the algorithms discussed in class. Your if-converter will operate on a complete,
acyclic procedure, converting it to straight-line, predicated code. You may assume the
procedure has no loops or cycles of any sort. As a result, there is no need to do any
backedge coalescing. The if-converter should convert the body of the procedure into a
single basic block without any branches (except of course any subroutine calls (BRL) and
the return from subroutine operation at the end of the procedure (RTS)). You may skip
all the CMPP compaction stuff. So, essentially, you are to implement steps 2 and 3 of the
if-conversion algorithm that was discussed in class.
Assumptions you can make:
- Procedure only contains basic blocks which in turn contain operations
- Generate only ON style CMPPs
- All branches are removed except BRLs and RTSs
You are given (see code provided in trimaran/elcor/src/Main/eecs583.cpp):
- Post dominator, and immediate post dominator for each basic block
- Function to create an ON style CMPP
- Function to create a predicate clear (remember to initialize each ON predicate!)
Steps:
1. Compute control dependences for each basic block, CD(x)
2. Create predicates for each unique control dependence
3. Construct and insert CMPPs
4. Guard all operations (initially everything is guarded by True)
5. (bonus, if you have the guts!) Remove control flow
pf2

Partial preview of the text

Download EECS 583 Homework 1: Implementing an If-Converter for Sequential, Predicated Code - Prof. and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 583 – Homework 1

Winter 2002

Assigned: Wednesday, January 23, 2002

Due: Wednesday, February 6, 2002

Warmup

Setup and install the Trimaran compiler system under Linux. You can do this either on your CAEN account or own system. Source code available on course webpage, this has some fixes for gcc 2.96, plus some code to get you started. If you have already installed trimaran from http://www.trimaran.org , then you should get the code from the course webpage and extract the following files, overwrite your files with these. trimaran/elcor/src/GNUmakefile, trimaran/elcor/src/Main/eecs583.cpp, trimaran/elcor/src/Main/process_function.cpp, trimaran/elcor/src/Main/el_driver_init.h and .cpp, trimaran/elcor/parms/DRIVER_DEFAULTS, trimaran/envrc

After untarring, modify first line of envrc appropriately, then add to your .cshrc, source …/trimaran/envrc. This sets all the enviroment variables that trimaran requires. Then, cd trimaran, run ./install (fix errors that come up ☺)

Problem

Implement an if-converter to convert branching code into sequential, predicated code using the algorithms discussed in class. Your if-converter will operate on a complete, acyclic procedure, converting it to straight-line, predicated code. You may assume the procedure has no loops or cycles of any sort. As a result, there is no need to do any backedge coalescing. The if-converter should convert the body of the procedure into a single basic block without any branches (except of course any subroutine calls (BRL) and the return from subroutine operation at the end of the procedure (RTS)). You may skip all the CMPP compaction stuff. So, essentially, you are to implement steps 2 and 3 of the if-conversion algorithm that was discussed in class.

Assumptions you can make:

  • Procedure only contains basic blocks which in turn contain operations
  • Generate only ON style CMPPs
  • All branches are removed except BRLs and RTSs You are given (see code provided in trimaran/elcor/src/Main/eecs583.cpp):
  • Post dominator, and immediate post dominator for each basic block
  • Function to create an ON style CMPP
  • Function to create a predicate clear (remember to initialize each ON predicate!) Steps:
  1. Compute control dependences for each basic block, CD(x)
  2. Create predicates for each unique control dependence
  3. Construct and insert CMPPs
  4. Guard all operations (initially everything is guarded by True)
  5. (bonus, if you have the guts!) Remove control flow
  1. Verify the code runs properly using the Trimaran simulator

Submission and Grading

You should submit the following to me via email ([email protected]) by 2/6/02. If you work with someone (see below), just submit one email with both persons names at the top.

  1. Single .cpp file containing all of your code – This class is not about creating pretty code, but please put some effort into readability, i.e., indent properly, use C++ style, the Elcor tools library, break up into small functions, a few comments, etc.
  2. Elcor output file that you get for 583test4 (583test1-3 are for you to play with, feel free to create other testcases, just create a directory under benchmarks using the same format).

Grading will be Pass/Fail. Bonus is worth an extra 20% for you homework score. Getting everything to work properly is obviously what you should be striving for, but I’m looking for effort and significant progress, so if you have both of those, you will Pass. To get the bonus, it must work.

Working together

You can work alone or in groups of 2, which ever you feel most comfortable. If you work together, each of you are responsible to understand the whole solution (i.e., both you and your partner’s code). So, you should be able to stand up in front of the class and explain your combined solution.

Running the compiler/simulator

Gui, figure it out yourself. You want to generate BB code, with the standard settings. This is useful to learn, but is not necessary for this assignment.

Compiler manually, elcor –i test1.O_reb –o test1.O_el –Finput_format=rebel –Foutput_format=rebel
-Fdo_583_hw1=yes

Simulator manually (can run on O_reb file as well), Note host_layout_info.md must be in same directory as test1* files. codegen –el test1.O_el –o test1.c –Finput_format=rebel –Femulate_unscheduled=yes
–Femulate_virtual_regs=yes gcc –I/home/mahlke/trimaran/simu/src/Emulib –L/home/mahlke/trimaran/simu/lib *.c –lequals -lm ./a.out > output, diff output verses expected output