COMP 411 Computer Organization Performance Don Porter COMP

  • Slides: 55
Download presentation
COMP 411: Computer Organization Performance Don Porter

COMP 411: Computer Organization Performance Don Porter

COMP 411: Computer Organization Topics • • • Defining “Performance” Performance Measures How to

COMP 411: Computer Organization Topics • • • Defining “Performance” Performance Measures How to improve performance Performance pitfalls Examples

COMP 411: Computer Organization Why Study Performance? • Helps us make intelligent design choices

COMP 411: Computer Organization Why Study Performance? • Helps us make intelligent design choices – See through the marketing hype • Key to understanding underlying computer organization – Why is some hardware faster than others for different programs? – What factors of system performance are hardware related? • e. g. , Do we need a new machine … • … or a new operating system? – How does a machine’s instruction set affect its performance?

COMP 411: Computer Organization What is Performance? • Loosely: – How fast can a

COMP 411: Computer Organization What is Performance? • Loosely: – How fast can a computer complete a task • Examples of “tasks”: – Short tasks: • Crunch a bunch of numbers (say calculate mean) • Display a PDF document • Respond to a game console button press – Longer ones: • Search for a document on hard drive • Rip a DVD into an mpg file • Apply a Photoshop filter

COMP 411: Computer Organization Performance Metrics • Latency: Time from input to corresponding output

COMP 411: Computer Organization Performance Metrics • Latency: Time from input to corresponding output – – – How long does it take for my program to run? How long must I wait after typing return for the result? Other examples? • Throughput: Results produced per unit time – – How many results can be processed per second? What is the average execution rate of my program? How much work is getting done each second? Other examples?

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range (miles) Cruising speed (mph) • How to Define “Best”? : – – Fastest? Farthest range? Most passenger capacity? Passenger-miles per hour? Passenger throughput (passengers x mph)

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range (miles) Cruising speed (mph) Boeing 777 Boeing 747 BAC/Sud Concorde Douglas DC-8 -50 0 200 400 600 Passenger Capacity Boeing 747 BAC/Sud Concorde Douglas DC-8 -50 500 1000 Cruising Speed (mph) 5000 Cruising Range (miles) Boeing 777 0 0 Passenger throughput (passengers x mph) 1500 10000

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range (miles) Cruising speed (mph) Passenger throughput (passengers x mph) • How much faster is the Concorde than the 747? – 1350 mph / 610 mph = 2. 2 X (“X” means “factor of”) • How much larger is the 747’s capacity than the Concorde? – 470 passengers / 132 passengers = 3. 6 X Note: X is a ratio – no units

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range

411: Computer Organization Which airplane COMP is “best”? Airplane Passeng er capacity Cruising range (miles) Cruising speed (mph) Passenger throughput (passengers x mph) • Note: Dimensional analysis is your friend

COMP 411: Computer Organization Performance Metrics • Latency: Time from input to corresponding output

COMP 411: Computer Organization Performance Metrics • Latency: Time from input to corresponding output – – Flight time from Raleigh to Paris How long does it take for my program to run? How long must I wait after typing return for the result? Other examples? • Throughput: Results produced per unit time – – – Passengers/hour How many results can be processed per second? What is the average execution rate of my program? How much work is getting done each second? Other examples?

COMP 411: Computer Organization Execution Time • Elapsed Time/Wall Clock Time – counts everything

COMP 411: Computer Organization Execution Time • Elapsed Time/Wall Clock Time – counts everything (disk and memory accesses, I/O, etc. ) – includes the impact of other programs – a useful number, but often not good for comparison purposes • CPU time – does not include I/O or time spent running other programs – can be broken up into system time, and user time • Our focus: user CPU time – time spent executing actual instructions of “our” program

COMP 411: Computer Organization Performance • For some program running on machine X, –

COMP 411: Computer Organization Performance • For some program running on machine X, – Performance. X = Program Executions / Time. X (executions/sec) = 1 / Execution Time. X • Relative Performance – "X is n times faster than Y” – Performance. X / Performance. Y = n

