題組內容
二、一個 2 GHz 的處理器用來執行下列的指令組合,其統計如下。(每小 題 10 分,共 20 分)
Integer Arithmetic:Instruction Count = 60000 Clock Cycle Count = 1
Data Transfer: Instruction Count = 35000 Clock Cycle Count = 2
Floating Point: Instruction Count = 55000 Clock Cycle Count = 4
Control Transfer: Instruction Count = 30000 Clock Cycle Count = 3
Integer Arithmetic:Instruction Count = 60000 Clock Cycle Count = 1
Data Transfer: Instruction Count = 35000 Clock Cycle Count = 2
Floating Point: Instruction Count = 55000 Clock Cycle Count = 4
Control Transfer: Instruction Count = 30000 Clock Cycle Count = 3
(一)計算平均的 CPI(Cycles Per Instruction)。
詳解 (共 1 筆)
詳解
要計算平均的CPI(Cycles Per Instruction),首先我們需要知道每類指令的總時鐘週期數,然後將這些總時鐘週期數加起來,再除以總的指令數。
給出的數據如下:
-
Integer Arithmetic:
- 指令數:60000
- 每個指令的時鐘週期數:1
- 總時鐘週期數:60000 * 1 = 60000
-
Data Transfer:
- 指令數:35000
- 每個指令的時鐘週期數:2
- 總時鐘週期數:35000 * 2 = 70000
-
Floating Point:
- 指令數:55000
- 每個指令的時鐘週期數:4
- 總時鐘週期數:55000 * 4 = 220000
-
Control Transfer:
- 指令數:30000
- 每個指令的時鐘週期數:3
- 總時鐘週期數:30000 * 3 = 90000
現在計算所有指令的總時鐘週期數和總的指令數:
-
總時鐘週期數: 60000+70000+220000+90000=44000060000 + 70000 + 220000 + 90000 = 44000060000+70000+220000+90000=440000
-
總的指令數: 60000+35000+55000+30000=18000060000 + 35000 + 55000 + 30000 = 18000060000+35000+55000+30000=180000
平均的CPI可以用以下公式計算:
平均CPI=總時鐘週期數總的指令數\text{平均CPI} = \frac{\text{總時鐘週期數}}{\text{總的指令數}}平均CPI=總的指令數總時鐘週期數將數值代入公式:
平均CPI=440000/180000≈2.44因此,平均的CPI為2.44。