15 pts 3 A Compiler designer is trying to decide between two

(15 pts) 3. A Compiler designer is trying to decide between two code sequences for a computer. The hardware designer have supplied the following facts, there are 4 category of instruction class, A, B, C and D, the CPI for each is given below category of the instuction CPI for this struction class CPI For a particular HLL statement, the compiler writer is considering two code sequences that requires the following instruction counts Code Instruction Counts for instruction class sequence G.1 5 pts): Which code sequence execute the most instruction (3.2 5 pts): Which code sequence will be faster G.3 5 pts): What is the overall CPI for each sequence?

Solution

1.Which code sequence executes the most instruction ?

Let\'s count the number of cycles needed to execute each code:
First code sequence: No. of cycles = 2x1 + 1x2 + 2x3 + 2x5 = 20 cycles.
Second code sequnce : No. of cycles = 4x1 + 1x2 + 2x3 +1x5 = 17 cycles.

Therefore the firstcode sequence executes the most instruction.

2.Which code squence will be faster?

Let\'s count the number of cycles needed to execute each code:
First code: No. of cycles = 2x1 + 1x2 + 2x3 + 2x5 = 20 cycles.
Second code: No. of cycles = 4x1 + 1x2 + 2x3 +1x5 = 17 cycles.

Therefore the second code is faster because it requires less number of cycles to execute.

(# cycles 1)/(# of cycles 2) = 20/17 = 1.17…
Therefore the second code 2 is faster than the first code by 1.17 times.

3.What is the overall CPI for each squence?

CPI1= CPU_cycles1/ Instruction_count1= 20/7 = 2.8
CPI2= CPU_cycles2/ Instruction_count2= 17/8 = 2.1

 (15 pts) 3. A Compiler designer is trying to decide between two code sequences for a computer. The hardware designer have supplied the following facts, there a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site