COMP 411: Computer Organization Performance • • Performance. X = 1 / Execution Time.

COMP 411: Computer Organization Performance • • Performance. X = 1 / Execution Time. X Relative Performance (“X is n times faster than Y”) – n = Performance. X / Performance. Y • Example: – Machine A runs a program in 20 seconds Performance. A = 1/20 – Machine B runs the same program in 25 seconds Performance. B = 1/25 • By how much is A faster than B? Machine A is (1/20)/(1/25) = 1. 25 times faster than Machine B

COMP 411: Computer Organization Performance: Pitfalls of using % • Same Example: – Machine

COMP 411: Computer Organization Performance: Pitfalls of using % • Same Example: – Machine A runs a program in 20 sec; B takes 25 sec – By how much is A faster than B? • • • Is it (25 -20)/25 = 20% faster? Is it (25 -20)/20 = 25% faster? Correct answer is: A is (Perf. A-Perf. B)/Per. B faster – (0. 05 - 0. 04) / (0. 04) = 25% faster – By how much is B slower than A? • Correct answer is: B is (Perf. B-Perf. A)/Per. A faster/slower – (0. 04 - 0. 05) / (0. 05) = -20% faster = 20% slower – Confusing: A is 25% faster than B; B is 20% slower – Better: A is 1. 25 times faster than B; B is 1/1. 25 as fast • Also: percentages are only good up to 100% – Never say A is 13000% faster than B Neither immediately intuitive; voice of experience

COMP 411: Computer Organization CPU Clocking • Operation of digital hardware governed by a

COMP 411: Computer Organization CPU Clocking • Operation of digital hardware governed by a constant-rate clock Clock period Clock (cycles) Data transfer and computation Update state • Clock period: duration of a clock cycle – e. g. , 250 ps = 0. 25 ns = 250× 10– 12 s • Clock frequency (rate): cycles per second – e. g. , 1/(0. 25 ns) = 4 GHz = 4000 MHz = 4. 0× 109 Hz Water hose analogy

COMP 411: Computer Organization Program Clock Cycles • Execution time often reported in cycle

COMP 411: Computer Organization Program Clock Cycles • Execution time often reported in cycle counts – History: A newer generation of the same processor… • Used to have the same cycle counts for the same program • But a faster clock speed (ex, 1 GHz changes to 1. 5 GHz) • Not really true anymore, but does focus on CPU performance • Clock “ticks” indicate when machine state changes – Abstraction: model time as discrete instead of continuous time • Simple relation:

COMP 411: Computer Organization From Cycles to *seconds • Relation: – or: •

COMP 411: Computer Organization From Cycles to *seconds • Relation: – or: •

COMP 411: Computer Organization How Many Cycles in a Program? • For some processors

COMP 411: Computer Organization How Many Cycles in a Program? • For some processors (e. g. , MIPS processor) . . . 6 th 5 th 4 th 3 rd instruction 2 nd instruction 1 st instruction – # of cycles == # of instructions time This assumption can be incorrect, Different instructions take different amounts of time on different machines. Memory accesses might require more cycles than other instructions. Floating-Point instructions might require multiple clock cycles to execute. Branches might stall execution rate

COMP 411: Computer Organization Instruction Count and CPI • Instruction Count for a program

COMP 411: Computer Organization Instruction Count and CPI • Instruction Count for a program – Determined by • program • Instruction set architecture (ISA) • compiler • Average cycles per instruction (“CPI”) – Determined by CPU hardware – If different instructions have different CPI • Average CPI affected by instruction mix

COMP 411: Computer Organization Now that we understand cycles • A given program will

COMP 411: Computer Organization Now that we understand cycles • A given program will require – – – some number of instructions (machine instructions) some number of cycles some number of seconds • We have a vocabulary that relates these quantities: – – – cycle time (seconds per cycle) clock rate (cycles per second) CPI (average cycles per instruction) • a floating point intensive application might have a higher CPI – MIPS (millions of instructions per second) • this would be higher for a program using simple instructions

COMP 411: Computer Organization Computer Performance Measure Millions of Instructions per Second Unfortunate coincidence:

COMP 411: Computer Organization Computer Performance Measure Millions of Instructions per Second Unfortunate coincidence: This “MIPS” has nothing to do with the name of the MIPS processor we will be studying! Frequency in MHz CPI (Average Cycles Per Instruction) Historically: PDP-11, VAX, Intel 8086: Load/Store RISC machines MIPS, SPARC, Power. PC, mini. MIPS: Modern CPUs, Pentium, Athlon : CPI > 1 CPI = 1 CPI < 1

COMP 411: Computer Organization How to Improve Performance? • Many ways to write the

COMP 411: Computer Organization How to Improve Performance? • Many ways to write the same equations: • So, to improve performance (everything else being equal) you can either – Decrease ____ the # of required cycles for a program; – Decrease ____ the clock cycle time or, said another way, – Increase ____ the clock rate; – Decrease ____ the CPI (average clocks per instruction). • MIPS Pitfall – Cannot compare MIPS of two different processors if they run different sets of instructions! – ARM CPU clock rate not directly comparable to Intel – ISA is different Meaningless Indicator of Processor Speed!

COMP 411: Computer Organization Example • Our favorite program runs in 10 seconds on

COMP 411: Computer Organization Example • Our favorite program runs in 10 seconds on computer A, which has a 2 GHz clock. We are trying to help a computer designer build a new machine B, to run this program in 6 seconds. The designer can use new (or perhaps more expensive) technology to substantially increase the clock rate, but has informed us that this increase will affect the rest of the CPU design, causing machine B to require 1. 2 times as many clock cycles as machine A for the same program. What clock rate should we tell the designer to target?

COMP 411: Computer Organization Performance Traps • Performance: What matters is the execution time

COMP 411: Computer Organization Performance Traps • Performance: What matters is the execution time of a program that you care about. • Do any of the other variables (alone) equal performance? – – – # of cycles to execute program? # of instructions in program? # of cycles per second? average # of cycles per instruction? average # of instructions per second? • Common pitfall: – Putting the blinders on, and focusing exclusively on one variable

COMP 411: Computer Organization CPI Example • Suppose we have two implementations of the

COMP 411: Computer Organization CPI Example • Suppose we have two implementations of the same instruction set architecture (ISA) – If same ISA which quantity (clock rate, CPI) is the same? Neither! – For some program: • Computer A has a clock cycle time of 250 ps and a CPI of 2. 0 • Computer B has a clock cycle time of 500 ps and a CPI of 1. 2 – What machine is faster for this program, and by how much? A is faster by 1. 2 X

COMP 411: Computer Organization CPI in More Detail • If different instruction classes take

COMP 411: Computer Organization CPI in More Detail • If different instruction classes take different numbers of cycles – Weighted average CPI: Relative frequency On most CPUs, CPI is a weighted average

COMP 411: Computer Organization Example: Compiler’s Impact • Two different compilers are being tested

COMP 411: Computer Organization Example: Compiler’s Impact • Two different compilers are being tested for a 500 MHz machine with three different classes of instructions: Class A, Class B, and Class C, which require one, two, and three cycles (respectively). Both compilers are used to produce code for a large piece of software. The first compiler's code uses 5 million Class A instructions, 1 million Class B instructions, and 2 million Class C instructions. The second compiler's code uses 7 million Class A instructions, 1 million Class B instructions, and 1 million Class C instructions. Which program uses fewer instructions? – Instructions 1 = (5+1+2) x 106 = 8 x 106 – Instructions 2 = (7+1+1) x 106 = 9 x 106 • Which sequence uses fewer clock cycles? – Cycles 1 = (5(1)+1(2)+2(3)) x 106 = 13 x 106 – Cycles 2 = (7(1)+1(2)+1(3)) x 106 = 12 x 106 CPI 1 = ? 13/8 = 1. 625 CPI 2 = ? 12/9 = 1. 33

