Compilers can significantly affect how well an application performs. Assume that for a program, compiler...

Miguel Reynolds

Miguel Reynolds

Answered

2021-12-23

Compilers can significantly affect how well an application performs. Assume that for a program, compiler A results in a dynamic instruction count of 1.0E9 and has an execution time of 1.1 s, while compiler B results in a dynamic instruction count of 1.2E9 and an execution time of 1.5 s. 
a. Find the average CPI for each program given that the processor has a clock cycle time of 1 ns. 
b. Assume there are two processors being used to run the compiled programs. If the execution times on the two processors are the same, how much faster is the clock of the processor running compiler A’s code versus the clock of the processor running compiler B’s code? 
c. A new compiler is developed that uses only 6.0E8 instructions and has an average CPI of 1.1. What is the speedup of using this new compiler versus using compiler A or B on the original processor?

Answer & Explanation

nghodlokl

nghodlokl

Expert

2021-12-24Added 33 answers

Step 1
a) Remember that
CPU time=instructions×CPU×cycle time,
thus
CPI=COU timeinstructions×cycle time
Here cycle time =1ns=109s. Additionally, execution time in this context =CPU time. So, for complier A, we have that
CPIA=CPU timeAinstructionsA×cycle time=1.1s109×109s=1.1
For compiler B, we have
CPIB=CPU timeBinstructionsB×cycle time=1.5s1.2×109×109s=1.25
Step 2
b) Recall that
execution time=CPU time=instructions×CPIclock rate
So, since execution times in both cases are the same,
execution time1=execution time2
which yields
instructions1×CPI1clock rate1=instructions2×CPI2clock rate2
Therefore, after rearranging,
clock rate1=instructions1×CPI1instructions2×CPI2×clock rate2=109×1.11.2×109×1.25×clock rate2
So,
clock rate1=0.73clock rate2
So, the clock rate of processor 1 is actually approximately 27% slower than the clock rate of processor 2.
Step 3
c) We use the same formula as in (a):
CPU timeC=instructionsC×CPIC×cycle time=6×108×1.1×109s=0.66s
So,
performanceCperformanceA=CPU timeACPU timeC=1.1s0.66s=1.67
performanceCperformanceA=CPU timeACPU timeC=1.5s0.66s=2.27
So, C is faster than A approximately 1.67 times, and faster than B approximately 2.27 times.

Paineow

Paineow

Expert

2021-12-25Added 30 answers

Step 1
Given
Cycle Time =1ns=109
CPU Time for A =1.1s
Instruction count =109
CPU Time for B =1.5s
Instruction Count =1.2×109
CPU Time=Instructions×Cycle Time×CPI
So, CPI=CPU TimeInstructions×Cycle Time
CPI for A=1.1109×109
CPI=1.1
CPI for B=1.51.2×109×109
CPI=1.512
CPI=1.25
Step 2
Given
Execution Time on A=Execution Time on B
CPU Time for A=1.1s
Instruction count=109
CPI=1.1
CPU Time for B=1.5s
Instruction Count =1.2×109
CPI=1.25
Execution Time=Instructions×CPIClock Rate
Execution Time A=Execution Time B
InstructionA×CPIAClock RateA=InstructionB×CPIBClock RateB.
Make Clock Rate A the subject of formula
Clock RateA=InstructionA×CPIA×Clock RateBInstructionB×CPIB
Clock RateA=109×1.1×Clock RateB1.2×109×1.25
Clock RateA=0.73Clock RateB
So the clock rate of A is 27% slower than clock rate of B
Step 3
For compiler A and C,
CPU Time=Instructions×Cycle TimeCPI
CPU Time of C=6×108×1.1×109=0.66s
Using ratio of CPU time and Compiler performance i,e.
CPU Time of A×Performance of A=CPU Time of C×Performance of C
Given
CPU Time of A=1.1
CPU Time of C=0.66
1.1×Performance of A=0.66×Performance of C

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get your answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?