The Renaissance of Compiler Development Compiler optimizations motivated

  • Slides: 30
Download presentation
The Renaissance of Compiler Development Compiler optimizations motivated by embedded systems Tibor Gyimóthy University

The Renaissance of Compiler Development Compiler optimizations motivated by embedded systems Tibor Gyimóthy University of Szeged October 6, 2004. Software Technology Forum 1

Open Source Laboratory at the University of Szeged October 6, 2004. Software Technology Forum

Open Source Laboratory at the University of Szeged October 6, 2004. Software Technology Forum 2

Open Source Laboratory at the University of Szeged Beszédes Árpád Ferenc Rudolf Gergely Tamás

Open Source Laboratory at the University of Szeged Beszédes Árpád Ferenc Rudolf Gergely Tamás Gyimóthy Tibor Jász Judit Havasi Ferenc Kiss Ákos October 6, 2004. Lóki Gábor Patrik Kluba Siket István Siket Péter Sógor Zoltán Tóth Gábor Vidács László Software Technology Forum 3

The Dragon book October 6, 2004. Software Technology Forum 4

The Dragon book October 6, 2004. Software Technology Forum 4

Good quality compilers October 6, 2004. Software Technology Forum 5

Good quality compilers October 6, 2004. Software Technology Forum 5

New challenges: embedded processors October 6, 2004. Software Technology Forum 6

New challenges: embedded processors October 6, 2004. Software Technology Forum 6

Low energy computation System-wide optimizations are required for energy-saving. n Software design has significant

Low energy computation System-wide optimizations are required for energy-saving. n Software design has significant impact on the energy consumption of the processor. n Accurate energy models of the hardware modules are required for power analysis at system level. n October 6, 2004. Software Technology Forum 7

Low energy computation(cont. ) n n Instruction level optimizations include reordering instructions to reduce

Low energy computation(cont. ) n n Instruction level optimizations include reordering instructions to reduce switching, reduction of memory operands etc. The register relabeling technique reorders the register labels of the generated code. A sample trace and a power model are used to obtain new labels (The Pennsylvania State University). October 6, 2004. Software Technology Forum 8

Low energy computation(cont. ) n n n ARM is the most popular processor for

Low energy computation(cont. ) n n n ARM is the most popular processor for the embedded domain. The 32 bit ARM processor also supports the 16 bit Thumb instruction set. By using Thumb code the I-cache activity (energy) can be reduced. However, the restricted Thumb instruction set may lead to the loss in performance. Profile guided algorithms were proposed for generating mixed ARM and Thumb code (The University of Arizona) October 6, 2004. Software Technology Forum 9

Low energy computation(cont. ) n n n System-level power optimizing data-flow transformations are applied

Low energy computation(cont. ) n n n System-level power optimizing data-flow transformations are applied for multimedia applications(IMEC, Leuven, Belgium) Main aim is to reduce the power consumption due to data storage and transfers (significant part of the total power budget of the system). Performance and code size must be taken into account as well. October 6, 2004. Software Technology Forum 10

Low energy computation(cont. ) n n n Tradional compiler approaches focusing only on speed

Low energy computation(cont. ) n n n Tradional compiler approaches focusing only on speed are not sufficient for multimedia applications. The power cost model is linear with respect to the acces frequency and the dependence on the memory size is determined by a polynomial function. Code transformations are applied to the original source code (C). The method reduces the size of the array signals and the acceses to array signals. Very large power savings can be achived without introducing significant performance penalties. October 6, 2004. Software Technology Forum 11

Low energy computation(cont. ) n Closely related to the code size reduction ¨ Executing

Low energy computation(cont. ) n Closely related to the code size reduction ¨ Executing fewer instructions ¨ Accessing external memory less frequently Agressive code size optimization techniques n Post-link time optimizations n October 6, 2004. Software Technology Forum 12

Code size reductions in GCC A survey paper in ACM Computing Surveys, 2003 n

Code size reductions in GCC A survey paper in ACM Computing Surveys, 2003 n Magic switches & patches n Local factoring n Sequence abstraction n CSi. BE- Code Size Benchmark n GCC improvement for Symbian n October 6, 2004. Software Technology Forum 13

Magic switches & patches Function inlining n Tree-to-rtl extension n Optimizing large jump tables

