Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes CS101 (CS)

Rating
-
Sold
-
Pages
57
Uploaded on
05-03-2025
Written in
2022/2023

It is best to know about the automata solution problems

Institution
Course

Content preview

15-213
“The course that gives CMU its
Zip!”

Code Optimization
Sept. 25, 2003

Topics
■ Machine-Independent Optimizations
■ Machine Dependent Optimizations
■ Code Profiling




class10.ppt

, Harsh Reality
There’s more to performance than asymptotic complexity


Constant factors matter too!
■ Easily see 10:1 performance range depending on how code is
written
■ Must optimize at multiple levels:
● algorithm, data representations, procedures, and loops

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

15-213,
–2– F’03

,Limitations of Optimizing Compilers
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
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
■ Whole-program analysis is too expensive in most cases
Most analysis is based only on static information
■ Compiler has difficulty anticipating run-time inputs


When in doubt, the compiler must be conservative

15-213,
–3– F’03

, Machine-Independent
Optimizations
Optimizations that you or compiler should do
regardless of processor / compiler


Code Motion
■ Reduce frequency with which computation performed
● If it will always produce same result
● Especially moving code out of loop


for (i = 0; i < n; i++) {
for (i = 0; i < n; i++) int ni = n*i;
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
a[n*i + j] = b[j]; a[ni + j] = b[j];
}



15-213,
–4– F’03

Written for

Institution
Course

Document information

Uploaded on
March 5, 2025
Number of pages
57
Written in
2022/2023
Type
Class notes
Professor(s)
Pinky
Contains
All classes

Subjects

$7.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
teddybear2

Get to know the seller

Seller avatar
teddybear2 Sri Ramakrishna Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions