EEM 486: Computer Architecture Lecture 4 Performance EEM 486 Performance Purchasing perspective Given a collection of machines, which has the» Best performance?» Least cost?» Best performance / cost? Design perspective Faced with design options, which has the» Best performance improvement?» Least cost?» Best performance / cost? Both require basis for comparison metric for evaluation Our goal: understand cost & performance implication of architectural choices Lec 4.2 1
Which airplane has the best performance? Plane DC to Paris Speed Passengers Throughput (p x mph) Boeing 747 6.5 hours 610 mph 470 286,700 Concorde 3 hours 1350 mph 132 178,200 Performance measure: Speed (cruising speed, range, capacity) Which is the fastest plane? the one with the highest cruising speed the one with the highest throughput OR Lec 4.3 Which airplane has the best performance? Time of Concorde vs. Boeing 747? Concord is 1350 mph / 610 mph = 2.2 times faster = 6.5 hours / 3 hours Throughput of Concorde vs. Boeing 747? Concord is 178,200 pmph / 286,700 pmph = 0.62 times faster Boeing is 286,700 pmph / 178,200 pmph = 1.60 times faster Concord is 2.2 times (120%) faster in terms of flying time Boeing is 1.6 times (60%) faster in terms of throughput Lec 4.4 2
Computer Performance Performance measure: TIME Two notions of computer performance: 1. Execution time 2. Throughput Execution (or Response) Time: Time to complete a given task users want smaller response times Throughput:Total amount of work done in a given time admins want higher throughput Q: If we upgrade a machine with a new processor what do we increase? Q: If we add a new machine to the lab what do we increase? Lec 4.5 User CPU Time Elapsed Time counts everything (disk and memory accesses, I/O, etc.) a useful number, but often not good for comparison purposes CPU time doesn't count 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 the lines of code that are "in" our program Lec 4.6 3
Definitions Performance is in units of things-per-second bigger is better!!! If we are primarily concerned with execution time performance X 1 = execution time X "X is n times faster than Y" means performance performance X n = = Y execution time execution time Y X Q: machine A runs a program in 20 seconds machine B runs the same program in 25 seconds Lec 4.7 Clock Cycles Clock ticks indicate when to start activities cycle time = time between ticks = seconds per cycle clock rate (frequency) = cycles per second (1 Hz = 1 cycle/sec) A 200 Mhz clock has a 1 200 10 6 109 = 5 nanoseconds cycle time time Lec 4.8 4
How many cycles are required for a program? Could assume that # of cycles = # of instructions 1st instruction 2nd instruction 3rd instruction 4th 5th 6th... time This assumption is incorrect, different instructions take different amounts of time Multiplication takes more time than addition Floating point operations take longer than integer ones Accessing memory takes more time than accessing registers Lec 4.9 CPU Time A given program will require some number of instructions (machine instructions) some number of cycles some number of seconds CPU Time = User CPU time for a program CPU Time = CPU clock cycles for a program x Clock cycle time CPU clock cycles for a program = -------------------------------------- Clock rate Lec 4.10 5
Example Our favorite program runs in 10 seconds on computer A, which has a 400 Mhz clock. We are trying to help a computer designer build a new machine B, that will 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? Lec 4.11 CPI CPI (clock cycles per instruction): average number of clock cycles per instr CPU clock cycles for a program = Instruction count x CPI CPU Time = CPU clock cycles for a program x Clock cycle time = Instruction count x CPIx Clock cycle time Instruction count x CPI = ------------------------------ Clock rate Lec 4.12 6
CPI Given that n : number of instruction classes CPI i: average number of cycles per instr for instr class i I : number of instructions of class i i CPU Clock Cycles = n i= 1 CPI i I i CPI = = = CPU Time Clock Rate Instruction Count CPU Clock Cycles Instruction Count n CPIi Ii Instruction Count i= 1 Lec 4.13 Example A compiler designer is trying to decide between two code sequences for a particular machine. Based on the hardware implementation, there are three different classes of instructions: Class A, Class B, and Class C, and they require one, two, and three cycles (respectively). The first code sequence has 5 instrs: 2 of A, 1 of B, and 2 of C The second sequence has 6 instrs: 4 of A, 1 of B, and 1 of C. Which sequence will be faster? How much? What is the CPI for each sequence? Lec 4.14 7
Aspects of CPU Performance CPU time = Seconds Instructions Cycles Seconds = x x Program Program Instruction Cycle Program instr count CPI clock rate x Compiler x x Instr. Set x x Organization x x Technology x Lec 4.15 Performance Performance is determined by execution time Do any of the other variables 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: thinking one of the variables is indicative of performance when it really isn t. Lec 4.16 8
CPI Example Suppose we have two implementations of the same instruction set architecture (ISA). For some program, Machine A has a clock cycle time of 10 ns. and a CPI of 2.0 Machine B has a clock cycle time of 20 ns. and a CPI of 1.2 Which machine is faster for this program, and by how much? Q: If two machines have the same ISA which of our quantities (e.g., clock rate, CPI, execution time, # of instructions) will always be identical? Lec 4.17 # of Instructions Example A compiler designer is trying to decide between two code sequences for a particular machine. Based on the hardware implementation, there are three different classes of instructions: Class A, Class B, and Class C, and they require one, two, and three cycles (respectively). The first code sequence has 5 instrs: 2 of A, 1 of B, and 2 of C The second sequence has 6 instrs: 4 of A, 1 of B, and 1 of C. Which sequence will be faster? How much? What is the CPI for each sequence? Lec 4.18 9
Benchmarks Performance best determined by running a real application 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 valuable indicator of performance (and compiler technology) can still be abused Lec 4.19 Benchmark Games An embarrassed Intel Corp. acknowledged Friday that a bug in a software program known as a compiler had led the company to overstate the speed of its microprocessor chips on an industry benchmark by 10 percent. However, industry analysts said the coding error was a sad commentary on a common industry practice of cheating on standardized performance tests The error was pointed out to Intel two days ago by a competitor, Motorola came in a test known as SPECint92 Intel acknowledged that it had optimized its compiler to improve its test scores. The company had also said that it did not like the practice but felt to compelled to make the optimizations because its competitors were doing the same thing At the heart of Intel s problem is the practice of tuning compiler programs to recognize certain computing problems in the test and then substituting special handwritten pieces of code Saturday, January 6, 1996 New York Times Lec 4.20 10
SPEC 89 Compiler enhancements and performance 800 700 600 SPEC performance ratio 500 400 300 200 100 0 gcc espresso spice doduc nasa7 li eqntott matrix300 fpppp tomcatv Benchmark Compiler Enhanced compiler Lec 4.21 SPEC95 Eighteen application benchmarks (with inputs) reflecting a technical computing workload Eight integer go, m88ksim, gcc, compress, li, ijpeg, perl, vortex Ten floating-point intensive tomcatv, swim, su2cor, hydro2d, mgrid, applu, turb3d, apsi, fppp, wave5 Must run with standard compiler flags eliminate special undocumented incantations that may not even generate working code for real programs Lec 4.22 11
SPEC CPU2000 Lec 4.23 SPEC 2000 Does doubling the clock rate double the performance? 1400 1200 1000 800 Pentium 4 CFP2000 Pentium 4 CINT2000 600 400 200 Pentium III CINT2000 Pentium III CFP2000 0 500 1000 1500 2000 2500 3000 3500 Clock rate in MHz Lec 4.24 12
SPEC 2000 Can a machine with a slower clock rate have better performance? 1.6 1.4 Pentium M @ 1.6/0.6 GHz Pentium 4-M @ 2.4/1.2 GHz Pentium III-M @ 1.2/0.8 GHz 1.2 1.0 0.8 0.6 0.4 0.2 0.0 SPECINT2000 SPECFP2000 SPECINT2000 SPECFP2000 SPECINT2000 SPECFP2000 Always on/maximum clock Laptop mode/adaptive clock Benchmark and power mode Minimum power/minimum clock Lec 4.25 Alternative Metrics Instruction Count MIPS = ------------------------- Execution Time x 10 6 MIPS can vary inversely with performance! Number of floating point operations in a program MFLOPS = -------------------------------------------------------- Execution Time x 10 6 FP operations perfromed may vary across computers! Lec 4.26 13
MIPS example Two different compilers are being tested for a 4 GHz. 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 1 million Class C instructions. The second compiler's code uses 10 million Class A instructions, 1 million Class B instructions, and 1 million Class C instructions. Which sequence will be faster according to MIPS? Which sequence will be faster according to execution time? Lec 4.27 Amdahl's Law Speedup due to enhancement E: ExTime w/o E Performance w/ E Speedup (E) = -------------------- = ----------------------- ExTime w/ E Performance w/o E Suppose that enhancement E accelerates a fraction F of the task by a factor S and the remainder of the task is unaffected then, ExTime (with E) = ((1-F) + F/S) x ExTime (without E) 1 Speedup (E) = --------------- (1-F) + F/S Lec 4.28 14
Example (RISC Processor) Op Freq Cycles CPI(i) % Time ALU 50% 1.5 23% Load 20% 5 1.0 45% Store 10% 3.3 14% Branch 20% 2.4 18% 2.2 Typical Mix How much faster would the machine be if a better data cache reduced the average load time to 2 cycles? (S= 1/(0.55+ 0.45/2.5)) How does this compare with using branch prediction to shave a cycle off the branch time? (S= 1/(0.82+ 0.18/2)) What if two ALU instructions could be executed at once? Lec 4.29 Summary Performance is specific to a particular program/s Best Metric: Time to execute the program For a given architecture performance increases come 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 CPI Inst. Count Cycle Time Pitfall: expecting improvement in one aspect of a machine s performance to affect the total performance Lec 4.30 15