lecture 1cs 380c 1 380c last time –course organization –read backus et al. announcements –hadi...
TRANSCRIPT
![Page 1: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/1.jpg)
Lecture 1 CS 380C 1
380C
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?
![Page 2: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/2.jpg)
Lecture 1 CS 380C 2
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
![Page 3: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/3.jpg)
Lecture 1 CS 380C 3
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.
![Page 4: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/4.jpg)
Lecture 1 CS 380C 4
Aren’t compilers a solved problem?
“Optimization for scalar machines is a problem that was solved ten years ago.”
David Kuck, Fall 1990
![Page 5: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/5.jpg)
Lecture 1 CS 380C 5
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
![Page 6: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/6.jpg)
Lecture 1 CS 380C 6
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
![Page 7: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/7.jpg)
Lecture 1 CS 380C 7
Optimization
What should it do?
![Page 8: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/8.jpg)
Lecture 1 CS 380C 8
Optimization
What should it do?1. improve running time, or2. decrease space requirements3. decrease power consumption
How does it do it?
![Page 9: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/9.jpg)
Lecture 1 CS 380C 9
Analysis
Scope of program analysis1. within a basic block (local)2. within a method (global)3. across methods (interprocedural)
Analysis1. control flow graph - dominators, loops, etc.2. dataflow analysis - flow of values3. static-single-assignment – transform
programs such that each variable has a unique definition
4. alias analysis - pointer memory usage5. dependence analysis - array memory
usage
![Page 10: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/10.jpg)
Lecture 1 CS 380C 10
Example optimizations
Division of optimizations1. Machine independent2. Machine dependent
Faster code optimizations– common subexpression elimination– constant folding – dead code elimination– register allocation – scheduling – loop transformations
![Page 11: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/11.jpg)
Lecture 1 CS 380C 11
Basic Compiler Structure
Program Machinecode
Higher to lower level representations, analyses, & transformations
Structural inlining
unrollingloop perm
Scalar cse
constantsexpressions
Memory scalar repl
ptrs
Reg. Alloc
Scheduling peephole
![Page 12: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/12.jpg)
Lecture 1 CS 380C 12
Exciting times
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
CompilerProgrammer RuntimeCode Code
Specification Future behavior
Feedback H/S Profiling
![Page 13: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/13.jpg)
Lecture 1 CS 380C 13
Questions?
![Page 14: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/14.jpg)
Lecture 1 CS 380C 14
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).
![Page 15: Lecture 1CS 380C 1 380C Last Time –Course organization –Read Backus et al. Announcements –Hadi lab Q&A Wed 1-2 in Painter 5.38N –UT Texas Learning Center:](https://reader036.vdocuments.us/reader036/viewer/2022082709/56649d6e5503460f94a4f8f1/html5/thumbnails/15.jpg)
Lecture 1 CS 380C 15
Overview
Today– Introduction to
compilers
Next Time– program
representation – control flow– Read wiki--No
critique on wiki reading!