Magic switches & patches Function inlining n Tree-to-rtl extension n Optimizing large jump tables n Extending move and compare parallelization n Crossjumping cleanup n October 6, 2004. Software Technology Forum 14

Local factoring n Code motion techniques ¨ Strategy: n n Move identical instructions from

Local factoring n Code motion techniques ¨ Strategy: n n Move identical instructions from basic blocks to their common predecessor and successor Data and register dependence must not be altered ¨ Implemented: n Code hoisting ¨ n Code sinking ¨ October 6, 2004. moving the code to an earlier place in the execution path moving the code to a later execution place Software Technology Forum 15

Code Hoisting October 6, 2004. Software Technology Forum 16

Code Hoisting October 6, 2004. Software Technology Forum 16

Code sinking October 6, 2004. Software Technology Forum 17

Code sinking October 6, 2004. Software Technology Forum 17

Sequence abstraction n Sequence Abstraction ¨ Works on SESE code fragments ¨ Strategy: n

Sequence abstraction n Sequence Abstraction ¨ Works on SESE code fragments ¨ Strategy: n n October 6, 2004. Find region of identical instructions which can be turned into procedures Replace all occurrences with calls to the newly created subroutine Software Technology Forum 18

Sequence abstraction(cont) October 6, 2004. Software Technology Forum 19

Sequence abstraction(cont) October 6, 2004. Software Technology Forum 19

Sequence abstraction ¨ RTL implementation: Compilation unit: function n No need to create a

Sequence abstraction ¨ RTL implementation: Compilation unit: function n No need to create a procedure, create only a call to a labelled representative code region n October 6, 2004. Software Technology Forum 20

CSi. BE-GCC Code Size Benchmark n n n www. inf. u-szeged. hu/CSi. BE Introduced

CSi. BE-GCC Code Size Benchmark n n n www. inf. u-szeged. hu/CSi. BE Introduced in 2003 ‘de facto’ a standard size benchmark for GCC Continuous monitoring the impact of the new patches on the code size New version: compilation time and performance More and more GCC developers are using CSi. BE in their daily work October 6, 2004. Software Technology Forum 21

CSi. BE(cont) October 6, 2004. Software Technology Forum 22

CSi. BE(cont) October 6, 2004. Software Technology Forum 22

CSi. BE(cont) October 6, 2004. Software Technology Forum 23

CSi. BE(cont) October 6, 2004. Software Technology Forum 23

CSi. BE(cont) October 6, 2004. Software Technology Forum 24

CSi. BE(cont) October 6, 2004. Software Technology Forum 24

Overall tendency of the code size 1. 3% 4. 3% 5. 1% 7. 2%

Overall tendency of the code size 1. 3% 4. 3% 5. 1% 7. 2% October 6, 2004. Software Technology Forum 25

GCC improvement for Symbian The official Symbian build is based on GCC 2. 9,

GCC improvement for Symbian The official Symbian build is based on GCC 2. 9, from the year 1998. n The GCC 2. 95. 3 was extended to support the Symbian target. n The modified compiler reduces the code size and improves the performance as well (5 -10%). n October 6, 2004. Software Technology Forum 26

Post-link time optimization n n Interprocedural versions of the classical compiler optimization techniques are

Post-link time optimization n n Interprocedural versions of the classical compiler optimization techniques are used for binary-rewriting of machine code(whole system optimization, Squeeze—Debray et al, ATOM—Univ. of Szeged). Techniques: ¨ ¨ ¨ ¨ Interprocedural control flow analysis, constant propagation, register liveness analysis Redundant code-elimination Unreachable-code elimination Dead-code elimination Strength-code elimination Local factoring Procedural abstraction October 6, 2004. Software Technology Forum 27

Some open issues in the GCC development There is a need for effective size

Some open issues in the GCC development There is a need for effective size optimization methods on Tree-SSA level. n The sequence abstraction approach can be extended to the unit-at time level. n The post-link time optimization methods can be integrated into GCC. n October 6, 2004. Software Technology Forum 28

Conclusions Open source software is widely used in the industry n There is a

Conclusions Open source software is widely used in the industry n There is a need for machine–level programmers n Challenge: many people will use their programs n October 6, 2004. Software Technology Forum 29

Effective compilers for embedded processors October 6, 2004. Software Technology Forum 30

Effective compilers for embedded processors October 6, 2004. Software Technology Forum 30