1.6
[20] <§1.6> Consider two diff erent implementations of the same instruction
set architecture. Th e instructions can be divided into four classes according to
their CPI (class A, B, C, and D). P1 with a clock rate of 2.5 GHz and CPIs of 1, 2, 3,
and 3, and P2 with a clock rate of 3 GHz and CPIs of 2, 2, 2, and 2.
Given a program with a dynamic instruction count of 1.0E6 instructions divided
into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D,
which implementation is faster?
a. What is the global CPI for each implementation?
b. Find the clock cycles required in both cases.
C P I 1 = 1 × 10 % + 2 × 20 % + 3 × 50 % + 3 × 20 % = 2.6 C P I 2 = 2 × 10 % + 2 × 20 % + 2 × 50 % + 2 × 20 % = 2 CPI_1 = 1 \times 10\% + 2\times20\%+3\times 50\%+3\times20\%=2.6\\CPI_2 = 2 \times 10\% + 2\times20\%+2\times 50\%+2\times20\%=2 CPI1=1×10%+2×20%+3×50%+3×20%=2.6CPI2=2×10%+2×20%+2×50%+2×20%=2
c l o c k c y c l e = C P I × I n s t r u c t i o n s f o r a p r o g r a m C P U 时 钟 周 期 数 = 程 序 指 令 数 × 指 令 平 均 周 期 数 clock\ cycle = CPI\times Instructions\ for\ a\ program\\ CPU时钟周期数 = 程序指令数 \times 指令平均周期数 clock cycle=CPI×Instructions for a programCPU时钟周期数=程序指令数×指令平均周期数
T 1 = 2.6 × 1.0 × 1 0 6 = 2.6 × 1 0 6 T 2 = 2 × 1.0 × 1 0 6 = 2 × 1 0 6 T_1 = 2.6\times 1.0\times 10^6 = 2.6\times 10^6\\ T_2 = 2\times 1.0\times 10^6 = 2\times 10^6 T1=2.6×1.0×106=2.6×106T2=2×1.0×106=2×106
1.7
[15] <§1.6> 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.
C P I = C P U 时 钟 周 期 数 程 序 指 令 数 = C P U 执 行 时 间 时 钟 周 期 长 度 × 程 序 指 令 数 CPI = \frac{CPU时钟周期数}{程序指令数} = \frac{CPU执行时间}{时钟周期长度\times 程序指令数} CPI=程序指令数CPU时钟周期数=时钟周期长度×程序指令数CPU执行时间
C P I A = 1.1 ( 1.0 × 1 0 − 9 ) ( 1.0 × 1 0 9 ) = 1.1 CPI_A=\frac{1.1}{(1.0\times10^{-9})(1.0\times 10^{9})} = 1.1 CPIA=(1.0×10−9)(1.0×109)1.1=1.1
C P I B = 1.5 ( 1.0 × 1 0 − 9 ) ( 1.2 × 1 0 9 ) = 1.25 CPI_B=\frac{1.5}{(1.0\times10^{-9})(1.2\times 10^{9})} = 1.25 CPIB=(1.0×10−9)(1.2×109)1.5=1.25
b. Assume the compiled programs run on two diff erent processors. 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?
F a s t e r = T I M E B T I M E A = 1.5 1.1 = 1.363 Faster = \frac{TIME_B}{TIME_A}=\frac{1.5}{1.1} = 1.363 Faster=TIMEA