COMP 411: Computer Organization Another CPI Example • Alternative compiled code versions using instructions

COMP 411: Computer Organization Another CPI Example • Alternative compiled code versions using instructions in classes A, B, C Class A B C CPI for class 1 2 3 IC for version 1 2 IC for version 2 4 1 1 • Version 1: IC = 5 – Clock Cycles = 2× 1 + 1× 2 + 2× 3 = 10 – Avg. CPI = 10/5 = 2. 0 ã Version 2: IC = 6 l Clock Cycles = 4× 1 + 1× 2 + 1× 3 =9 l Avg. CPI = 9/6 = 1. 5

COMP 411: Computer Organization Performance Summary • Performance depends on – – Algorithm: affects

COMP 411: Computer Organization Performance Summary • Performance depends on – – Algorithm: affects IC, possibly CPI Programming language: affects IC, CPI Compiler: affects IC, CPI Instruction set architecture: affects IC, CPI, Cycle Time

COMP 411: Computer Organization Comparing Computers • So, if IPC, clock, etc. aren’t good

COMP 411: Computer Organization Comparing Computers • So, if IPC, clock, etc. aren’t good measures, what is? • Execution time of the program you care about! – But this is in the eye of the beholder • Idea: Let’s get a set of representative applications – May not be perfect, or exactly what I care about – But covers common use cases • What might be good smartphone apps? 30

COMP 411: Computer Organization Benchmarks • A set of applications for comparing execution time

COMP 411: Computer Organization Benchmarks • A set of applications for comparing execution time – Use programs typical of expected workload – Or, typical of expected class of applications • e. g. , compilers/editors, scientific applications, graphics, etc. • Small benchmarks – – – nice for architects and designers easy to standardize can be abused • SPEC (System Performance Evaluation Cooperative) – – – companies have agreed on a set of real program and inputs can still be abused valuable indicator of performance (and compiler technology)

COMP 411: Computer Organization SPEC ’ 95 • Periodically updated with newer benchmarks:

COMP 411: Computer Organization SPEC ’ 95 • Periodically updated with newer benchmarks:

COMP 411: Computer Organization SPEC 2006 • Interesting to see how the mix of

COMP 411: Computer Organization SPEC 2006 • Interesting to see how the mix of applications has changed over the years… – See http: //www. spec. org/cpu 2006/{CINT 2006, CFP 2006} 33

COMP 411: Computer Organization Other Popular Benchmarks • • Desktop: Phoronix File System: Filebench

COMP 411: Computer Organization Other Popular Benchmarks • • Desktop: Phoronix File System: Filebench Java VM: Da. Capo Cloud: Cloudbench Same goal: Standardize & compare end-user perf.

COMP 411: Computer Organization Amdahl’s Law • Possibly the most important law on performance:

COMP 411: Computer Organization Amdahl’s Law • Possibly the most important law on performance: • Informally: The law of diminishing returns – Eventually, performance gains will be limited by what cannot be improved – Paris flight example: I spend 1 hour in takeoff/taxi/landing, and 6 in the air. If I improve take-off time, what is the fastest I will get to Paris? • 6 hours if I could instantly jump into the air from parked Implication: Make the common case fast

COMP 411: Computer Organization Amdahl’s Law: Example • Example: "Suppose a program runs in

COMP 411: Computer Organization Amdahl’s Law: Example • Example: "Suppose a program runs in 100 seconds on a machine, where multiplies are executed 80% of the time. How much do we need to improve the speed of multiplication if we want the program to run 4 times faster? " 25 = 80/r + 20 r = 16 x How about making it 5 times faster? 20 = 80/r + 20 r=?

COMP 411: Computer Organization Example • Suppose we enhance a machine making all floating-point

