banner

Compilers can have a profound impact on the performance of an application. 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.

  1. Given that the processor’s clock cycle time is 1 ns, calculate each program’s average CPI under this situation.
  2. Assume there are two processors being used to run the compiled programs. How much quicker is the clock on the processor executing compiler A’s code compared to the clock on the processor executing compiler B’s code if the runtime here on two processors are equal?
  3. A new compiler with an average CPI of 1.1 and only 6.0E8 instructions is created. How much faster is this new compiler than compilers A or B while running just on original processor?

This question aims to find the average CPI for the given compilers, the speed of the clock, and the speedup for the new compiler.

This question uses the concept of average CPI. The weighted average of the CPIs for each instruction, multiplied by the percentage of time each instruction is used, represents the average CPI.

Expert Answer

a) We know that:

\[CPU time \space = \space instructions \space \times CPU \space \times cycle time\]

\[CPI \space = \space \frac{COU time}{instructions \space \times \space cycle time}\]

Now for compiler $ A $, we know that:

\[CPI_A \space = \space \frac{COU time_A}{instructions_A \space \times \space cycle time}\]

By putting values, we get:

\[= \space \frac{1.1}{10^9 \space \times \space 10^{-9}}\]

\[= \space 1.1 \]

Now for compiler $B$, we know that:

\[CPI_B \space = \space \frac{COU time_B}{instructions_B \space \times \space cycle\ time}\]

\[= \space \frac{1.5}{1.2 \space \times 10^9 \space \times \space 10^{-9}}\]

\[= \space 1.25 \]

b) We know that:

\[ Execution\ Times = Instruction\ \times CPI\ clock\ rate \]

Execution time is the same, so:

\[instructions_1 \space \times CPI_1 \space clock\ rate_1 \space = \space  instructions_2 \space \times CPI_2 \space clock\ rate_2  \]

By putting values, we get:

\[= \space \frac{10^9 \space \times \space 1.1}{1. \space \times \space 10^9 \space \times \space 1.25} \space \times \space clock rate_2 \]

\[= \space 0.73 clock rate_2 \]

c) We know that:

\[CPU \space \times \space time_c \space = \space 0.66s \]

So:

\[\frac{performance_c}{performance_a} \space = \space \frac{CPU time_A}{CPU time_C} \space = \space 1.67 \]

\[\frac{performance_c}{performance_a} \space = \space \frac{CPU time_A}{CPU time_C} \space = \space 1.67 \]

\[\frac{performance_C}{performance_B} \space = \space \frac{CPU time_B}{CPU time_C} \space = \space 2.27 \]

Numerical Answer

The average CPI time for compiler $A$ is 1.1 and for compiler $ B $, it is 1.25.

The clock rate_1 is equal to $ 0.73 clock rate_2$.

Compiler $ C $ is $1.67$ times faster than compiler $ A $.

Example

Given that the processor’s clock cycle time is 1 ns, calculate each program’s average CPI under this situation when compiler A has an instruction count of $1.0E9$ with an execution time of $ 1.5s $ and compiler $B $ has an instruction count of $ 1.3E9 $with an execution time of $1.6s$.

We know that:

\[CPU time \space = \space instructions \space \times CPU \space \times cycle time\]

\[CPI \space = \space \frac{COU time}{instructions \space \times \space cycle time}\]

Now for compiler $ A $, we know that:

\[CPI_A \space = \space \frac{COU time_A}{instructions_A \space \times \space cycle time}\]

By putting values, we get:

\[= \space \frac{1.5}{10^9 \space \times \space 10^{-9}}\]

\[= \space 1.5 \]

Now for compiler $B$, we know that:

\[CPI_B \space = \space \frac{COU time_B}{instructions_B \space \times \space cycle time}\]

\[= \space \frac{1.6}{1.3 \space \times 10^9 \space \times \space 10^{-9}}\]

\[= \space 1.23 \]

5/5 - (16 votes)