Compilers can have a profound impact on the performance of an applicat

Miguel Reynolds

Miguel Reynolds

Answered question

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

Beginner2021-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

Beginner2021-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

xleb123

xleb123

Skilled2023-05-10Added 181 answers

Explanation:
a) To find the average CPI (Cycles Per Instruction) for each program, we can use the formula:
CPI=Execution TimeInstruction Count
For compiler A, with a dynamic instruction count of 1.0×109 and an execution time of 1.1 s:
CPIA=1.1s1.0×109
For compiler B, with a dynamic instruction count of 1.2×109 and an execution time of 1.5 s:
CPIB=1.5s1.2×109
b) If the execution times on the two processors are the same, we can find the ratio of their clock cycle times. Let's assume the clock cycle time for both processors is t (1 ns = 1×109 s). The execution time formula can be rearranged as:
ExecutionTime={Instruction Count}×CPI×{Clock Cycle Time}
For compiler A:
1.1s=1.0×109×CPIA×t
For compiler B:
1.5s=1.2×109×CPIB×t
By dividing the above two equations, we can find the ratio of their clock cycle times:
1.1s1.5s=1.0×109×CPIA×t1.2×109×CPIB×t
Simplifying the equation will give us the relative clock speeds.
c) For the new compiler with an instruction count of 6.0×108 and an average CPI of 1.1, we can calculate its execution time on the original processor using the formula:
ExecutionTime={Instruction Count}×CPI×{Clock Cycle Time}
Comparing this execution time with the execution time of compiler A and B, we can find the speedup:
Speedup=Execution Time of Previous CompilerExecution Time of New Compiler

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

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

Didn't find what you were looking for?