Homework 1 - Advanced Compilers - Winter 2004 | EECS 583, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Professor: Mahlke; Class: Advanced Compilers; Subject: Electrical Engineering And Computer Science; University: University of Michigan - Ann Arbor; Term: Winter 2004;

Typology: Assignments

Pre 2010

Uploaded on 09/02/2009

koofers-user-pcj
koofers-user-pcj 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EECS 583 – Homework 1
Winter 2004
Assigned: Wednesday, January 21, 2004
Due: Friday, February 6, 2004
Warmup
Setup and install the Trimaran compiler system under Linux. You can do this either on
your EECS account, CAEN account, or own system. The Trimaran source code is
available on the course webpage (do not use the version on http://www.trimaran.org).
See the installation instructions given in class. Verify that your installation is correct by
running the benchmarks strcpy and wc, i.e., “tcc –bench strcpy”.
You should also compute the estimated number of execution cycles using the compiler.
Using the profile information, the compiler can estimate the running time of an
application assuming a perfect memory system. Hint: you just need to toggle a compiler
switch to make this happen. There is a program called Sumstat that is built when you
make elcor. The compiler creates statistics for each procedure that it compiles and stores
the statistics in a file called ELCOR_STATS. Sumstat simply totals the stats. To run
sumstat, go into the benchmark intermediate directory, e.g., strcpy_O/elcor_intermediate,
and type “Sumstat –total –i ELCOR_STATS”.
Your Mission
The objective of this homework is to implement a Superblock formation algorithm inside
Elcor. Superblock formation consists of 2 steps: trace selection and tail duplication.
Trace selection identifies likely, sequential execution paths in a CFG. You can
use the algorithm from Lecture 3, slides 15-16 directly. Use a threshold
probability of 60% and a minimum weight of 10 (i.e., a BB must have a minimum
profile weight of 10 to be considered for trace selection). I will provide the
function is_backedge(Edge*) to discern if an edge is a backedge or not.
Tail duplication eliminates all side entrances by selectively replicating BBs and
redirecting side entry control flow edges to the replicated BBs. Remember, each
BB in a trace needs to be duplicated at most once with tail duplication. Also, the
profile information for the replicated BBs/edges must be inferred as was
described in class. New basic blocks created by duplication can just be inserted at
the end of the procedure for convenience. You can assume that duplicated BBs
are not eligible for trace selection, hence you only need to form traces out of the
original BBs in the program.
You will start with a Procedure region. You may assume that the procedure only
contains basic blocks, which in turn contain operations. You are given the code
pf2

Partial preview of the text

Download Homework 1 - Advanced Compilers - Winter 2004 | EECS 583 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EECS 583 – Homework 1

Winter 2004

Assigned: Wednesday, January 21, 2004

Due: Friday, February 6, 2004

Warmup

Setup and install the Trimaran compiler system under Linux. You can do this either on your EECS account, CAEN account, or own system. The Trimaran source code is available on the course webpage (do not use the version on http://www.trimaran.org). See the installation instructions given in class. Verify that your installation is correct by running the benchmarks strcpy and wc, i.e., “tcc –bench strcpy”.

You should also compute the estimated number of execution cycles using the compiler. Using the profile information, the compiler can estimate the running time of an application assuming a perfect memory system. Hint: you just need to toggle a compiler switch to make this happen. There is a program called Sumstat that is built when you make elcor. The compiler creates statistics for each procedure that it compiles and stores the statistics in a file called ELCOR_STATS. Sumstat simply totals the stats. To run sumstat, go into the benchmark intermediate directory, e.g., strcpy_O/elcor_intermediate, and type “Sumstat –total –i ELCOR_STATS”.

Your Mission

The objective of this homework is to implement a Superblock formation algorithm inside Elcor. Superblock formation consists of 2 steps: trace selection and tail duplication.

  • Trace selection identifies likely, sequential execution paths in a CFG. You can use the algorithm from Lecture 3, slides 15-16 directly. Use a threshold probability of 60% and a minimum weight of 10 (i.e., a BB must have a minimum profile weight of 10 to be considered for trace selection). I will provide the function is_backedge(Edge*) to discern if an edge is a backedge or not.
  • Tail duplication eliminates all side entrances by selectively replicating BBs and redirecting side entry control flow edges to the replicated BBs. Remember, each BB in a trace needs to be duplicated at most once with tail duplication. Also, the profile information for the replicated BBs/edges must be inferred as was described in class. New basic blocks created by duplication can just be inserted at the end of the procedure for convenience. You can assume that duplicated BBs are not eligible for trace selection, hence you only need to form traces out of the original BBs in the program.

You will start with a Procedure region. You may assume that the procedure only contains basic blocks, which in turn contain operations. You are given the code

provided in trimaran/elcor/src/eecs583/583sbform.cpp to get you started. The code walks all the basic blocks in a procedure visiting the predecessors and successors of each basic block. There are some other utility functions in there as well to help you out such as the is_backedge() function, and some others to help with creating new blocks.

In your code, provide some debug information to print out the traces that you select and the blocks that are duplicated in tail duplication. There is no prescribed format for this information, so just provide whatever you feel is reasonable.

Submission

You should submit a single .tgz file via email to me (or ftp if I get that working) by the due date containing the following:

  1. Single .cpp source file (583sbform.cpp) containing all of your code – This class is not about creating pretty code, but please put some effort into readability. You should NOT need to modify any other parts of the compiler, so please do not!
  2. Single .cpp template file (583template.cpp) if you used any new templates
  3. Rebel (wc.O_el) and debug screen output (wc.OUT) for a run of your superblock formation on the benchmark wc.
  4. Optional README 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 4-3-2-1. 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 do ok.

You are encouraged to help each other with the homework, Trimaran usage, internal data structures, etc. But, each person must turn in his/her own implementation.

Tips

  1. See the file trimaran/elcor/src/eecs583/583sbform.cpp to get started.
  2. Graph/region.h, edge.h. op.h are the central classes you need to look at.
  3. Use graph iterators to walk the IR, see graph/iterators.h. Particularly useful for this homework are Region_exit_edges, Region_entry_edges.
  4. Control/el_control.cpp contains some useful utilities. The function El_fix_pbr_dests_with_edges() can be used to adjust branch targets once you have adjusted edges properly.
  5. Graph/edge_utilities.h, Graph/region_utilities.h contain some other useful functions.
  6. The profile weight on a control flow edge is stored as an attribute. To get access to the weight given an Edge* foo, you use the function get_control_flow_freq(foo) to get the attribute. Then, the profile weight is just a public member variable of the attribute, e.g., attr->freq