免費詳解 / 中山 / 硬體 / 105

105 中山資工所考古題解答|硬體逐題詳解

105 中山資工所硬體考古題的逐題詳解,共 5 題,免費公開。

逐題詳解

120%

SIMD, SIMT, VLIW, Superscalar, Superpipeline

1.1 (4%) Explain the major features of single instruction multiple data (SIMD) processor. In other words, point out the major differences between SIMD CPU and conventional CPU. Give a practical example of SIMD instructions, CPU, or computer.

1.2 (4%) Compare the differences of thread and process. Is context switching the change of threads or the change of process?

1.3 (4%) Explain the major features of single instruction multiple threads (SIMT) processor. Give a practical example of SIMT computer.

1.4 (4%) Explain the major features of very long instruction word (VLIW) processor. Which processor category does VLIW belong to, static multiple issue or dynamic multiple issue?

1.5 (4%) What is a superscalar processor? What is a superpipeline processor?

1.1 SIMD:一條指令同時對多筆資料做同樣的運算(data-level parallelism)。只有一個 control unit、一個 PC,抓一次指令就把同一個運算廣播給多個 ALU,各自處理不同資料

conventional CPU(SISD):一條指令只處理一組運算元

例:x86 的 MMX/SSE/AVX、ARM NEON、vector processor(Cray)

1.2 process:有自己的 address space 與資源(code、data、open files);thread:同一 process 內的執行單位,共用 address space、code、data、files,各自有 PC、register、stack;thread 建立與切換成本低

context switch:存下目前執行單位的 state 再載入另一個;換到另一個 process 還要換 address space(page table、TLB),代價高;同一 process 內的 thread 之間只換 register 與 stack

一般所說的 context switch 指 process 之間的切換,thread 之間是較輕的一種

1.3 SIMT:SIMD 加 multithreading。程式以 scalar thread 的角度寫,硬體把一群 thread(warp,如 32 條)打包,同一時間執行同一條指令;每條 thread 有自己的 register 與(邏輯上的)PC,遇 branch 分歧時用 mask 依序執行各路徑;靠大量 thread 切換隱藏記憶體延遲

例:NVIDIA GPU(CUDA)

1.4 VLIW:一條很長的指令內含多個互相獨立的 operation(各有欄位),分派給不同功能單元同時執行;哪些 operation 可並行由 compiler 在編譯時決定,硬體不做 dynamic scheduling,電路簡單;缺點是執行時才知道的延遲(cache miss)只能保守填 nop

屬於 static multiple issue

例:Intel Itanium、TI C6000 DSP

1.5 superscalar:每個 clock cycle 發出多條指令(IPC \(\gt\) 1),由硬體在執行時動態挑選、檢查相依(dynamic multiple issue,常配 out-of-order)

superpipeline:把 pipeline 切成更多、更短的 stage,使 clock rate 提高(cycle time 變短)

220%

Cache

2.1 (4%) Give two methods to reduce cache miss rate. 2.2 (4%) Give two methods to reduce cache hit time. 2.3 (4%) Give two methods to reduce cache miss penalty.

2.4 (4%) For the following Figure 1, explain the reason why the miss rate goes down as the block size increases to a certain level, and explain the reason why the miss rate goes up if the block size is too large relative to the cache size.

10%5%0% 163264128256Block size 4K16K64K256K Miss rate

2.5 (4%) Explain the differences of write-allocate and no-write-allocate during cache write miss.

2.1 降低 miss rate:① 加大 block size(利用 spatial locality,減少 compulsory miss)② 提高 associativity(減少 conflict miss);也可加大 cache 容量、prefetch

2.2 降低 hit time:① 用小而簡單的 cache(direct-mapped,只比對一個 tag)② 用 virtually addressed(indexed)cache,hit 路徑不必先經 TLB 轉換;也可 way prediction

2.3 降低 miss penalty:① 加第二層 cache(L2)② critical word first+early restart(先搬需要的 word,到了就讓 CPU 繼續);也可用 write buffer、victim cache

2.4 miss rate 先降:block 變大,一次 miss 搬進更多相鄰 word,利用 spatial locality,之後對附近位址的存取直接命中(compulsory miss 被攤掉)