COMP 411: Computer Organization Example • Suppose we enhance a machine making all floating-point instructions run FIVE times faster. If the execution time of some benchmark before the floating-point enhancement is 10 seconds, what will the speedup be if only half of the 10 seconds is spent executing floating-point instructions? 5/5 + 5 = 6 Relative Perf = 10/6 = 1. 67 x

COMP 411: Computer Organization Example • We are looking for a benchmark to show

COMP 411: Computer Organization Example • We are looking for a benchmark to show off the new floatingpoint unit described above, and want the overall benchmark to show at least a speedup of 3. What percentage of the execution time would floating-point instructions have to account for in this program in order to yield our desired speedup on this benchmark? – Recall: we make floating point 5 x faster 100/3 = f/5 + (100 – f) = 100 – 4 f/5 f = 83. 33

COMP 411: Computer Organization Design Tradeoffs • Performance is rarely the sole factor –

COMP 411: Computer Organization Design Tradeoffs • Performance is rarely the sole factor – Cost is important too – Energy/power consumption is often critical • Frequently used compound metrics – Performance/Cost (throughput/$) – Performance/Power (throughput/watt) – Work/Energy (total work done per joule) • for battery-powered devices 39

COMP 411: Computer Organization Power Consumption • Power = Energy consumed per unit time

COMP 411: Computer Organization Power Consumption • Power = Energy consumed per unit time • Two contributors to power consumption – Dynamic power • power consumed when doing actual work • called dynamic because components and wires are switching between ‘ 0’ and ‘ 1’ – Static or ‘leakage’ power • power consumed even when everything is idle or ‘static’ • due to some small amount of ‘leakage’ current that still flows

COMP 411: Computer Organization Dynamic Power Consumption • Energy consumed due to switching activity:

COMP 411: Computer Organization Dynamic Power Consumption • Energy consumed due to switching activity: – Remember the model of gates as on/off switches? This burns energy – All wires and transistor gates have capacitance, or the ability to store electric charge – Energy required to charge a capacitance, C, to VDD is CVDD 2 • Energy = CVDD 2 C is the total capacitance of circuit (“capacitive load”) VDD is the supply voltage f is the switching frequency

COMP 411: Computer Organization Dynamic Power Consumption • Energy consumed due to switching activity:

COMP 411: Computer Organization Dynamic Power Consumption • Energy consumed due to switching activity: – Energy = CVDD 2 – Circuit running at frequency f: transistors switch (from 1 to 0 or vice versa) at that frequency – Capacitor is charged f/2 times per second • assume 50% chance switching from 0 to 1 – additional energy drawn from battery CVDD 2 • assume 50% chance switching from 1 to 0 – no additional energy taken from battery stored energy is discharged Pdynamic = CVDD 2 *f/2 = ½CVDD 2 f C is the total capacitance of circuit (“capacitive load”) VDD is the supply voltage f is the switching frequency

COMP 411: Computer Organization Static Power Consumption • Power consumed when no gates are

COMP 411: Computer Organization Static Power Consumption • Power consumed when no gates are switching – Caused by the quiescent supply current, IDD (also called the leakage current) Pstatic or Pleakage = IDDVDD is the supply voltage IDD is the leakage current

COMP 411: Computer Organization Combining Dynamic + Static • P = ½CVDD 2 f

COMP 411: Computer Organization Combining Dynamic + Static • P = ½CVDD 2 f + IDDVDD C is the total capacitance of circuit (“capacitive load”) VDD is the supply voltage IDD is the leakage current f is the switching frequency

COMP 411: Computer Organization Power Consumption Example • Estimate the power consumption of a

COMP 411: Computer Organization Power Consumption Example • Estimate the power consumption of a wireless handheld computer C is the total capacitance of circuit (“capacitive load”) – – VDD = 1. 2 V C = 20 n. F f = 1 GHz IDD = 20 m. A VDD is the supply voltage IDD is the leakage current f is the switching frequency 1 F = 1 (W *s) / Volt 2 1 W=1 V*1 A 1 Hz = 1 second -1 P = ½CVDD 2 f + IDDVDD = ½(20 n. F)(1. 2 V)2(1 GHz) + (20 m. A)(1. 2 V) = 14. 4 W + 24 m. W = 14. 424 W

