178k views
3 votes
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. a. Find the average CPI for each program given that the processor has a clock cycle time of 1 ns. b. Assume the compiled programs run on two different processors. If the execution times on the two processors are the same, how much faster

1 Answer

5 votes

Answer:

1.1

1.25

Clock rate A = 0.733 clock rate B

Step-by-step explanation:

Given the following :

Clock cycle time = 1ns = 10^-9 s

COMPILER A:

Instruction count = 1.0E9

Execution time = 1.1 s

COMPILER B:

Instruction count = 1.2E9

Execution time = 1.5 s

Using the relation :

CPI = [Execution time / (instruction count × cycle time)]

CPI for compiler A :

[1.1 / (10^9 × 10^-9)] = 1.1 / 10^0 = 1.1 / 1 = 1.1

CPI for compiler B:

[1.5 / (1.2 ×10^9 * 10^-9)]

(1.5 / 1.2 * 1) = 1.5 / 1.2 = 1.25

b. Assume the compiled programs run on two different processors. If the execution times on the two processors are the same, how much faster

Since, execution time is the same on both processors

Execution time = [(Instruction count × CPI) / clock rate] ;

[(Instruction count × CPI) / clock rate] A = [(Instruction count × CPI) / clock rate] B

Make clock rate of A the subject of the formula :

(Instruction count A * CPI A * clock rate B) / (instruction count B * CPI B)

= (10^9 * 1.1 * clock rate B / 1.2 × 10^9 * 1.25)

1.1 × 10^9 clock rate B / 1.5 × 10^9

Clock rate A = 0.733 clock rate B

User Mei
by
5.8k points