### Computer Organization_exercises_lab_1

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 – ∑ FEi) + ∑ (FEi / SEi)]
– 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 109) =
0.75 N x 10-9
• Time taken to execute on P2 is = N/ (1.5 x 109) =
0.66 N x 10-9
• Time taken to execute on P3 is = 2.5 N/ (3 x 109) =
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:
P1
P2
P3
clock rate
CPI
2 GHz
1.5 GHz
3 GHz
1.5
1.0
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 N1/ (2 x 109)
– So N1 (number of instructions) = 1.33 x 1010
– Number of Cycles = 1.5 x N1 = 2 x 1010
• …Do the same for P2 and P3
Exercise 4
• Given below are the number of instructions of
a program:
arithmetic
store
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 109)
– 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
a)
b)
1.0 x 109
1.4 x 109
exec. Time
1s
0.8 s
no. instructions
1.2 x 109
1.2 x 109
exec. Time
1.4 s
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 109 ) = 1
• For program a on Compiler B
– CPI = 1.4 / (10-9 x 1.2 x 109 ) = 1.667
• Do the same for program b…
Exercise 6 - a
• Three enhancements with the following
speedups are proposed for a new architecture:
Speedup1 = 30
Speedup2 = 20
Speedup3 = 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 – ∑ FEi) + ∑ (FEi / SEi)]
= 1 / [1 – (FE1 + FE2 + FE3) + ((FE1/SE1) + (FE2/SE2) + (FE3/SE3))]
• By replacing every known variable by its value in the equation, we
get:
10 = 1 / [1 – (0.3 + 0.3 + FE3) + ((0.3/30) + (0.3/20) + (FE3/10))]
• Solving for FE3 we get
1 = 10 x (1 - 0.3 - 0.3 + 0.3/30 + 0.3/20 - FE3 + FE3/10) = 4.25 – 9FE3
• Which means FE3 = 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,
SpeedupE1 = 1 / [(1 – FE1) + (FE1/SE1)] = 1 / [(1 – 0.15) + (0.15/30))] = 1.169
SpeedupE2 = 1 / [(1 – FE2) + (FE2/SE2)] = 1 / [(1 – 0.15) + (0.15/20))] = 1.166
SpeedupE3 = 1 / [(1 – FE3) + (FE3/SE3)] = 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
SpeedupE1 and E2 = 1 / [(1 – FE1 – FE2) + (FE1/SE1 + FE2/SE2)]
= 1 / [(1 – 0.15 – 0.15) + (0.15/30 + 0.15/20))] = 1.403
SpeedupE1 and E3 = 1 / [(1 – FE1 – FE3) + (FE1/SE1 + FE3/SE3)]
= 1 / [(1 – 0.15 – 0.70) + (0.15/30 + 0.70/10))] = 4.444
SpeedupE2 and E3 = 1 / [(1 – FE2 – FE3) + (FE2/SE2 + FE3/SE3)]
= 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.