9
UNIVERSITY NIVERSITY OF OF D DELAWARE ELAWARE C COMPUTER & OMPUTER & INFORMATION NFORMATION SCIENCES CIENCES DEPARTMENT EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization John Cavazos University of Delaware

Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

Embed Size (px)

DESCRIPTION

Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization. John Cavazos University of Delaware. Feedback-Directed Optimization (FDO). Exploit information gathered at run-time to optimize execution “selective optimization”: what to optimize “FDO” : how to optimize. - PowerPoint PPT Presentation

Citation preview

Page 1: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Optimizing CompilersCISC 673

Spring 2009

Feedback Directed Optimization

John CavazosUniversity of Delaware

Page 2: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Feedback-Directed Optimization (FDO)

Exploit information gathered at run-time to optimize execution “selective optimization”: what to

optimize “FDO” : how to optimize

Page 3: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Advantages of FDO Can exploit dynamic information

that cannot be inferred statically

System can change and revert decisions when conditions change

Runtime binding allows more flexible systems

Page 4: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Challenges for automatic online FDO

Compensate for profiling overhead

Compensate for runtime transformation overhead

Account for partial profile available and changing conditions

Page 5: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Clients of Profiling Information

Inlining, unrolling, method dispatch Dispatch tables, Garbage

Collection Pretching

Misses, Hardware performance monitors [Adl-Tabatabai et al.’04]

Code layout

Page 6: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Code Layout Motivation Instruction memory critical to program

performance Cache line conflicts are one cause of misses Particularly for direct-mapped caches Page faults

Default code layout for most compilers is bad Instructions placed in source order Procedures placed according to source file

listing Compilers can rearrange code to reduce

misses More performance and less power for free

Page 7: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Procedure Positioning

“Closest is best” strategy: if procedure calls another frequently, we want two procedures close to one another. Increases chances they will land on the same page, reducing working set.

Construct a weighted call graph Node = procedure Edge from A B means procedure A calls B (perhaps

multiple times) Weight on edge is the total number of dynamic calls

Using the weighted call graph to build the link order for the procedures

Page 8: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Example Call Graph

Page 9: Optimizing Compilers CISC 673 Spring 2009 Feedback Directed Optimization

UUNIVERSITYNIVERSITY OFOF D DELAWARE ELAWARE • • C COMPUTER & OMPUTER & IINFORMATION NFORMATION SSCIENCES CIENCES DDEPARTMENTEPARTMENT

Merging Nodes

1) The heaviest weight edge is one connecting procedures A and D. They are merged. Edge weights are updated.

2) The next edge chosen is the one between C and F.