Download presentation
Presentation is loading. Please wait.
1
Computer Science 313 – Advanced Programming Topics
2
Tom Cargill The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
3
Let’s Get Coding Who will write next lab in assembly? Can only use assembly code for entire lab pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)
4
Let’s Get Coding Who will write next lab in assembly? Can only use assembly code for entire lab During the first pass, apply standard optimizations pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)
5
Let’s Get Coding Who will write next lab in assembly? Can only use assembly code for entire lab During the first pass, apply standard optimizations Every method should be tuned to maximize branches pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)
6
Let’s Get Coding Who will write next lab in assembly? Can only use assembly code for entire lab During the first pass, apply standard optimizations Every method should be tuned to maximize branches Necessary to achieve top performance pushl %ebp movl %esp, %ebp subl $24, %esp movl 8(%ebp), %eax movl %eax, -4(%ebp) cmpl $0, -4(%ebp)
7
Promise of Perfect Debugging Programs just λ-calculus equations Use Java, but instead prove program correct Translate program into λ-calculus Specify theorem & prove program correctness
8
Fewest Lectures Ever
10
Why Isn’t This Done? Almost never use these techniques Low-level device drivers use some C (or similar) Rare for partial proof of correctness to be used Simple result from easy cost-benefit analysis Techniques requires massive amounts of time Time is money; these are very, very expensive The provided benefits just not worth it
11
What’s The Secret? How do I know when to optimize? I need to know. Please, please, please?
12
Problem is Universal Frequent need to make optimal decision Using reagents during chemical synthesis Take power plant offline & perform maintenance Fastest torrent from which to download Cannot optimize everything Instead we only focus efforts where it matters
13
Problem is Universal Frequent need to make optimal decision Using reagents during chemical synthesis Take power plant offline & perform maintenance Fastest torrent from which to download Cannot optimize everything Instead we only focus efforts where it matters But how can I know what is important?
14
Are Graphics Important? Rewrite Swing to improve its performance?
15
Are Graphics Important? Rewrite Swing to improve its performance? Hells, yes. We need 60 fps for new games.
16
Are Graphics Important? Rewrite Swing to improve its performance? Hells, yes. We need 60 fps for new games. %#$ no. What does it do for search speed?
17
Critical Paths All that is important is code along critical path Determines time needed and not just the fluff Graphics are not critical for Google Major graphics improvements are nice… …but have zero affect on search times Bungie’s critical path is graphics package Games performance limited by graphic times Would hate GPU for search – slows them down
18
Guess the Critical Path $ java -Xprof edu.canisius.ann.Network Flat profile of 16.4 secs (956 total ticks): main Compiled + native Method 35.6% 282 + 58 Neuron.getWeightedError 21.1% 187 + 15 Neuron.updateWeights 13.0% 124 + 0 Network.trainNetwork 9.5% 0 + 91 java.lang.StrictMath.exp 9.5% 91 + 0 Neuron.compute 4.5% 22 + 21 Network.setNetworkInput 3.6% 34 + 0 Network.runOneInput 2.0% 0 + 19 java.util.ArrayList. 0.8% 8 + 0 Network.main 99.6% 748 + 204 Total compiled
19
Still a Cost-Benefit Trade Great. More useless geekery. When will it make a difference? When is it worth my time?
20
Amdahl’s Law Determines how much faster program can go Use this to answer question that matters Speedup calculated by this equation Speedup of 2 means program twice as fast Need 1 / 10 the time, 10 is speedup factor of approach When speedup is 1, time taken unchanged Speedup of ½ == twice as long as past approach
21
Amdahl’s Law Determines how much faster program can go Use this to answer question that matters Speedup calculated by this equation Speedup of 2 means program twice as fast Need 1 / 10 the time, 10 is speedup factor of approach When speedup is 1, time taken unchanged Speedup of ½ == twice as long as past approach (But usually say slowdown factor of 2)
22
Amdahl’s Law Determines how much faster program can go Use this to answer question that matters Speedup calculated by this equation Speedup of 2 means program twice as fast Need 1 / 10 the time, 10 is speedup factor of approach When speedup is 1, time taken unchanged Speedup of ½ == twice as long as past approach (But usually say slowdown factor of 2) (Or hide report that shows this sucks)
23
Amdahl’s Law Equation %changed of time in methods to be optimized Expressed as decimal between 0 - 1 All other time from run is %unchanged Another decimal from 0 – 1 you FAIL If %changed + %unchanged ≠ 1, you FAIL
24
Applying Amdahl’s Law Made getWeightedError twice as fast Speedup changed = 2, since now twice as fast Took 16.4 seconds before, what will it take now? Get execution times using java –Xprof 35.6% 282 + 58 Neuron.getWeightedError %changed = 0.356 %unchanged = 1 - 0.356 = 0.644
25
Amdahl’s Law Speedup = 1.21
26
Applying Amdahl’s Law Move Neuron.compute off critical path? Removes it from program execution time Speedup changed = ∞ Get execution times from java –Xprof 9.5% 91 + 0 Neuron.compute %changed = 0.095 %unchanged = 1 - 0.095 = 0.905
27
Amdahl’s Law Speedup = 1.10
28
What Amdahl’s Law Means
29
For Next Class Lab #2 on web/Angel in 1 hour I will be in lab from 12 - 1 – feel free to stop by Read pages 37 – 55 in book Get back into code & design patterns How could we handle 1-to-many communication? Why not have cycles in UML class diagram? What is secret to Lindsay Lohan's success?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.