150 likes | 301 Views
Last Time Course organization Read Backus et al. Announcements Hadi lab Q&A Wed 1-2 in Painter 5.38N UT Texas Learning Center: 5 hours of free writing consultation, $13per hour. Today Questions on course organization? What’s a compiler? How does it work?. 380C. What is a compiler? .
E N D
Last Time Course organization Read Backus et al. Announcements Hadi lab Q&A Wed 1-2 in Painter 5.38N UT Texas Learning Center: 5 hours of free writing consultation, $13per hour Today Questions on course organization? What’s a compiler? How does it work? 380C CS 380C
What is a compiler? • A program that translates a program in one language to another language • The essential interface between applications & architectures • Typically lowers the level of abstraction • analyzes and reasons about the program & architecture • We expect the program to be optimized, i.e., better than the original • ideally exploiting architectural strengths and hiding weaknesses CS 380C
When should we compile? Ahead-of-time: before you run the program Offline profiling: compile several times compile/run/profile.... then run again Just-in-time: while you run the program required for dynamic class loading, i.e., Java, Python, etc. CS 380C
Aren’t compilers a solved problem? “Optimization for scalar machines is a problem that was solved ten years ago.” David Kuck, Fall 1990 CS 380C
Aren’t compilers a solved problem? “Optimization for scalar machines is a problem that was solved ten years ago.” David Kuck, Fall 1990 • Architectures keep changing • Languages keep changing • Applications keep changing - SPEC CPU? • When to compile keeps changing CS 380C
Role of compilers Bridge complexity and evolution in architecture, languages, & applications Help programmers with correctness, reliability, program understanding Compiler optimizations can significantly improve performance • 1 to 10x on conventional processors Performance stability:one line change can dramatically alter performance • unfortunate, but true CS 380C
Optimization What should it do? CS 380C
Optimization What should it do? • improve running time, or • decrease space requirements • decrease power consumption How does it do it? CS 380C
Analysis Scope of program analysis • within a basic block (local) • within a method (global) • across methods (interprocedural) Analysis • control flow graph - dominators, loops, etc. • dataflow analysis - flow of values • static-single-assignment – transform programs such that each variable has a unique definition • alias analysis - pointer memory usage • dependence analysis - array memory usage CS 380C
Example optimizations Division of optimizations • Machine independent • Machine dependent Faster code optimizations • common subexpression elimination • constant folding • dead code elimination • register allocation • scheduling • loop transformations CS 380C
Basic Compiler Structure Higher to lower level representations, analyses, & transformations Machine code Program Structural inlining unrolling loop perm Scalar cse constants expressions Memory scalar repl ptrs Reg. Alloc Scheduling peephole CS 380C
Exciting times Compiler New and changing architectures • Hitting the microprocessor wall • multicore, tiled architectures, tiled memory systems Object-oriented languages becoming dominant paradigm • Java and C# coming to your OS soon - Jnode, Singularity • Security and reliability, ease of programming Key challenges and approaches • Latency & parallelism still key to performance • Language & runtime implementation efficiency • Orchestrating a new software/hardware dance • Break down artificial system boundaries Feedback H/S Profiling Programmer Code Code Runtime Specification Future behavior CS 380C
Questions? CS 380C
Programming Assignment #1 • 380C Lab 1 • Due: Friday 9/11 5pm • Translate from 3 address code to C • We provide a high-level language: • SC: a C-Subset that has functions, recursion, one type of integer (long==8 bytes), arrays, structs, no floating point, no pointers, etc. • We provide “csc” a C-subset compiler that translates from SC to valid 3 address code • You translate it back to C code • Hadi will be available for Q&A Wednesday 9/2 1-2pm (special location). CS 380C
Today Introduction to compilers Next Time program representation control flow Read wiki--No critique on wiki reading! Overview CS 380C