




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This document, based on a lecture by prof. Bill pugh from the university of maryland, college park, discusses the importance of compiler optimization research. It covers reasons for studying compiler optimization, the impact of economics, proebsting's law, and todd's justification. The document also explores optimizations for specfp, specint, and java benchmarks, benefits from compiler optimization, and future directions in compiler optimization research.
Typology: Study notes
1 / 8
This page cannot be seen from the preview
Don't miss anything!





CMSC 430, Lecture 18 2
0 Why study compiler optimization?
0 Hardware improving at much faster rate 0 Compiler optimizations are not implemented in commercial compilers, anyway
Java Perl
Cobol Fortran LISP
Unix Windows NT
Unix Windows 3.
Unix DOS
1 Ghz Pentium 256 Mb DRAM 100 Mb Ethernet WWW
33 Mhz x 32 Mb DRAM 10 Mb Ethernet Internet
8 Mhz 8088 4 Mb DRAM Modem USENET
Hardware
Operating Systems
Programming Languages
0 Few new optimizations implemented in commercial compilers
0 Expensive to build & maintain
0 Many interesting 0 Most narrowly applicable 0 General purpose compilers l Cannot justify expense 0 Custom compilers l Too expensive to write
CMSC 430, Lecture 18 5
3) Proebsting’s Law
0 Chip density doubles every 18 months 0 Often reflected in CPU power doubling every 18 months
0 Compiler technology doubles CPU power every 18 years
0 1 year of code optimization research = 1 month of hardware improvement 0 No further need for compiler optimization research 0 Just wait a few months… CMSC 430, Lecture 18 6
Todd’s Justification for Proebsting’s Law
0 4x performance improvement from optimizations 0 Compiler technology represents 36 years of progress
0 Compiler technology doubles CPU power every 18 years 0 Improvement = 4% a year
Checking Justification for Proebsting’s Law
0 Numeric Fortran code DEC SPEC results (optimized) vs GNU f77 –O0 (unoptimized) 0 Integer C code DEC SPEC results (optimized) vs DEC cc –O0 (unoptimized)
0 Jalapeno (optimized) vs Jalapeno (unoptimized)
Optimizations for SPECfp Benchmarks
Speedup
Scott 2001
CMSC 430, Lecture 18 13
Compiler Optimization Research
0 Take existing C / Fortran benchmarks (e.g., SPEC 95) 0 Apply complex, expensive program analyses / transformations l Automatic parallelization for multithreaded processors using interprocedural context-sensitive whole-path alias analysis of complex pointer-based data structures 0 Targeting existing RISC / x86 microprocessors
0 For current languages / applications / architectures 0 Too much work, not enough improvement
CMSC 430, Lecture 18 14
Importance of Performance
0 Time to market 0 Maintainability 0 Reliability 0 Safety / security
Compiler Optimization Research
0 I.e., closer to 4% / month (processor) than 4% / year (compiler)
Overview
CMSC 430, Lecture 18 17
1) Targeting HPC Applications
0 Computational science 0 Simulation using numerical models (molecules to galaxies) 0 Precision depends on computation power
0 Techniques may not be economical for general compiler 0 May produce programming tool instead of compiler
CMSC 430, Lecture 18 18
2) Exploiting New Architectural Features
0 Chip density doubles every 18 months
0 Smaller gate size = faster switching speed 0 Smaller chip = less wire delay
Exploiting New Architectural Features
0 Extra transistors = more processor features
0 Larger on-chip caches 0 Vector operations 0 Long instruction words (VLIW) 0 Out-of-order execution 0 Branch prediction 0 Value prediction 0 Predicated instructions 0 Multithreading 0 Speculative threads 0 Prefetching
Exploiting New Architectural Features
0 On-chip caches → locality optimizations 0 Vector operations → automatic vectorization 0 Long instruction words (VLIW) → instruction scheduling 0 Out-of-order execution → instruction scheduling 0 Predicated instructions → control dependence analysis 0 Multithreading → automatic parallelization 0 Speculative threads → dependence analysis 0 Prefetching → software prefetching
CMSC 430, Lecture 18 25
0
500
1000
1500
2000
2500
3000
3500
198819891990199119921993199419951996199719981999200020012002 Year
Speed (Mhz)
Processor Clock Memory Bus Clock
Processor vs. Memory Speed (Latency)
x386x486 x486 DX2Pentiumx486 DX4Pentium ProPentium IIP II MMXP IIIP 4 P 4 FPM DRAM (420 ns) EDO DRAM (300 ns)SDRAM (200 ns)DDR-DRAM (200 ns)
CMSC 430, Lecture 18 26
1
10
100
1000
10000
198819891990199119921993199419951996199719981999200020012002 Year
Speed (Mhz)
Processor Clock Memory Bus Clock
Processor vs. Memory Speed (log scale)
x386x486 x486 DX2Pentiumx486 DX4Pentium ProPentium IIP II MMXP IIIP 4 P 4 FPM DRAM EDO DRAMSDRAM DDR-DRAM
3) Improving Programmer Productivity
0 How can compiler optimization research help?
0 Discourage manual optimizations 0 Encourage high-level languages 0 Reduce cost of l High-level language constructs l Error-checking / security 0 Provide / exploit user feedback
Improving Productivity – Reduce Manual Opts.
0 “Register” variable declarations 0 Write compact, dense code 0 Unroll loops by hand
0 Code hard to understand and maintain 0 More difficult to optimize 0 May even introduce errors
0 Handle simple cases, remove temptation
CMSC 430, Lecture 18 29
Improving Productivity – High-Level Languages
0 Use assembly code instead of C 0 Use C instead of C++ 0 Use C++ instead of Java 0 Use MPI instead of HPF
0 Low-level programming generally less productive 0 May even introduce errors l Malloc / free vs. garbage collection l Arbitrary pointer arithmetic vs. multidimensional arrays l Arbitrary type casting vs. safe types l Message deadlock in message-passing programs
CMSC 430, Lecture 18 30
Improving Productivity – High-Level Languages
0 Reduce penalty for high-level language constructs l Type safety l Objects l Inheritance l Abstract data types l Parametric polymorphism 0 Many of these features are already in Java compilers
l Exceptions l Tagged unions l Garbage collection l Higher-order functions l Parameterized typedefs
CMSC 430, Lecture 18 31
High-Level Languages – Intel cc vs GNU gcc
SPECint 2000, 2.2 Ghz Intel Xeon [Mehis+ 2002] (^) CMSC 430, Lecture 18 32
Summary
0 But not by doing the same thing for the next 18 years
0 High performance computing applications 0 Exploiting new processor architectural features 0 Improving programmer productivity
0 Only care about performance if improvement >> 4% / year 0 If narrowly applicable, may produce programming tool instead of compiler