COMP 411: Computer Organization Power Trends • In CMOS IC technology × 30 5

COMP 411: Computer Organization Power Trends • In CMOS IC technology × 30 5 V → 1 V Note: “Frequency” may also be called “clock rate/frequency” or “frequency switched” × 1000

COMP 411: Computer Organization Reducing Dynamic Power • Suppose a new CPU has –

COMP 411: Computer Organization Reducing Dynamic Power • Suppose a new CPU has – 85% of capacitive load of old CPU – 15% voltage and 15% frequency reduction • About a 50% reduction in power

COMP 411: Computer Organization The Power Wall • Hard physical realities: – It is

COMP 411: Computer Organization The Power Wall • Hard physical realities: – It is hard to reduce voltage below a certain point • Leakage starts to dominate results – Garden hose analogy: hard to differentiate water left in hose from real output • Circuit outputs become unstable – We can only dissipate so much heat from a cm 2 of surface area • Fancier cooling possible: liquids, larger heat sinks • But not in my phone! 48

COMP 411: Computer Organization Fallacy: Low Power at Idle • AMD X 4 power

COMP 411: Computer Organization Fallacy: Low Power at Idle • AMD X 4 power benchmark: – At 100% load: 295 W (max power) – At 50% load: 246 W (83% max power) – At 10% load: 180 W (still consumes 61% of max power) • Google data center – Mostly operates at 10% - 50% load – At 100% load less than 1% of the time • Open Problem: Design processors to make power proportional to load

COMP 411: Computer Organization Moore’s Law: Uniprocessor Perf. Constrained by power, instruction-level parallelism, memory

COMP 411: Computer Organization Moore’s Law: Uniprocessor Perf. Constrained by power, instruction-level parallelism, memory latency 50

COMP 411: Computer Organization Multiprocessors • “Multicore” microprocessors – More than one processor core

COMP 411: Computer Organization Multiprocessors • “Multicore” microprocessors – More than one processor core per chip • Requires explicitly parallel programming – Hardware executes multiple instructions at once • Ideally, hidden from the programmer – Hard to do • • Programming for performance Load balancing Optimizing communication and synchronization But, newer OSes and libraries have been designed for this 51

COMP 411: Computer Organization Manufacturing ICs • IC = Integrated Circuit (“chip”) • Yield:

COMP 411: Computer Organization Manufacturing ICs • IC = Integrated Circuit (“chip”) • Yield: proportion of working dies per wafer

COMP 411: Computer Organization Integrated Circuit Cost • Nonlinear relation to area and defect

COMP 411: Computer Organization Integrated Circuit Cost • Nonlinear relation to area and defect rate – Wafer cost and area are fixed – Defect rate determined by manufacturing process – Die area determined by architecture and circuit design

COMP 411: Computer Organization Remember • Performance is specific to a particular program –

COMP 411: Computer Organization Remember • Performance is specific to a particular program – Total execution time is a consistent summary of performance • For a given architecture, performance comes from: – – – increases in clock rate (without adverse CPI affects) improvements in processor organization that lower CPI compiler enhancements that lower CPI and/or instruction count • Pitfall: Expecting improvements in one aspect of a machine’s performance to affect the total performance • You should not always believe everything you read! – Read carefully! Especially what the business guys say!

COMP 411: Computer Organization Concluding Remarks • Cost/performance is improving – Due to underlying

COMP 411: Computer Organization Concluding Remarks • Cost/performance is improving – Due to underlying technology development • Hierarchical layers of abstraction – In both hardware and software • Instruction set architecture – The hardware/software interface • Execution time: the best performance measure • Power is a limiting factor – Use parallelism to improve performance