Assignment 1 Solution_29e8954948de09f86fb86e13da78933d

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

NDJ20903 COMPUTER SYSTEM 2023/2024 Sem 2

ASSIGNMENT 1 : CPU PERFORMANCE CALCULATION


SUBMISSION DATE : Wednesday, 14/02/2024
Time : 12.00pm Noon
SOLUTION 30 marks

1. Suppose the following 8051 delay subroutine is used for a certain program

DELAY : MOV R2, #250


AGAIN : MOV R3, #250
HERE : NOP
NOP
DJNZ R3, HERE
DJNZ R2, AGAIN
RET

SOLUTION
Label instruction cycle
DELAY : MOV R2,#250 2
AGAIN : MOV R3,#250 2
HERE : NOP 1
NOP 1
DJNZ R3,HERE 2
DJNZ R2,AGAIN 2
RET 1

(a) Determine the total number of instructions that runs throughout this
subroutine.
((3x250) + 2)x250 + 2 = 188,002 total number of instructions

(b) Determine the average cycles per instruction for this subroutine.
Total cycles = ((4x250) + 4)x250 + 3 = 251,003 cycles
Average CPI = total cycle / total instruction
= 251,003 / 188,002
= 1.33 @ 1.34

(c) If the microcontroller is running on an 11.0592MHz clock, determine the total


execution time for this subroutine.
1 cycle time, ct = 12T ➔ 12 / f ➔ 12 / 11.0592 MHz ➔ 1.085 us

Total execution time = I x CPI x ct


= 251,003 x 1.085 us
= 272.35 ms @ 0.272 s

(d) Detemine the throughput for this program.


Throughput (MIPs) = f / (CPI x 106) = (11,059,200 / 12) / (1.34 x 106)
= 0.69 million instructions per second (MIPs)

[1]
Universiti Malaysia Perlis
NDJ20903 COMPUTER SYSTEM 2023/2024 Sem 2

2. Suppose you have a 242,500 instruction program with the following instruction mix :

Operation Frequency Clock Cycle


ALU 35% 1
Loads 25% 2
Stores 15% 2
Branches 25% 5

(a) What is the total number of clock cycles to complete this program?
ALU cycles = 35% of 242,500 = 84,875 x 1 = 84,875 cycles
Loads cycles = 25% of 242,500 = 60,625 x 2 = 121,250 cycles
Stores cycles = 15% of 242,500 = 36,375 x 2 = 72,750 cycles
Branches cycles = 25% of 242,500 = 60,625 x 5 = 303,125 cycles

Total number of clcock cycles = 582,000 clock cycles.

(b) Compute the CPI.


Average cycles per instruction, CPI = total clock cycles / total instructions
CPI = 582,000 / 242,500
= 2.4
Or
CPI = (0.35x1) + (0.25x2) + (0.15x2) + (0.25x5)
= 2.4

(c) If the program runs on a 500MHz processor, what is the execution time for
each operation?
1 cycle time, ct = t = 1/f ➔ 1 / 500 x 106 ➔ 2 ns

Execution time, TEX = I x CPI x ct, where I x CPI = total clock cycles, C
Execution time for each operation :
ALU = 84,875 x 2 ns = 169.75 us
Loads = 121,250 x 2 ns = 242.5 us
Stores = 72,750 x 2 ns = 145.5 us
Branches = 303,125 x 2 ns = 606.25 us

(d) What is the total execution time for this program?


Total execution time, TEX = 1.164 ms

[2]
Universiti Malaysia Perlis
NDJ20903 COMPUTER SYSTEM 2023/2024 Sem 2

(e) We observe that 35% of the ALU operation are paired with a load, and thus a
new program version with an additional operation is introduced. The new
operation takes 2 clock cycle but reduces the branch cycle to 3. Show the new
version’s table of instruction mix.
Operation Frequency Clock Cycle
ALU 23% 1
ALU+Loads 12% 2
Loads 25% 2
Stores 15% 2
Branches 25% 3

(f) Compute the CPI for the new version.


New CPI = (0.23x1) + (0.12x2) + (0.25x2) + (0.15x2) + (0.25x3) = 2.02

(g) If the new version runs on the same processor, determine the performance
between the old and the new program.
Performance New / Performance Old =
TEXOld / TEXNew = 2.4 / 2.02 = 1.19 @ New is 19% faster

3. Consider a program with the following instruction mix

Operation Frequency Clock Cycle


ALU 60% 3.0
Loads 20% 2.5
Stores 20% 2.5

(a) If a software engineer produces an enhanced program that reduces a third of


the number of ALU operations, show the overall speedup using Amdahl’s Law.
Operation Frequency Clock Cycle CPI old CPI new
ALU 60% 3.0 1.8 (64%) 1.2
Loads 20% 2.5 0.5 (18%) 0.5
Stores 20% 2.5 0.5 (18%) 0.5

Speedup = 1 / ((1-F) + (F/s)) F = 0.64 & s = 0.6/0.4 = 1.5


= 1 / ((1-0.64) + (0.64/1.5)) = 1.27 @ new is 27% faster

(b) Prove this speedup through the performance calculation.


Per(new) / Per(old) = Tex(lod) / Tex(new)

(I x 2.8 x ct) / (I x 2.2 x ct) = 2.8/2.2 = 1.27 @ 27% faster

[3]
Universiti Malaysia Perlis

You might also like