Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An instruction set consists of three types of instructions, I1, I2, and I3, and

ID: 2072969 • Letter: A

Question

An instruction set consists of three types of instructions, I1, I2, and I3, and runs on microprocessor M with a clock rate of 1GHz. The table below shows (1) the number of cycles, C, required to execute each instruction type, and (2) the number of instructions of each type within two programs P1 and P2 based on this instruction set. What is the average number of cycles per instruction (CPI) for each program? Which program completes execution earlier? In general - i.e., not just for the cases described in this problem - when you compare two programs is it always true that the program with the better CPI has the faster execution time? Explain. Let us say that we have the freedom to change the clock period of microprocessor M without affecting any entries in the table above. Let the execution time of P1, executed at a clock frequency of 1GHz, be T units. At what clock speed should P2 be executed to ensure that it is also completed in exactly T units?

Explanation / Answer

2.

a. To calculate the average number of cycles per instruction ( CPI ) for each program:

Average number of cycles per instruction = sum of ( cycles per instruction x no. of instructions of that type ) / ( Total no. of instructions )

For program 1:

Average number of cycles per instruction = (2x 2000 ) + ( 1x 3000) + (3x 4000 ) / ( 2000 +3000+4000 ) = 19000/ (9000 ) = 2.11 cycles per instruction

For program 2:

Average number of cycles per instruction = ( 2x4000) + ( 1x2000) + ( 3x4000 )/ (4000+2000+4000)

= 22000/10000 = 2.2 cycles per instruction

b.

Time taken to complete first program: (2x2000 + 1x3000 + 3x4000 ) x 10 e-9 sec = 19000x10-9 sec ( since clock rate is 1 GHz, one cycle time 1/10e9 = 10e-9sec )

Time taken to complete second program: (2x4000 + 1x2000 + 3 x 4000 )x 10e-9 sec = 22000x10e-9 sec

Therefore the first program finishes execution earlier.

c. CPI indicates the no. of cycles needed to complete one instruction. Since the clock rate is fixed and the no. of cycles is a direct measure of time. Therefore, more the no. of cycles more is the time and less the no. of cycles, less is the time.

Thus if CPI is low, it means the time taken to execute one onstruction is less. Similarly, if CPI is high, it means time taken to execute one instruction is high. Since a program is a set of instructions, more CPI time, more is the program execution time. Similarly, lower the CPI, faster is the execution time.

d.

The execution time of P1 with 1GHz clock = T units

From the calculation in b above, T = 19000 x 10e-9 sec

Let the clock speed of P2 execution be ‘X’ GHz. Then the time taken to complete P2 program would be : ( 4000x2 ) + ( 1x 2000 ) + ( 3x4000) / X x 10e9 sec = 22000 x 10e-9 / X sec

Equating this to T, we get

22000 x 10e-9 / X = 19000 x 10e-9

X = 22000 x 10e-9 / 19000 x 10e-9 = 1.158 GHz

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote