High Performance Embedded Computing © 2007 Elsevier Chapter 3, part 1: Programs High Performance Embedded Computing Wayne Wolf.

Slides:



Advertisements
Similar presentations
Optimizing Compilers for Modern Architectures Compiler Improvement of Register Usage Chapter 8, through Section 8.4.
Advertisements

© 2004 Wayne Wolf Topics Task-level partitioning. Hardware/software partitioning.  Bus-based systems.
Compiler Support for Superscalar Processors. Loop Unrolling Assumption: Standard five stage pipeline Empty cycles between instructions before the result.
Register Usage Keep as many values in registers as possible Register assignment Register allocation Popular techniques – Local vs. global – Graph coloring.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
1 Optimizing compilers Managing Cache Bercovici Sivan.
Optimizing Compilers for Modern Architectures Allen and Kennedy, Chapter 13 Compiling Array Assignments.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Parallelism & Locality Optimization.
Architecture-dependent optimizations Functional units, delay slots and dependency analysis.
CPE 731 Advanced Computer Architecture Instruction Level Parallelism Part I Dr. Gheith Abandah Adapted from the slides of Prof. David Patterson, University.
Computer Architecture Lecture 7 Compiler Considerations and Optimizations.
Instruction Level Parallelism María Jesús Garzarán University of Illinois at Urbana-Champaign.
POLITECNICO DI MILANO Parallelism in wonderland: are you ready to see how deep the rabbit hole goes? ILP: VLIW Architectures Marco D. Santambrogio:
EECC551 - Shaaban #1 Fall 2003 lec# Pipelining and Exploiting Instruction-Level Parallelism (ILP) Pipelining increases performance by overlapping.
1 COMP 740: Computer Architecture and Implementation Montek Singh Tue, Feb 24, 2009 Topic: Instruction-Level Parallelism IV (Software Approaches/Compiler.
Computer Architecture Instruction Level Parallelism Dr. Esam Al-Qaralleh.
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
Register Allocation CS 671 March 27, CS 671 – Spring Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
Compiler Challenges for High Performance Architectures
1 CS 201 Compiler Construction Lecture 12 Global Register Allocation.
Stanford University CS243 Winter 2006 Wei Li 1 Loop Transformations and Locality.
1 Handling nested procedures Method 1 : static (access) links –Reference to the frame of the lexically enclosing procedure –Static chains of such links.
Compiler Challenges, Introduction to Data Dependences Allen and Kennedy, Chapter 1, 2.
Compiler Optimizations for Memory Hierarchy Chapter 20 High Performance Compilers.
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
Introduction to Program Optimizations Chapter 11 Mooly Sagiv.
Data Partitioning for Reconfigurable Architectures with Distributed Block RAM Wenrui Gong Gang Wang Ryan Kastner Department of Electrical and Computer.
Storage Assignment during High-level Synthesis for Configurable Architectures Wenrui Gong Gang Wang Ryan Kastner Department of Electrical and Computer.
Chapter 13 Reduced Instruction Set Computers (RISC) Pipelining.
1 COMP 206: Computer Architecture and Implementation Montek Singh Wed., Oct. 30, 2002 Topic: Caches (contd.)
Improving Code Generation Honors Compilers April 16 th 2002.
Improving code generation. Better code generation requires greater context Over expressions: optimal ordering of subtrees Over basic blocks: Common subexpression.
High Performance Embedded Computing © 2007 Elsevier Lecture 11: Memory Optimizations Embedded Computing Systems Mikko Lipasti, adapted from M. Schulte.
Course Outline DayContents Day 1 Introduction Motivation, definitions, properties of embedded systems, outline of the current course How to specify embedded.
Optimizing Loop Performance for Clustered VLIW Architectures by Yi Qian (Texas Instruments) Co-authors: Steve Carr (Michigan Technological University)
Optimization software for apeNEXT Max Lukyanov,  apeNEXT : a VLIW architecture  Optimization basics  Software optimizer for apeNEXT  Current.
Introduction to Embedded Systems Rabie A. Ramadan 4.
Sub-expression elimination Logic expressions: –Performed by logic optimization. –Kernel-based methods. Arithmetic expressions: –Search isomorphic patterns.
1 Advance Computer Architecture CSE 8383 Ranya Alawadhi.
Chapter 8 CPU and Memory: Design, Implementation, and Enhancement The Architecture of Computer Hardware and Systems Software: An Information Technology.
Cleaning up the CFG Eliminating useless nodes & edges C OMP 512 Rice University Houston, Texas Fall 2003 Copyright 2003, Keith D. Cooper & Linda Torczon,
High-Level Transformations for Embedded Computing
6. A PPLICATION MAPPING 6.3 HW/SW partitioning 6.4 Mapping to heterogeneous multi-processors 1 6. Application mapping (part 2)
Crosscutting Issues: The Rôle of Compilers Architects must be aware of current compiler technology Compiler Architecture.
Introduction to Code Generation Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice.
High Performance Embedded Computing © 2007 Elsevier Chapter 7, part 3: Hardware/Software Co-Design High Performance Embedded Computing Wayne Wolf.
© 2004 Wayne Wolf Memory system optimizations Strictly software:  Effectively using the cache and partitioned memory. Hardware + software:  Scratch-pad.
CSCI1600: Embedded and Real Time Software Lecture 33: Worst Case Execution Time Steven Reiss, Fall 2015.
Register Allocation CS 471 November 12, CS 471 – Fall 2007 Register Allocation - Motivation Consider adding two numbers together: Advantages: Fewer.
High Performance Embedded Computing © 2007 Elsevier Lecture 10: Code Generation Embedded Computing Systems Michael Schulte Based on slides and textbook.
High Performance Embedded Computing © 2007 Elsevier Lecture 7: Memory Systems & Code Compression Embedded Computing Systems Mikko Lipasti, adapted from.
Memory-Aware Compilation Philip Sweany 10/20/2011.
High Performance Embedded Computing © 2007 Elsevier Chapter 3, part 1: Programs High Performance Embedded Computing Wayne Wolf.
Code Optimization Overview and Examples
Global Register Allocation Based on
Instruction Level Parallelism
Modeling of Digital Systems
5.2 Eleven Advanced Optimizations of Cache Performance
CSCI1600: Embedded and Real Time Software
Performance Optimization for Embedded Software
Introduction to Code Generation
Register Pressure Guided Unroll-and-Jam
Reiley Jeyapaul and Aviral Shrivastava Compiler-Microarchitecture Lab
Spring 2008 CSE 591 Compilers for Embedded Systems
Lecture 17: Register Allocation via Graph Colouring
Parallel Programming in C with MPI and OpenMP
CSCI1600: Embedded and Real Time Software
CS 201 Compiler Construction
Presentation transcript:

High Performance Embedded Computing © 2007 Elsevier Chapter 3, part 1: Programs High Performance Embedded Computing Wayne Wolf

© 2006 Elsevier Topics Code generation and back-end compilation. Memory-oriented software optimizations.

© 2006 Elsevier Embedded vs. general-purpose compilers General-purpose compilers must generate code for a wide range of programs:  No real-time requirements.  Often no explicit low-power requirements.  Generally want fast compilation times. Embedded compilers must meet real-time, low-power requirements.  May be willing to wait longer for compilation results.

© 2006 Elsevier Code generation steps Instruction selection chooses opcodes, modes. Register allocation binds values to registers.  Many DSPs and ASIPs have irregular register sets. Address generation selects addressing mode, registers, etc. Instruction scheduling is important for pipelining and parallelism.

© 2006 Elsevier twig model for instruction selection twig models instructions, programs as graphs. Covers program graph with instruction graph.  Covering can be driven by costs.

© 2006 Elsevier twig instruction models Rewriting rule:  replacement<- template {cost} = action Dynamic programming can be used to cover program with instructions for tree- structured instructions.  Must use heuristics for more general instructions.

© 2006 Elsevier ASIP instruction description PEAS-III describes pipeline resources used by an instruction. Leupers and Marwedel model instructions as register transfers and NOPs. Register transfers are executed under conditions.

© 2006 Elsevier Register allocation and lifetimes

© 2006 Elsevier Clique covering Cliques in graph describe registers.  Clique: every pair of vertices is connected by an edge. Cliques should be maximal. Clique covering performed by graph coloring heuristics.

© 2006 Elsevier VLIW register files VLIW register sets are often partitioned.  Values must be explicitly copied. Jacome and de Veciana divide program into windows:  Window start and stop, data path resource, set of activities bound to that resource within the time range. Construct basic windows, then aggregated windows. Schedule aggregated windows while propagating delays.

© 2006 Elsevier FlexWare instruction definition [Lie94] © 1994 IEEE

© 2006 Elsevier Other techniques PEAS-III categorizes instructions: arithmetic/logic, control, load/store, stack, special.  Compiler traces resource utilization, calculates latency and throughput. Mesman et al. modeled code scheduling constraints with constraint graph.  Model data dependencies, multicycle ops, etc.  Solve system by adding some edges to fix some operation times.

© 2006 Elsevier Araujo and Malik Optimal selection/ allocation/ scheduling algorithm for limited architecture---location can have either one or unbounded number available. Use a tree-grammar paerser to select instructions and allocate registers; use O(n) algorithm to schedule instructions. [Ara95] © 1995 IEEE

© 2006 Elsevier Araujo and Malik algorithm [Ara95] © 1995 IEEE

© 2006 Elsevier Code placement Place code to minimize cache conflicts. Possible cache conflicts may be determined using addresses; interesting conflicts are determined through analysis. May require blank areas in program.

© 2006 Elsevier Hwu and Chang Analyzed traces to find relative execution times. Inline expanded infrequently used subroutines. Placed frequently-used traces using greedy algorithm.

© 2006 Elsevier McFarling Analyzed program structure, trace information. Annotated program with loop execution count, basic block size, procedure call frequency. Walked through program to propagate labels, group code based on labels, place code groups to minimize interference.

© 2006 Elsevier McFarling procedure inlining Estimated number of cache misses in a loop:  s l = effective loop body size.  s b = basic block size.  f = average execution frequency of block.  M l = number of misses per loop instance.  l = average number of loop iterations.  S = cache size. Estimated new cache miss rate for inlining; used greedy algorithm to select functions to inline.

© 2006 Elsevier Pettis and Hansen Profiled programs using gprof. Put caller and callee close together in the program, increasing the chance they would be on the same page. Ordered procedures using call graph, weighted by number of invocations, merging highly-weighted edges. Optimized if-then-else code to take advantage of the processor’s branch prediction mechanism. Identified basic blocks that were not executed by given input data; moved to separate processes to improve cache behavior.

© 2006 Elsevier Tomiyama and Yasuura Formulated trace placement as an integer linear programming. Basic method increased code size. Improved method combined traces to create merged traces that fit evenly into cache lines.

© 2006 Elsevier FlexWare programming environment [Pau02] © 2002 IEEE

© 2006 Elsevier Memory-oriented optimizations Memory is a key bottleneck in many embedded systems. Memory usage can be optimized at any level of the memory hierarchy. Can target data or instructions. Global flow analysis can be particularly useful.

© 2006 Elsevier Loop transformations Data dependencies may be within or between loop iterations. A loop nest has loops enclosed by other loops. A perfect loop nest has no conditional statements.

© 2006 Elsevier Types of loop transformations Loop permutation changes order of loops. Index rewriting changes the form of the loop indexes. Loop unrolling copies the loop body. Loop splitting creates separate loops for operations in the loop body. Loop merging combines loop bodies. Loop padding adds data elements to change cache characteristics.

© 2006 Elsevier Polytope model Loop transformations can be modeled as matrix operations:

© 2006 Elsevier Loop permutation and fusion

© 2006 Elsevier Kandemir et al. loop energy experiments [Kan00] © 2000 ACM Press

© 2006 Elsevier Java transformations Real-Time Specification for Java (RTSJ) specifies Java for real time:  Scheduling: requires fixed-priority scheduler with at least 28 priorities.  Memory management: allows program to operate outside the heap.  Synchronization: additional mechanisms.

© 2006 Elsevier Optimizing compiler flow (Bacon et al.) Procedure restructuring inlines functions, eliminates tail recursion, etc. High-level data flow optimization reduces operator strength, moves loop-invariant code, etc. Partial evaluation simplifies algebra, computes constants, etc. Loop preparation peels loops, etc. Loop reordering interchanges, skews, etc.

© 2006 Elsevier Catthoor et al. methodology Memory-oriented data flow analysis and model extraction. Global data flow transformations. Global loop and control flow optimizations. Data reuse decisions for memory hierarchy. Memory organization. In-place optimization.

© 2006 Elsevier Buffer management Excessive dynamic memory management wastes cycles, energy with no functional improvements. IMEC: analyze code to understand data transfer requirements, balance concerns across program. Panda et al.: loop transformations can improve buffer utilization. Before: for (i=0; i<N; ++i) for (j=0; j<N-L; ++j) b[i][j] = 0; for (i=0; i<N; ++i) for (j=0; j<N-L; ++j) for (k=0; k<L; ++k) b[i][j] = a[i][j+k]; After: for (i=0; i<N; ++i) for (j=0; j<N-L; ++j) b[i][j] = 0; for (k=0; k<L; ++k) b[i][j] = a[i][j+k]; closer

© 2006 Elsevier Cache optimizations Strategies:  Move data to reduce the number of conflicts.  Move data to take advantage of prefetching. Need:  Load map.  Information on access frequencies.

© 2006 Elsevier Cache data placement Panda et al.: place data to reduce cache conflicts. 1. Build closeness graph for accesses. 2. Cluster variables into cache-line sized units. 3. Build a cluster interference graph. 4. Use interference graph to optimize placement. [Pan97] © 1997 ACM Press

© 2006 Elsevier Array placement Panda et al.: improve conflict test to handle arrays. Given addresses X, Y. Cache line size k holding M words. Formulas for X and Y overlapping:

© 2006 Elsevier Array assignment algorithm [Pan97] © 1997 IEEE

© 2006 Elsevier Data and loop transformations Kandemir et al.: combine data and loop transformations to optimize cache performance. Transform loop nest to make the innermost index as the only array element in one array dimension (unused in other dimensions). Align references to the right side to conform to the left side. Search right-side transformations to choose best one.

© 2006 Elsevier Scratch pad optimizations Panda et al.: assign scalars statically, analyze cache conflicts to choose between scratch pad, cache. VAC(u): variable access count. IAC(u): interference access count. IF(u): total interference count VAC(u) + IAC(u). LCF(u): loop conflict factor. TCF(u): total conflict factor.

© 2006 Elsevier Scratch pad allocation formulation AD( c ): access density.

© 2006 Elsevier Scratch pad allocaiton algorithm [Pan00] © 2000 ACM Press

© 2006 Elsevier Scratch pad allocation performance [Pan00] © 2000 ACM Press

© 2006 Elsevier Main memory-oriented optimizations Memory chips provide several useful modes:  Burst mode accesses sequential locations.  Paged modes allow only part of the address to be transmitted.  Banked memories allow parallel accesses. Access times depend on address(es) being accessed.