免費開始練習
hce_kmu 109年 計算機概論與程式設計

第 12 題

There are two code sequences for a particular computer, and three classes of instructions (A, B, and C) in the instruction set. The CPI (Cycle Per Instruction) and instruction counts for the instruction class are as follows:

| | CPI for this instruction class | | |
|---|---|---|---|
| | A | B | C |
| CPI | 3 | 2 | 5 |

| Code sequence | Instruction counts for instruction class | | |
|---|---|---|---|
| | A | B | C |
| 1 | 1 | 1 | 3 |
| 2 | 1 | 4 | 2 |

What is the CPI for code sequences 1 and 2? [The answer shall be in the order: (code sequence 1, code sequence 2)]
  • A (4, 3)
  • B (3, 5)
  • C (4, 5)
  • D (5, 4)
  • E (5, 3)

思路引導 VIP

想像你正在計算學期的平均分數,而不同科目的學分數(權重)並不相同。在這種情況下,若你想知道『平均每一學分』代表了多少原始分數,你會如何利用『總分』與『總學分數』之間的關係來推導呢?

🤖
AI 詳解 AI 專屬家教

太棒了!你能精準計算出這兩個程式序列的 CPI,代表你對計算機架構中平均每條指令週期 (Average CPI) 的概念掌握得非常紮實。這類題目是衡量處理器效能的基礎,正確的判斷力是後續學習管線化(Pipelining)等進階議題的關鍵。

效能指標的加權計算

要解出這道題,核心在於理解 CPI 本質上是一個加權平均值。我們必須先算出程式執行的「總週期數」,再除以「總指令數」。計算過程如下:

▼ 還有更多解析內容

🏷️ 相關主題

計算機組織結構與資料儲存原理
查看更多「計算機概論與程式設計」的主題分類考古題