EECS 583 Homework 2: Implementing Heuristic Hyperblock Formation Algorithm - Prof. Scott M, Assignments of Electrical and Electronics Engineering

Instructions for homework 2 in eecs 583, a course focused on compiler design. Students are required to implement a heuristic hyperblock formation algorithm that performs selective if-conversion for inner-most loops. The steps involved, including loop detection, backedge coalescing, block selection, tail duplication, and if-conversion. Students are encouraged to be creative in defining heuristics for block selection and are provided with resources and tools to help. The quality of the hyperblocks will be evaluated using the elcor scheduler.

Typology: Assignments

Pre 2010

Uploaded on 09/02/2009

koofers-user-hsj
koofers-user-hsj 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 583 – Homework 2
Winter 2003
Assigned: Monday, January 27, 2003
Due: Monday, February 10, 2003
The goal for this homework is to implement a heuristic hyperblock formation algorithm
that performs selective if-conversion for inner-most loops. On the surface, this requires a
large amount of code to accomplish this task. However, the bulk of the code will be
provided to you (tail duplication, if-conversion). Your main task is to first implement a
simple control flow optimization, backedge coalescing, to convert any multi-backedge
loop into a single backedge loop. Second, implement a heuristic block selection
algorithm to “intelligently” choose the set of basic blocks that will be if-converted. You
are free to define any heuristic that you wish and are encouraged to be creative here.
Please try to avoid just blindly using the BSV algorithm discussed in class.
Your algorithm should operate on an inner-most loop, where you wish to perform
selective if-conversion of the loop body. You should create at most 1 hyperblock for the
loop, so you do not need to worry about making other HBs out of basic blocks that you
do not choose for your primary HB. The algorithm should be applied to all the inner
most loops in the program.
Your algorithm should consist of the following 5 steps:
Loop detection – Using the code from HW1, identify all the loops in a
Procedure. Mark those that are innermost for subsequent processing.
Backedge coalescing – For each inner-most with multiple backedges, combine
all backedges into a single backedge using the technique described in class.
Block selection – Identify the subset of blocks within the loop that you wish to
if-convert using whatever means you wish. The goal is to produce the fastest
code possible as compared with the original basic block implementation.
Tail duplication – Replicate the set of basic blocks and adjust the control flow
edges such that the selected blocks contain no side entrances. This code will be
provided to you, see elcor/src/Control/el_tail_duplication.cpp
If-conversion – Eliminate all the control flow among the selected basic blocks
by using predicated execution. This code will be provided to you, see elcor/src/
Control/el_if_converter.cpp
Block Selection
This will obviously require come thought. You should start with the lecture on
Hyperblocks that talks about the 2 previous techniques, block selection value and path
selection. Think about the cost/benefits of if-conversion. On the benefit side, you
eliminate branches, mispredictions and allow for more instruction overlap. On the
negative side, you may increase resource utilization, dependence height, and possibly
pf2

Partial preview of the text

Download EECS 583 Homework 2: Implementing Heuristic Hyperblock Formation Algorithm - Prof. Scott M and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 583 – Homework 2

Winter 2003

Assigned: Monday, January 27, 2003

Due: Monday, February 10, 2003

The goal for this homework is to implement a heuristic hyperblock formation algorithm that performs selective if-conversion for inner-most loops. On the surface, this requires a large amount of code to accomplish this task. However, the bulk of the code will be provided to you (tail duplication, if-conversion). Your main task is to first implement a simple control flow optimization, backedge coalescing, to convert any multi-backedge loop into a single backedge loop. Second, implement a heuristic block selection algorithm to “intelligently” choose the set of basic blocks that will be if-converted. You are free to define any heuristic that you wish and are encouraged to be creative here. Please try to avoid just blindly using the BSV algorithm discussed in class. Your algorithm should operate on an inner-most loop, where you wish to perform selective if-conversion of the loop body. You should create at most 1 hyperblock for the loop, so you do not need to worry about making other HBs out of basic blocks that you do not choose for your primary HB. The algorithm should be applied to all the inner most loops in the program. Your algorithm should consist of the following 5 steps:

 Loop detection – Using the code from HW1, identify all the loops in a

Procedure. Mark those that are innermost for subsequent processing.

 Backedge coalescing – For each inner-most with multiple backedges, combine

all backedges into a single backedge using the technique described in class.

 Block selection – Identify the subset of blocks within the loop that you wish to

if-convert using whatever means you wish. The goal is to produce the fastest code possible as compared with the original basic block implementation.

 Tail duplication – Replicate the set of basic blocks and adjust the control flow

edges such that the selected blocks contain no side entrances. This code will be provided to you, see elcor/src/Control/el_tail_duplication.cpp

 If-conversion – Eliminate all the control flow among the selected basic blocks

by using predicated execution. This code will be provided to you, see elcor/src/ Control/el_if_converter.cpp

Block Selection

This will obviously require come thought. You should start with the lecture on Hyperblocks that talks about the 2 previous techniques, block selection value and path selection. Think about the cost/benefits of if-conversion. On the benefit side, you eliminate branches, mispredictions and allow for more instruction overlap. On the negative side, you may increase resource utilization, dependence height, and possibly

restrict the ordering of operations. So, the trick is to come up with a heuristic that does a good balancing job. This is left as an open problem without any prescribed solutions. There are several tools available that may be useful to defining a good heuristic for block selection. More info about these will be provided on the course newsgroup.

  1. Control flow profile information
  2. Dependence height of a basic block
  3. Resource minimum schedule length (RMSL)

Performance Evaluation

To evaluate the quality of your hyperblocks, you will need to turn on the Elcor scheduler. For simplicity, we will assume infinite registers, so register allocation will be turned off. Elcor collects statistics on the estimated execution cycles for each function that are output into the file ELCOR_STATS. You are interested in the total execution cycles.

Submission and Grading

You should submit a single .tgz file via anonymous ftp to www.eecs.umich.edu, log in as anonymous, cd /groups/eecs583, put your tar file named uniquename_hw2.tgz. Note that you will not be able to perform any gets from this directory. Your tar file should contain:

  1. loopdet.cpp, loopdet.h from HW1 with modifications to identify innermost loops.
  2. 2 files, hyperblock.cpp, hyperblock.h which contain the source code for this HW
  3. Single .cpp template file (583_template.cpp) if you used any new templates
  4. Text output file that you get for 583hw2d (583hw2[a-c] are for you to play with, feel free to create other testcases, just create a directory under benchmarks using the same format).
  5. README.hw2 file that contains any special instructions or other notes you wish to give me. For instance, if you could not get the entire thing working, how far did you get, what is broken, etc. Grading will be 2, 1, or 0, same as HW1.

Working Together and Hints

You are encouraged to help each other with the homework, Trimaran usage, internal data structures, heuristics, etc. But, each person must turn in their own implementation. A sample piece of code for the HB formation will be provided to get you started. Stay tuned for more.

Competition

On a TBD benchmark, the two people with the best performance will receive the first ever EECS583 outstanding HW prize. Stay tuned for more!!