Download EECS 583 Class 2: Trimaran Installation and Control Flow Analysis Overview - Prof. Scott M and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!
EECS 583 – Class 2 Trimaran Installation Overview Basic Control Flow Analysis
University of Michigan January 11, 2006
Reading Material^ Y^ See reading list on course webpage^ Y^ Trimaran/HPL_PD references^ Y^ Class 1
»^ “EPIC: An Architecture for Instruction-Level Parallel Processors”^ y^
Optional – more in-depth look at VLIW/EPIC arch features
Y^ Topic 1 – Control flow analysis and optimization^ »
Today’s class^ y^ Ch 9.4, 10.4 from Red Dragon book (Aho, Sethi, Ullman) » Next Wednesday’s class^ y^ “Trace selection for Compiling Large C Application Programs toMicrocode”^ y^ “The Superblock: An Effective Technique for VLIW and SuperscalarCompilation”
Needed Software (older versions likely towork but I’m not certain)^ Y^ perl, gzip, gunzip^ Y^ gnu make 3.80^ Y^ autoconf 2.54, automake 1.7 (need these verions!)^ Y^ gcc – we use 4.0.1, 3.4.4, 3.2 also should work^ Y^ Gnu ranlib, ar (binutils 2.9 – 2.15)^ Y^ gdb – 6.x^ Y^ tcsh – Use this or you will have to translate some stuff^ Y^ emacs, vi, pico or whatever text editor you prefer^ Y^ Graph visualizing tools
»^ dot – http://www.research.att.com/sw/tools/graphviz Y TCL/TK – v8.0p2 or higher (tclsh, wish) »^ needed for Gui (I don’t recommend you use gui)
Installation – Step 1^ Y^ Source on the course webpage, trimaran.w06.tgz^ Y^ In your home directory, mkdir trimaran^ Y^ tar zxvf trimaran.w05.tgz
» Will create 6 subdirectories » openimpact, elcor, simu, scripts, benchmarks, gui Y Enviroment variables/path – this is critical! » trimaran/scripts/envrc – should have everything you need » Or, trimaran/scripts/envrc.bash for you bash users » Modify first line if you don’t put trimaran in$HOME/trimaran » Add to your .cshrc, source trimaran/scripts/envrc^ y^
So you don’t forget
Trimaran Overview
C source
Frontend – parsing, profiling function inlining, memory dep analysis. Also, does some backend stuff – region formation, optimization
Impact
Lcode – HPL_PD specific Lcode, aka bridge code
Backend – analysis, optimization, scheduling register allocation, code generation
Elcor
Rebel
Emulator – emulate VLIW semantics using C code – “compiled simulation”
Simu C emulation code
Running Trimaran^ Y^ Install trimaran, verify your code works on strcpy and wc^ Y^ Trimaran-gui – I don’t like/use this^ Y^ tcc – gcc equivalent, sorta!
»^ Command line way to invoke entire system – Gui calls this »^ “tcc –help” to get options »^ “tcc –bench strcpy” to run strcpy with basic blocks »^ Save output to examine Y trimaran/benchmarks »^ source, compile flags, link flags »^ input for profiling the code, output to check if ran properly »^ To add a new benchmark, follow the organization that is there
Control Flow^ Y^ Control transfer = branch (taken or fall-through)^ Y^ Control flow
»^ Branching behavior of an application »^ What sequences of instructions can be executed Y Execution
Æ^ Dynamic control flow
»^ Direction of a particular instance of a branch »^ Predict, speculate, squash, etc. Y Compiler
Æ^ Static control flow
»^ Not executing the program »^ Input not known, so what could happen Y Control flow analysis »^ Determining properties of the program branch structure »^ Determining instruction execution properties
Basic Block (BB)^ Y^ Group operations into units with equivalent executionconditions^ Y^ Defn: Basic block
- a sequence of consecutive operations
in which flow of control enters at the beginning andleaves at the end without halt or possibility of branchingexcept at the end^ »^ Straight-line sequence of instructions^ »^ If one operation is executed in a BB, they all are Y Finding BB’s^ »^ The first operation starts a BB^ »^ Any operation that is the target of a branch starts a BB^ »^ Any operation that immediately follows a branch starts a BB
Control Flow Graph (CFG)^ Y^ Defn Control Flow Graph
Directed graph, G = (V,E) whereeach vertex V is a basic blockand there is an edge E, v1 (BB1) Æ^ v2 (BB2) if BB2 canimmediately follow BB1 in someexecution sequence^ »^ A BB has an edge to all blocks itcan branch to^ »^ Standard representation used bymany compilers^ »^ Often have 2 pseudo vertices^ y
entry node y exit node
Entry^ BB1 BB2^ BB
BB
BB^
BB6 BB7 Exit
CFG Example
B1^ x = z – 2;^ y = 2 * z;^ if (c) B2 else B
x = z – 2; y = 2 * z; if (c) {^ x = x + 1;^ y = y + 1; } else {^ x = x – 1;^ y = y – 1; } z = x + y
then(taken) x = x + 1; y = y + 1; goto B
z = x + y
else(fallthrough)
B
B
x = x – 1; y = y – 1;
B
Dominator (DOM)^ Y^ Defn: Dominator
- Given a CFG(V, E, Entry, Exit), a
node x dominates a node y, if every path from the Entryblock to y contains x Y 3 properties of dominators^ »^ Each BB dominates itself^ »^ If x dominates y, and y dominates z, then x dominates z^ »^ If x dominates z and y dominates z, then either x dominates y ory dominates x Y Intuition^ »^ Given some BB, which blocks are guaranteed to have executedprior to executing the BB
Dominator Examples
BB
BB
BB3 BB
BB^
BB6 BB
Entry^ Exit
BB
BB
BB
Entry BB
BB1 BB6 BB7^ Exit
Immediate Dominator^ Y^ Defn: Immediate^ dominator
(idom)– Each
node n has a uniqueimmediate dominator mthat is the last dominatorof n on any path from theinitial node to n^ »^ Closest node thatdominates
Entry^ BB1 BB2^ BB
BB
BB^
BB6 BB7 Exit
Dominator Tree
BB^
DOM 1
1 2
1, 3
1, 4
1,
BB^
DOM 5
1,4, 6
1,4, 7
1,4,
First BB is the root node, each node dominates all of its descendants
BB
BB BB^
BB^
BB4 BB6BB
BB Dom tree
BB
BB3 BB
BB^
BB6 BB