# Computer Organization Lab 1 Soufiane berouel. Formulas to Remember CPU Time = CPU Clock Cycles x Clock Cycle Time CPU Clock Cycles = Instruction Count.

## Presentation on theme: "Computer Organization Lab 1 Soufiane berouel. Formulas to Remember CPU Time = CPU Clock Cycles x Clock Cycle Time CPU Clock Cycles = Instruction Count."— Presentation transcript:

Computer Organization Lab 1 Soufiane berouel

Formulas to Remember CPU Time = CPU Clock Cycles x Clock Cycle Time CPU Clock Cycles = Instruction Count x Cycles per Instruction Clock Cycle Time = 1 / Clock Cycle Rate Amdahl’s Law – Overall Speedup = 1 / [(1 – ∑ FE i ) + ∑ (FE i / SE i )] – FE is the proportion affected, SE is the speed up for the specific proportion

Exercise 1 For a color display using 8 bits for each primary color (R, G, B) per pixel and with a resolution of 1280 x 800 pixels, what should be the size (in bytes) of the frame buffer to store a frame?

Exercise 1 (sol) Each frame requires 1280 x 800 x 3 = 3072000 ~ 3 Mbytes

Exercise 2 Consider 3 processors P1, P2 and P3 with clock rates and CPI given below, are running the same program: clock rate CPI P1 2 GHz 1.5 P2 1.5 GHz 1.0 P3 3 GHz 2.5 Which processor will have the best performance?

Exercise 2 (sol) Suppose the program has N instructions. Time taken to execute on P1 is = 1.5 N / (2 x 10 9 ) = 0.75 N x 10 -9 Time taken to execute on P2 is = N/ (1.5 x 10 9 ) = 0.66 N x 10 -9 Time taken to execute on P3 is = 2.5 N/ (3 x 10 9 ) = 0.83 N x 10 -9 P2 has the best performance (since it takes the least time to execute).

Exercise 3 Consider 3 processors P1, P2 and P3 with same instruction set with clock rates and CPI given below: clock rate CPI P1 2 GHz 1.5 P2 1.5 GHz 1.0 P3 3 GHz 2.5 If the processors each execute a program in 10 seconds, find the number of cycles and the number of instructions.

Exercise 3 (sol) For P1 – 10 (execution time) = 1.5 (CPI) x N 1 / (2 x 10 9 ) – So N 1 (number of instructions) = 1.33 x 10 10 – Number of Cycles = 1.5 x N 1 = 2 x 10 10 …Do the same for P2 and P3

Exercise 4 Given below are the number of instructions of a program: arithmetic store load branch 500 50 100 50 Assuming the instructions take 1, 5, 5 and 2 cycles, what is the execution time in a 2 GHz processor?

Exercise 4 (sol) Execution time = cycle time x CPI x no. of inst – Cycle time = 1/(2 x 10 9 ) – CPI = (500 x 1 + 50 x 5 + 100 x 5 + 50 x 2) / (500 + 50 + 100 + 50) – Thus, Execution Time = 1350 / 700 x 700 / (2 x 10 -9 ) So the Execution time = 675 x 10 -9 sec

Exercise 5 Compilers have a profound impact on the performance of an application on a given processor. This problem will explore the impact compilers have on execution time: compiler A compiler B no instructions exec. Time no. instructions exec. Time a) 1.0 x 10 9 1 s 1.2 x 10 9 1.4 s b) 1.4 x 10 9 0.8 s 1.2 x 10 9 0.7 s Find the average CPI for programs a and b, on different compilers, given that the processor has a cycle time of 1 ns.

Exercise 5 (sol) Execution Time = CPI x cycle time x no. of inst -cycle time = 1ns = 10 -9 s For program a on Compiler A -CPI = 1 / (10 -9 x 10 9 ) = 1 For program a on Compiler B – CPI = 1.4 / (10 -9 x 1.2 x 10 9 ) = 1.667 Do the same for program b…

Exercise 6 - a Three enhancements with the following speedups are proposed for a new architecture: Speedup 1 = 30 Speedup 2 = 20 Speedup 3 = 10 Only one enhancement is usable at a time. a. If enhancements 1 and 2 are each usable for 30% of the time, what fraction of the time must enhancement 3 be used to achieve an overall speedup of 10?

Exercise 6 - a (sol) By applying Amdahl’s Law to three enhancements we find Overall Speedup = 1 / [(1 – ∑ FE i ) + ∑ (FE i / SE i )] = 1 / [1 – (FE 1 + FE 2 + FE 3 ) + ((FE 1 /SE 1 ) + (FE 2 /SE 2 ) + (FE 3 /SE 3 ))] By replacing every known variable by its value in the equation, we get: 10 = 1 / [1 – (0.3 + 0.3 + FE 3 ) + ((0.3/30) + (0.3/20) + (FE 3 /10))] Solving for FE3 we get 1 = 10 x (1 - 0.3 - 0.3 + 0.3/30 + 0.3/20 - FE 3 + FE 3 /10) = 4.25 – 9FE 3 Which means FE 3 = 3.25 / 9 = 0.361111… Thus, Enhancement 3 must be used around 36% of the time.

Exercise 6 - b b. Assume for some benchmark, the fraction of use is 15% for each of enhancements 1 and 2 and 70% for enhancement 3. We want to maximize performance. If only one enhancement can be implemented, which should it be? If two enhancements can be implemented, which should be chosen?

Exercise 6 – b (sol) When we can choose between enhancements, we pick the one or combination that offers the highest speedup. Following that logic, and if we can pick only one enhancement, Speedup E1 = 1 / [(1 – FE 1 ) + (FE 1 /SE 1 )] = 1 / [(1 – 0.15) + (0.15/30))] = 1.169 Speedup E2 = 1 / [(1 – FE 2 ) + (FE 2 /SE 2 )] = 1 / [(1 – 0.15) + (0.15/20))] = 1.166 Speedup E3 = 1 / [(1 – FE 3 ) + (FE 3 /SE 3 )] = 1 / [(1 – 0.70) + (0.70/10))] = 2.703 Since the Speedup provided by enhancement 3 is the highest, we choose it.

Exercise 6 – b (sol) But if two enhancements can be implemented, we will need to find the best combination which means finding the speedup for all combinations and comparing them Speedup E1 and E2 = 1 / [(1 – FE 1 – FE 2 ) + (FE 1 /SE 1 + FE 2 /SE 2 )] = 1 / [(1 – 0.15 – 0.15) + (0.15/30 + 0.15/20))] = 1.403 Speedup E1 and E3 = 1 / [(1 – FE 1 – FE 3 ) + (FE 1 /SE 1 + FE 3 /SE 3 )] = 1 / [(1 – 0.15 – 0.70) + (0.15/30 + 0.70/10))] = 4.444 Speedup E2 and E3 = 1 / [(1 – FE 2 – FE 3 ) + (FE 2 /SE 2 + FE 3 /SE 3 )] = 1 / [(1 – 0.15 – 0.70) + (0.15/20 + 0.70/10))] = 4.396 Since the Speedup provided by the combination of enhancements 1 and 3 is the highest, we choose them.

Similar presentations