Lecture 4: Program Tuning and Optimization
Background Material
- Reading assembly code (Chapter 3 of Bryant and O'Hallaron)
Reading
- Bryant and O'Hallaron (Chpt. 5)
- Bacon, Graham, and Sharp, Compiler Transformations for
High-Performance Computing, ACM Computing Surveys, Vol. 26, No. 4,
December 1994.
Topics
- Optimization blockers
- Pointers and aliasing
(see twiddle.c)
- Functions and side-effects
(see f.c)
- Machine Independent Optimizations
- Compiler optimizations: code movement, strength reduction,
common subexpression elimination, constant folding, register
allocation.
- Abstract vector class example.
- Moving function calls outside of loops.
- Removing access functions allows further optimization,
but exposes implementation.
- Accumulate into local variable to remove loads and allow
accumulation into register.
- Machine Dependent Optimizations
- Machine model with support for instruction level parallelism
(separate Instruction control and Execution units, data and
instruction cache, multiple functional units, register renaming
and the retirement unit, out of order execution, branch prediction
and speculative computation)
- Latency and issue time for functional units (pipelining).
- Translating instructions into operations. Simple renaming
convention and pictorial diagram to show instruction overlap
and dependencies.
- Instruction scheduling
- Loop unrolling.
- Loop splitting and introducing parallelism.
- Limits to parallelism - register spilling.
- Branch prediction and misprediction penalties.
Tasks
Compute CPE and CPI for vsum.c.
Compute CPE for the various versions of
Lecture Notes
- Lecture Notes from Bryant and O'Hallaron (Chpt. 5) on Machine Independent
Optimization - (class10.ppt,
class10.pdf)
- Lecture Notes from Bryant and O'Hallaron (Chpt. 5) on Machine Dependent
Optimization - (class11.ppt,
class11.pdf)
Programs
- counter.c -
access to cycle counter
- counter.h
- vsum.c - cycle counting example
- Pointers and aliasing
(see twiddle.c)
- Functions and side-effects (see f.c)
- Vector example and optimizations
(see vec.c)
Resources
Created: Sept. 27, 2006 by jjohnson@cs.drexel.edu