後升:cache 總容量固定,block 越大 block 數越少,不同位址競爭同一格的 conflict/capacity miss 增加,block 常在裡面的 word 還沒用幾個就被換出,白搬;miss penalty 也隨 block 變大而增加。圖中 4K 的曲線在 block 64 之後最先翹起,大 cache(64K、256K)block 佔的比例小,在圖上範圍內仍持平或下降

2.5 write-allocate:write miss 時先把該 block 從下層搬進 cache,再寫入(之後同 block 的寫入都在 cache 內完成,通常配 write-back)

no-write-allocate:write miss 時直接寫到下層記憶體,不把 block 帶進 cache(通常配 write-through)

320%

The execution of an instruction can be divided into five parts: instruction fetch (IF), register read (RR), ALU operation (EX), data access (MEM), and register write (RW). The following Table 1 shows the execution time of each part for several types of instructions, assuming that the multiplexors and control unit have no delay.

Instruction classInstruction fetchRegister readALU operationData accessRegister write
Load word (lw)200 ps100 ps200 ps200 ps100 ps
Store word (sw)200 ps100 ps200 ps200 ps
R-format (add, sub, AND, OR, slt)200 ps100 ps200 ps100 ps
Branch (beq)200 ps100 ps200 ps

If instructions are to be executed in a pipelined CPU with five pipeline stages, IF, RR, EX, MEM, RW where the pipeline stages execute the corresponding operations mentioned above.

3.1 (4%) What is the cycle time of the pipelined CPU? What is the maximum working frequency? 3.2 (4%) What is the latency of executing the load-word instruction (lw) in the pipelined CPU? 3.3 (4%) What is the latency of executing the add instruction (add) in the pipelined CPU? 3.4 (4%) What is the maximum throughput of the pipelined CPU? 3.5 (4%) Propose a design method to increase the throughput performance of the pipelined CPU.

各 stage:IF 200、RR 100、EX 200、MEM 200、RW 100 ps

3.1 cycle time 取最慢的 stage

200 ps;最高頻率 \(1/200\text{ ps}=5\) GHz

3.2 lw 走完 5 個 stage,每個 stage 一個 cycle:\(5\times200\)

1000 ps

3.3 add 在固定 5 級的 pipeline 仍要經過 MEM stage(空過),\(5\times200\)

1000 ps

單週期設計下 add 只要 600 ps;pipeline 讓單一指令變慢,換來 throughput。

3.4 pipeline 填滿後每個 cycle 完成 1 條指令

\(1/200\text{ ps}=5\times10^9\) 條指令/秒(5 GIPS)

3.5 ① 加深 pipeline(superpipeline):把 200 ps 的 IF、EX、MEM 各切成兩級,cycle time 降到 100 ps,理想 throughput 加倍(代價:branch penalty 與 forwarding/hazard 處理更複雜)

② 多發射(superscalar/multiple issue):每個 cycle 發出並完成多條指令,IPC \(\gt\) 1(代價:多組功能單元與更複雜的相依檢查)

420%

Memory Hierarchy. The following Figure 2 shows the process of going from a virtual address to a data item in cache. Answer the following questions based on this figure.

Figure 2 要點:virtual address 的 virtual page number 20 bits、page offset 12 bits;TLB 每一列有 Valid、Dirty、Tag、Physical page number,每列各有一個比較器,TLB hit;physical page number 20 bits 加 page offset 12 bits 組成 physical address;physical address 分成 tag 18 bits、cache index 8 bits、block offset 4 bits、byte offset 2 bits;cache 有 Valid、Tag、Data,index 選一列,tag 比較器輸出 cache hit,data 輸出 32 bits。

4.1 (4%) What is the purpose of the translation lookaside buffer (TLB)? 4.2 (4%) Is the TLB direct mapped, set associative, or full associative? Is the data cache direct mapped, set associative, or fully associative? 4.3 (4%) What is the page size? What is the block size of the data cache? 4.4 (4%) What is the size of the data cache (excluding the tags)? What is the maximum size of physical memory supported in this memory system? 4.5 (4%) Is the cache virtually addressed or a physically addressed?

