1
play

1 Topics (cont) Loop Transformations VI. Parallelism and Locality - PowerPoint PPT Presentation

Final Review Questions to think about Today Possible big picture questions Overview of what we have learned so far For this class, which of the five criteria for evaluating optimizations have SSA review we used and how? (safety,


  1. Final Review Questions to think about Today Possible big picture questions – Overview of what we have learned so far – For this class, which of the five criteria for evaluating optimizations have – SSA review we used and how? (safety, profitability, opportunity, compile-time, – pointer and alias analysis implementation complexity) – interprocedural analysis and optimization – What is the scope of different analyses/optimizations that we have – loop transformations and Fourier-Motzkin studied? (peep hole, local, global, interprocedural) – affine partitionings for parallelism – Where could a representation for loops (polyhedral or presburger sets) fit – induction variable elimination review into the MiniJava compiler? – How would you design an experiment to compare a set of alias/pointer Studying analysis algorithms? – make sure to review terminology – (i.e. what does flow-sensitive mean?) – do lots of examples CS553 Lecture Final Review 1 CS553 Lecture Final Review 2 Structure of the MiniJava Compiler (CodeGenAssem.java) Topics I. Introduction Analysis Synthesis – Scanning and parsing character stream II. Compiling for OOP and Garbage Collection III. Low-Level Optimizations Lexer Translate lexical analysis IR code generation – Register allocation – Instruction scheduling tokens “words” IRT Tree/ IV. Data-Flow and Control-Flow Analysis and Optimization instruction selection Mips/Codegen Parser.parse() syntactic analysis – Dataflow analysis – Theoretic framework built on lattices AST “sentences” Assem – Control flow analysis: control-flow graphs, dominators, dominance frontiers, Project 4 irreducibility BuildSymTable semantic analysis optimization CheckTypes – Program optimizations: dead-code elimination, constant propagation, CSE, loop- Assem invariant code motion, copy propagation, PRE, induction variable elimination (*) CodeGenAssem V. Static Single Assignment (*) AST and symbol table code generation – SSA Form: types of data dependences, how to translate to minimal SSA minijava.node/ MIPS – global value numbering SymTable/ CS553 Lecture Final Review 3 CS553 Lecture Final Review 4 1

  2. Topics (cont) Loop Transformations VI. Parallelism and Locality (*) Original code – Dependence analysis do i = 1,6 – Loop transformations do j = 1,5 – unimodular transformation framework j A(i,j) = A(i-1,j+1)+1 i – Kelly and Pugh transformation framework enddo – Tiling and Unroll and Jam: when is tiling legal? enddo – Fourier Motzkin elimination for code generation – Affine partitionings for parallelism (1, -1) Distance vector: Which loop can we parallelize and why? IV. Interprocedural Analysis and Optimization (*) What transformation can enable parallelism? – Aliases – how do data-flow analysis algorithms use aliasing information? What is a synchronization-free affine partitioning for this loop? – how do we characterize alias analysis algorithms? – Interprocedural Analysis – how do different levels of context information affect analysis results? CS553 Lecture Final Review 5 CS553 Lecture Final Review 6 Synchronization-free parallelism SSA do i = 1 to N f = read() x = 3 do j = 0 to M y = 5 A(i,j) = A(i-1,j) if (f>6) z = 7 else z = 0 x = y - 2 print x+y+z CS553 Lecture Final Review 7 CS553 Lecture Final Review 8 2

  3. Induction Variable Elimination Jump Functions for Figure 12.11 in book i = 0 int id(int p) { return p; } j = 0 k = 0 if (a==1) { x = id(2); y=id(3); } loop: else { x = id(3); y=id(2); } i = i + 1 z = x+y; j = i*4 k = i+10 if i<10 goto loop exit: CS553 Lecture Final Review 9 CS553 Lecture Final Review 10 Alias/Pointer Analysis Example Example (Data dependence analysis main() { Sample code int *a,*b,c,d; do i = 1,6 a = &c; do j = 1,5 b = &d; A(2i,j) = A(i,j-1) foo(&a,&a); enddo foo(&b,&a); enddo } j void boo(int** x, int **y){ *x = *y; Dependence i **x = 3; – 2i 1 -i 2 = 0, j 1 = j 2 - 1, solution: YES } void foo(int** p, int **q){ Distance/Direction Vector boo(p,q); } – (i 1 , j 1 ) + (d i , d j ) = (i 2 , j 2 ), d j = 1, d i = ?, d = (<,1) Which analyses are relevant? FICI, FICS, FSCI, and/or FSCS Dependence Relation How do the analysis results differ based on a call stack size of 0, 1, or 2? – { [i, j] -> [2i, j +1 ]| 1<=i<=3 && 1<=j<=4 } CS553 Lecture Final Review 11 CS553 Lecture Final Review 12 3

  4. Tiling Sample code do i = 1,6 do j = 1,5 A(2i,j) = A(i,j-1) enddo enddo j Dependence Relation i – { [i, j] -> [2i, j +1 ]| 1<=i<=3 && 1<=j<=4 } Tiling Both Loops with tile size 4 – { [i, j] -> [(j-1)/4, (i-1)/4, i,j]} CS553 Lecture Final Review 13 4

Recommend


More recommend