lecture14 - CIS 450 Computer Architecture and Organization...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CIS 450 Computer Architecture and Organization Lecture 14: Code Optimization I Mitch Neilsen Mitch Neilsen [email protected] [email protected] 219D Nichols Hall 219D Nichols Hall – 2 – Topics Topics Machine-Independent Optimizations ¡ Basic optimizations ¡ Optimization blockers – 3 – Harsh Reality Harsh Reality There There ’s more to performance than asymptotic complexity s more to performance than asymptotic complexity Constant factors matter too! Constant factors matter too! ¡ Easily see 10:1 performance range depending on how code is written ¡ Must optimize at multiple levels: z algorithm, data representations, procedures, and loops Must understand system to optimize performance Must understand system to optimize performance ¡ How programs are compiled and executed ¡ How to measure program performance and identify bottlenecks ¡ How to improve performance without destroying code modularity and generality – 4 – Optimizing Compilers Optimizing Compilers Provide efficient mapping of program to machine Provide efficient mapping of program to machine ¡ register allocation ¡ code selection and ordering (scheduling) ¡ dead code elimination ¡ eliminating minor inefficiencies Don Don ’t (usually) improve asymptotic efficiency t (usually) improve asymptotic efficiency ¡ up to programmer to select best overall algorithm ¡ big-O savings are (often) more important than constant factors z but constant factors also matter Have difficulty overcoming Have difficulty overcoming “optimization blockers optimization blockers ” ¡ potential memory aliasing ¡ potential procedure side-effects – 5 – Limitations of Optimizing Compilers Limitations of Optimizing Compilers Operate under fundamental constraint Operate under fundamental constraint ¡ Must not cause any change in program behavior under any possible condition ¡ Often prevents it from making optimizations when would only affect behavior under pathological conditions. Behavior that may be obvious to the programmer can be Behavior that may be obvious to the programmer can be obfuscated by languages and coding styles obfuscated by languages and coding styles ¡ e.g., Data ranges may be more limited than variable types suggest Most analysis is performed only within procedures Most analysis is performed only within procedures ¡ Whole-program analysis is too expensive in most cases Most analysis is based only on Most analysis is based only on static static information information ¡ Compiler has difficulty anticipating run-time inputs When in doubt, the compiler must be conservative When in doubt, the compiler must be conservative – 6 –...
View Full Document

This note was uploaded on 04/09/2008 for the course CIS 450 taught by Professor Neilsen,mitch during the Spring '08 term at Kansas State University.

Page1 / 22

lecture14 - CIS 450 Computer Architecture and Organization...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online