由圖讀出欄位:

virtual address(32)virtual page number 20page offset 12
physical address(32)PPN 20 + page offset 12
cache 欄位(32)tag 18index 8block offset 4byte offset 2

4.1 TLB 是 page table entry 的快取,存最近用過的 virtual→physical 轉換;hit 時省掉讀 page table 的那次記憶體存取

4.2 TLB:每一列各有一個比較器,virtual page number 同時與所有 entry 的 tag 比對,沒有 index → fully associative

data cache:8 bits 的 index 直接指定唯一一列,只有一個 tag 比較器 → direct mapped

4.3 page offset 12 bits → page size \(2^{12}=\) 4 KB

block 內定位用 block offset 4 + byte offset 2 \(=6\) bits → block size \(2^6=\) 64 bytes(16 words)

4.4 cache 有 \(2^8=256\) 個 block,每個 64 B:\(256\times64=16\) KB(輸出的 32 bits 是從 block 中挑出的一個 word)

data cache 16 KB(不含 tag)

physical address \(=20+12=32\) bits:\(2^{32}\) bytes

最大實體記憶體 4 GB

4.5 virtual address 先經 TLB 轉成 physical address,再用 physical address 的 tag/index/offset 查 cache

physically addressed

520%

Answer the following questions.

5.1 (4%) What are the differences of arithmetic mean and geometric mean? Is geometric mean or arithmetic mean used by SPECINT2006 to summarize the speed measurements for several benchmark programs?

5.2 Figure 3 shows the growth in processor performance since mid-1980s (performance relative to VAX-11/780, from 1978 to 2012; labeled growth: 25%/year, then 52%/year, then 22%/year). Answer the following questions. (4%) Is the vertical axis of Figure 3 linear scale or log-scale? What is the growth rate, linear or exponential, if it is a straight line in a particular time interval in Figure 3? (4%) Give two possible reasons for the large performance growth rate from 1986 to 2002. (4%) Give two possible reasons to explain why the growth rate slows down after 2002.

5.3 (4%) Give two design methods to increase the performance of executing conditional branch instructions.

5.1 arithmetic mean:\(\dfrac1n\sum x_i\),用於執行時間,正比於總執行時間,會被最久的 benchmark 主導

geometric mean:\(\left(\prod x_i\right)^{1/n}\),用於正規化的比值(SPEC ratio);兩台機器 GM 的比值等於各 benchmark 比值的 GM,與選哪台當參考機器無關

SPECINT2006 用 geometric mean

5.2 縱軸是 log scale(1、10、100、…、100000 等距);log 軸上一段直線 → exponential 成長(每年固定百分比,如 52%/年)

1986~2002 成長快:① 製程進步(Moore's law):電晶體數與 clock rate 持續成長 ② 架構與組織改良:RISC、pipeline、cache 與記憶體階層、superscalar/out-of-order 挖 instruction-level parallelism、compiler 進步

2002 後變慢:① power wall:功耗與散熱撐不住,clock rate 無法再提高 ② ILP wall:單一指令流可挖的平行度已近極限,再加硬體報酬遞減;(memory wall:記憶體延遲改善遠慢於處理器)。之後改走多核心,需要程式明確平行化

5.3 ① branch prediction:dynamic predictor(1-bit/2-bit)配 branch target buffer 預測方向與目標位址,猜對沒有 penalty,猜錯才 flush

② 把 branch 的判斷提前:在 ID stage 就比較與算目標位址,錯誤預測要丟掉的指令由 3 條減為 1 條;或用 delayed branch,由 compiler 在 delay slot 放一條必定執行的有用指令

109–115 的詳解也是這樣寫的。

國立中山大學 109–115 的詳解收錄在付費版;106–115 全年度完整詳解共 236 頁,逐題推導。

購買 · NT$ 850 看中山其他免費詳解

其他年度與考科

同一年的其他科

同一科的其他年度

聯絡我們

題目有錯、詳解看不懂,都歡迎來信

想許願補哪一份、對購買有疑問也可以,收到後會盡快回覆。

william.chou.123123@gmail.com