CPU Clock Cycles = Instruction Count X CPI CPU Execution Time =
Total Page:16
File Type:pdf, Size:1020Kb
CPUCPU PerformancePerformance Evaluation:Evaluation: CyclesCycles PerPer InstructionInstruction (CPI)(CPI) • Most computers run synchronously utilizing a CPU clock running at a constant clock rate: Clock cycle where: Clock rate = 1 / clock cycle cycle 1 cycle 2 cycle 3 • The CPU clock rate depends on the specific CPU organization (design) and hardware implementation technology (VLSI) used • A computer machine (ISA) instruction is comprised of a number of elementary or micro operations which vary in number and complexity depending on the instruction and the exact CPU organization (Design) – A micro operation is an elementary hardware operation that can be performed during one CPU clock cycle. – This corresponds to one micro-instruction in microprogrammed CPUs. – Examples: register operations: shift, load, clear, increment, ALU operations: add , subtract, etc. • Thus a single machine instruction may take one or more CPU cycles to complete termed as the Cycles Per Instruction (CPI). • Average CPI of a program: The average CPI of all instructions executed in the program on a given CPU design. EECC550 - Shaaban (Chapter 4) Cycles/sec = Hertz = Hz #1 Lec # 3 Winter 2005 12-6-2005 GenericGeneric CPUCPU MachineMachine InstructionInstruction ProcessingProcessing StepsSteps Instruction Obtain instruction from program memory Fetch Instruction Determine required actions and instruction size Decode Operand Locate and obtain operand data Fetch Execute Compute result value or status Result Deposit results in storage (memory or register) Store for later use Next Determine successor or next instruction Instruction EECC550 - Shaaban #2 Lec # 3 Winter 2005 12-6-2005 ComputerComputer PerformancePerformance Measures:Measures: ProgramProgram ExecutionExecution TimeTime • For a specific program compiled to run on a specific machine (CPU) “A”, has the following parameters: – The total executed instruction count of the program. I – The average number of cycles per instruction (average CPI). CPI – Clock cycle of machine “A” C • How can one measure the performance of this machine (CPU) running this program? – Intuitively the machine (or CPU) is said to be faster or has better performance running this program if the total execution time is shorter. – Thus the inverse of the total measured program execution time is a possible performance measure or metric: PerformanceA = 1 / Execution TimeA How to compare performance of different machines? What factors affect performance? How to improve performance? EECC550 - Shaaban #3 Lec # 3 Winter 2005 12-6-2005 ComparingComparing ComputerComputer PerformancePerformance UsingUsing ExecutionExecution TimeTime • To compare the performance of two machines (or CPUs) “A”, “B” running a given specific program: PerformanceA = 1 / Execution TimeA PerformanceB = 1 / Execution TimeB • Machine A is n times faster than machine B means (or slower? if n < 1) : Performance Execution Time Speedup = n = A = B PerformanceB Execution TimeA • Example: (i.e Speedup is ratio of performance, no units) For a given program: Execution time on machine A: ExecutionA = 1 second Execution time on machine B: ExecutionB = 10 seconds Speedup= PerformanceA / PerformanceB = Execution TimeB / Execution TimeA = 10 / 1 = 10 The performance of machine A is 10 times the performance of machine B when running this program, or: Machine A is said to be 10 times faster than machine B when running this program. The two CPUs may target different ISAs provided the program is written in a high level language (HLL) EECC550 - Shaaban #4 Lec # 3 Winter 2005 12-6-2005 CPUCPU ExecutionExecution Time:Time: TheThe CPUCPU EquationEquation • A program is comprised of a number of instructions executed , I – Measured in: instructions/program • The average instruction executed takes a number of cycles per instruction (CPI) to be completed. Or Instructions Per Cycle (IPC): – Measured in: cycles/instruction, CPI IPC= 1/CPI • CPU has a fixed clock cycle time C = 1/clock rate – Measured in: seconds/cycle • CPU execution time is the product of the above three parameters as follows: Executed CPUCPU time time = = Seconds Seconds = = Instructions Instructions x x Cycles Cycles x x Seconds Seconds ProgramProgram Program Program Instruction Instruction Cycle Cycle T = I x CPI x C execution Time Number of Average CPI for program CPU Clock Cycle per program in seconds instructions executed EECC550 - Shaaban (This equation is commonly known as the CPU performance equation) #5 Lec # 3 Winter 2005 12-6-2005 CPUCPU AverageAverage CPI/ExecutionCPI/Execution TimeTime For a given program executed on a given machine (CPU): CPI = Total program execution cycles / Instructions count (average) → CPU clock cycles = Instruction count x CPI CPU execution time = = CPU clock cycles x Clock cycle = Instruction count x CPI x Clock cycle T = I x CPI x C execution Time Number of Average CPI CPU Clock Cycle per program in seconds instructions executed for program EECC550 - Shaaban (This equation is commonly known as the CPU performance equation) #6 Lec # 3 Winter 2005 12-6-2005 CPUCPU ExecutionExecution Time:Time: ExampleExample • A Program is running on a specific machine (CPU) with the following parameters: – Total executed instruction count: 10,000,000 instructions – Average CPI for the program: 2.5 cycles/instruction. – CPU clock rate: 200 MHz. (clock cycle = 5x10-9 seconds) • What is the execution time for this program: CPUCPU time time = = Seconds Seconds = = Instructions Instructions x x Cycles Cycles x x Seconds Seconds ProgramProgram Program Program Instruction Instruction Cycle Cycle CPU time = Instruction count x CPI x Clock cycle = 10,000,000 x 2.5 x 1 / clock rate = 10,000,000 x 2.5 x 5x10-9 = .125 seconds T = I x CPI x C EECC550 - Shaaban #7 Lec # 3 Winter 2005 12-6-2005 FactorsFactors AffectingAffecting CPUCPU PerformancePerformance CPUCPU time time = = Seconds Seconds = = Instructions Instructions x x Cycles Cycles x x Seconds Seconds ProgramProgram Program Program Instruction Instruction Cycle Cycle T = I x CPI x C Instruction Cycles per Clock Rate Count Instruction (1/C) Program Compiler Instruction Set Architecture (ISA) Organization (CPU Design) Technology (VLSI) EECC550 - Shaaban #8 Lec # 3 Winter 2005 12-6-2005 AspectsAspects ofof CPUCPU ExecutionExecution TimeTime CPU Time = Instruction count x CPI x Clock cycle T = I x CPI x C Depends on: Program Used Compiler ISA Instruction Count I (executed) Depends on: Program Used Depends on: Compiler CPI Clock CPU Organization Technology (VLSI) ISA (Average Cycle CPU Organization CPI) C EECC550 - Shaaban #9 Lec # 3 Winter 2005 12-6-2005 PerformancePerformance Comparison:Comparison: ExampleExample • From the previous example: A Program is running on a specific machine (CPU) with the following parameters: – Total executed instruction count, I: 10,000,000 instructions – Average CPI for the program: 2.5 cycles/instruction. – CPU clock rate: 200 MHz. • Using the same program with these changes: – A new compiler used: New executed instruction count, I: 9,500,000 New CPI: 3.0 – Faster CPU implementation: New clock rate = 300 MHz • What is the speedup with the changes? Speedup = Old Execution Time = Iold x CPIold x Clock cycleold Speedup = Old Execution Time = Iold x CPIold x Clock cycleold New Execution Time Inew x CPInew x Clock Cyclenew New Execution Time Inew x CPInew x Clock Cyclenew Speedup = (10,000,000 x 2.5 x 5x10-9) / (9,500,000 x 3 x 3.33x10-9 ) = .125 / .095 = 1.32 or 32 % faster after changes. Clock Cycle = 1/ Clock Rate T = I x CPI x C EECC550 - Shaaban #10 Lec # 3 Winter 2005 12-6-2005 InstructionInstruction TypesTypes && CPICPI • Given a program with n types or classes of instructions executed on a given CPU with the following characteristics: Ci = Count of instructions of typei executed i = 1, 2, …. n CPIi = Cycles per instruction for typei Then:Then: CPI = CPU Clock Cycles / Instruction Count I Where: n CPU clock cycles =×∑ ()CPIii C i=1 Executed Instruction Count I = Σ Ci T = I x CPI x C EECC550 - Shaaban #11 Lec # 3 Winter 2005 12-6-2005 InstructionInstruction TypesTypes && CPI:CPI: AnAn ExampleExample • An instruction set has three instruction classes: Instruction class CPI A1For a specific B2CPU design C3 • Two code sequences have the following instruction counts: Instruction counts for instruction class Code Sequence A B C 1 2 1 2 2 4 1 1 • CPU cycles for sequence 1 = 2 x 1 + 1 x 2 + 2 x 3 = 10 cycles CPI for sequence 1 = clock cycles / instruction count = 10 /5 = 2 • CPU cycles for sequence 2 = 4 x 1 + 1 x 2 + 1 x 3 = 9 cycles CPI for sequence 2 = 9 / 6 = 1.5 n CPI = CPU Cycles / I EECC550 - Shaaban CPU clock cycles =×∑ ()CPIii C i=1 #12 Lec # 3 Winter 2005 12-6-2005 InstructionInstruction FrequencyFrequency && CPICPI • Given a program with n types or classes of instructions with the following characteristics: i = 1, 2, …. n Ci = Count of instructions of typei CPIi = Average cycles per instruction of typei Fi = Frequency or fraction of instruction typei executed = Ci/ total executed instruction count = Ci/ I Then: n CPI = × ∑ ()CPI i F i i=1 CPI x F Fraction of total execution time for instructions of type i = i i CPI EECC550 - Shaaban #13 Lec # 3 Winter 2005 12-6-2005 InstructionInstruction TypeType FrequencyFrequency && CPI:CPI: AA RISCRISC ExampleExample CPI x F Program Profile or Executed Instructions Mix i i CPI Base Machine (Reg / Reg) Op Freq, Fi CPIi CPIi x Fi % Time Given ALU 50% 1 .5 23% = .5/2.2 Load 20% 5 1.0 45% = 1/2.2 Store 10% 3 .3 14% = .3/2.2 Branch 20% 2 .4 18% = .4/2.2 Typical Mix Sum = 2.2 n CPI = × ∑ ()CPI i F i i =1 CPI = .5 x 1 + .2 x 5 + .1 x 3 + .2 x 2 = 2.2 = .5 + 1 + .3 + .4 EECC550 - Shaaban #14 Lec # 3 Winter 2005 12-6-2005 MetricsMetrics ofof ComputerComputer PerformancePerformance (Measures) Application Execution time: Target workload, SPEC, etc. Programming Language Compiler (millions) of Instructions per second – MIPS (millions) of (F.P.) operations per second – MFLOP/s ISA Datapath Control Megabytes per second.