Computer Architecture 1 ISA (INSTRUCTION SET ARCHITECTURE) (10%)
| ISA | Number of General registers | Number of FP registers |
|---|---|---|
| Intel X86 (80386) | 8 (eax to esp) | 8 (ST0 to ST7) |
| Intel X86-64 | 16 | 32 ZMM registers |
| Intel Itanium | 128 | 128 |
| ARMv7 (VPFv2) | 16 | 16 |
| ARMv8 | 31 | 32 |
The above table shows the number of registers provided by Intel x86, Intel/HP Itanium, and ARM ISA (Instruction Set Architecture).
A. (1 point) Please list one or more ISAs that provide no registers at all.
B. (5 points) Registers are usually used to hold temporaries. Modern compilers also use registers to hold frequently used local variables, pointers, and so on. Ideally, the more the registers, the more objects could be allocated to registers and memory references to those objects could be saved. The trend of ISA has clearly shown that new architectures tend to have more registers. So is it a good idea to take a quantum leap to go for 1024 registers in an ISA. You must argue for your answer, just say yes or no will get no credits.
C. (2 points) In each ISA's calling convention, the set of general purpose registers is usually divided into caller-save and callee-save two subsets. Which type of procedures could benefit most from such a register partition?
D. (2 points) Most ISAs have separate register files: general purpose registers, floating point registers, and SIMD (e.g. Intel SSE/ZMM and ARM Neon) registers. Why do most modern ISAs provide different set of registers? Would it be better to use just one set of general purpose registers? For example, we could have instructions such like: Add R1,R2,R3 /* integer add */, FADD R1,R2,R3 /* Floating point add */, PADD R1,R2,R3 /* SIMD Add */. Although these are different type of instructions, they could use the same general purpose registers.
A. stack machine 型的 ISA:運算元放在 stack 頂、運算結果放回 stack,指令不指定暫存器(例:Java bytecode/JVM、WebAssembly、Burroughs B5000)。memory-to-memory 的 ISA 也沒有暫存器
stack machine(如 JVM bytecode)
B. 不是好主意:
① 指令編碼:1024 個要 10 bit,三運算元(add rd,rs,rt)就用掉 30 bit,32-bit 指令只剩 2 bit 給 opcode 等欄位,指令得變長
② register file 越大越慢、越耗電、越佔面積:位址解碼與 bit line 變長,加上要多個 read/write port,面積約隨 port 數平方成長 → 可能拉長 clock cycle,抵銷少存取記憶體的好處
③ 報酬遞減:compiler 能同時放進暫存器的活著的變數有限,從 16 到 32 個已降低大多數 spill;再多也用不到
④ context switch、interrupt、procedure call 要存回/還原的狀態變成 1024 個暫存器,延遲與 stack 流量變大(callee-save 規定更貴)
NO:編碼位元、存取時間/功耗、報酬遞減、context switch 成本都會變差
C. leaf procedure(不再呼叫別的 procedure)受益最大:可直接使用 caller-save 暫存器,不用在 entry/exit 存回與還原,沒有任何 stack 存取;non-leaf procedure 把跨越 call 還活著的值放在 callee-save 暫存器,只在 entry 存一次,不必在每次 call 前後存取
leaf procedure
D. 分開比較好:
① 資料寬度不同:整數 32/64 bit、FP 32/64 bit、SIMD 128~512 bit;合成一個 file 要全部做到最寬,浪費面積
② port 數與頻寬:整數、FP、SIMD 單元各用自己的小 register file,同時存取,不必擠在一個多 port 的大 file(越多 port 越慢、越大)
③ 接線距離:register file 放在各自的 execution unit 旁,延遲短
④ context switch 時沒用到 FP/SIMD 的 process 可不存這些暫存器(lazy save)
缺點:兩個 file 之間搬資料要多一道 move 指令;共用一個 file 時暫存器分配比較有彈性,但上面的代價更大
分開(寬度、port 與延遲、面積、context switch 成本);不建議合成一個 general purpose register file