Solution of Sample Exercises in Chapter 2 2.4
Solution of Sample Exercises in Chapter 2 2.4
2.4
We are given the number of cycles per second and the number of seconds, so we
can calculate the number of required cycles for each machine. If we divide this by the
CPI well get the number of instructions.
For M1, we have
3 seconds 200 106cycles/second = 600 10 cycles per program / 10 cycles per
instruction = 60 106instructions per program.
For M2, we have
4 second 300 106 cycles/second = 1200 106cycles per program / 9.4 cycles per
instruction = 127.7 106instructions per program.
2.9
We do this problem by finding the amount of time that program 2 can be run in an
hour and using that for executions per second, the throughput measure.
3600
Executions of P2 per hour=
seconds
seconds
200
hour
Execution of P1
seconds
Execution of P2
3600
3600
Executions of P2 per hour on M2=
seconds
200 100
1600
hour
=
= 53
3
3
seconds
200 5
2600
hour
=
= 650
4
4
650
=1.2 times
533
faster than M1. The cost-effectiveness of the machines is to be measured in units
of throughput on program 2 per dollar, so
With performance measured by throughput for program 2, machine M2 is
Cost-effectiveness of M1=
533
= 0.053
10,000
Cost-effectiveness of M2=
650
= 0.043
15,000
Thus, M1 is more cost-effective than M2. (Machine costs are from Exercise 2.5.)
2.12
2.18
M1 would be as fast if the clock rate were 1.25 higher, so 500 1.25 = 625 MHz.
CPI for Mbase = 2 0.4 + 3 0.25 + 3 0.25 + 5 0.1 = 2.8
CPI for Mopt = 2 0.4 + 2 0.25 + 3 0.25 + 4 0.1 = 2.45
2.21
This problem can be done in one of two ways. Either find the new mix and adjust
the frequencies first or find the new (relative) instruction count and divide the CPI by
that. We use the latter.
Ratio of instructions=0.9 0.4+0.9 0.25+0.85 0.25+0.1 0.95=0.81
2.29
Program
Program 1 (seconds)
Weight
10
Computer A
1
Computer B
10
Computer C
20
Program 2 (seconds)
1000
100
20
9.18
18.2
20
Weighted AM
So B is fastest; it is 1.10 times faster than C and 5.0 times faster than A. For an equal
number of executions of the programs, the ratio of total execution times A:B:C is
1001:110:40, thus C is 2.75 times faster than B and 25 times faster than A.
2.44
Using Amdahls law (or just common sense) we can determine the following:
Speedup if we improve only multiplication =100/(30+50+20/4)=1.18
Speedup if we only improve memory access =100/(100-(50-50/2))=1.33
Speedup if both improvements are made=100/(30+50/2+20/4)=1.67