113 年 國立中山大學電機工程學系碩士班己組《計算機結構》
第 1 題20 分
In hardware, SYS-1 system has a CPU with a base CPI of , where is larger than zero, assuming all references hit in the primary cache (L1) and a CPU clock rate of 2GHz. Assume that the main memory access time is 160 ns, including all the cache miss handling. Suppose the miss rate per instruction at L1 is 5%. Based on the construction of SYS-1 system, there are two systems shown as follows.
(i) SYS-2 system includes SYS-1 and an additional secondary cache (L2). The access time of L2 is 28 ns for either a hit or a miss. Suppose the miss rate per instruction at L2 is , where .
(ii) SYS-3 system includes SYS-2 and an additional tertiary cache (L3). The access time of L3 is 44 ns for either a hit or a miss. Suppose the miss rate per instruction at L3 is 0.1%.
We know that SYS-2 system is faster than SYS-1 system by 2 times. In addition, SYS-3 system is faster than SYS-2 system by 1.25 times. Please answer the following questions.
(a) As regards SYS-1 system, please calculate the memory-stall cycles per instruction.
(b) Please calculate .
(c) Please calculate .
(d) According to the result calculated in (b), the program has three different instruction categories, such as A, B, and C. We know that CPI for A, B, and C is 3, 5, and 6, respectively. The instruction count of A and B is 48 and 30, respectively. Please calculate the instruction count of C.
登入後即可作答並保存紀錄。
(a) 記憶體停頓週期/指令
(b) 求基礎 CPI
SYS‑1 CPI:
SYS‑2 停頓 CPI
L2 命中延遲 cycles,
L2 未命中再至主記憶,總延遲 cycles。
已知 SYS‑2 速度是 SYS‑1 的 → CPI 減半:
SYS‑3 停頓 CPI
L3 命中延遲 cycles,
L3 未命中再至主記憶,總延遲 cycles。
第 2 題10 分
A program, SVM, has the total execution time of 500 ns and can be well-divided into P1 - P4 parts. P1 - P3 can be modified to increase or decrease the individual execution time by the certain approaches. But P4 still keeps identical without any influence. The execution time of P1 - P4 is denoted as T1 - T4, respectively. Assume that T1 - T4 originally are 144 ns, 108 ns, 120 ns, and 128 ns, respectively. There are three different design scenarios as follows.
◆ Design scenario 1: If T1 and T2 are improved by X and Z times, respectively, T3 is increased to 1.34 times accordingly. The corresponding total execution time is decreased to 476 ns.
Design scenario 2: If T1 and T3 are improved by Y and Z times, respectively, T2 is increased to 1.5 times accordingly. The corresponding total execution time is decreased to 490 ns.
◆ Design scenario 3: If T2 and T3 are improved by Y and X times, respectively, T1 is increased to 1.375 times accordingly. The corresponding total execution time is increased to 512 ns.
Which one is the possible solution of (X, Y, Z)?
(single choice)
(A) (1.25, 1.5, 1.4)
(B) (1.25, 1.2, 1.75)
(C) (1.4, 1.2, 1.25)
(D) (1.25, 1.5, 1.6)
(E) (1.5, 1.2, 1.25)
(F) (1.4, 1.2, 1.5)
(G) (1.75, 1.4, 1.5)
(H) (1.25, 1.2, 1.25)
(I) (1.25, 1.5, 1.25)
(J) (1.4, 1.75, 1.5)
(K) (1.25, 1.2, 1.5)
(L) (1.4, 1.6, 1.5)
登入後即可作答並保存紀錄。
設計情境方程式(改善=時間除以因子,惡化=時間乘以因子)
-
(①)
-
(②)
-
第 3 題25 分
Assume that X1 - X7 and Y1 - Y7 are well-represented as the 32-bit single-precision format in IEEE-754 standard as shown in TABLE I. We know that the relationship is calculated as follows, W1 = X1 × Y1, W2 = X2 × Y2, ......, W7 = X7 × Y7. Please answer the following questions.
(a) If , where , please find out the value of .
(b) If , where , please find out the value of .
(c) Please sort these seven numbers (W1 - W7) in descending order.
TABLE I
Bit
31
X1 0 10000011011001100010000000000000
Y1 0 11000101011010011111000000000000
X2 0 00100111010111011001000000000000
Y2 1 10100010001001000110000000000000
X3 0 01101010000011001000000000000000
Y3 1 01011101010100111000000000000000
X4 1 10111001101100010010000000000000
Y4 0 00010010001111110101000000000000
X5 0 00111100010110001100000000000000
Y5 1 10001011000111000100000000000000
X6 1 10011001110111100011000000000000
Y6 1 00101100011111101100000000000000
X7 0 00111101101111110000000000000000
Y7 0 10001000001111010100000000000000
Bit
0
🖼️【此處有附圖,請對照原卷】
登入後即可作答並保存紀錄。
核心觀念
IEEE-754 單精度浮點數共 位元,依序分成:
- 符號位元 : 位元。
- 指數欄位 : 位元,偏移量為 。
- 小數欄位 : 位元。
本題各數皆為正規化數,因此其數值為
令有效數 、實際指數 ,則兩數相乘為
排序時,先分正負,再比較指數與有效數;負數的絕對值越大,數值越小。
解題方法
原卷 TABLE I 的每列由左至右是位元 到位元 ,四位一組的格線只是方便閱讀,並非欄位分界。尤其 的原卷位元為 1100 1100 1110 1111 0001 1000 0000 0000,應切成符號 、指數 ,以及其餘 位小數。
(a)求
由原卷讀得
因此
所以
代入題目範圍可得
故 。
(b)求
由原卷讀得
因此
所以
代入題目範圍:
與 對照,得到 。
(c)將 至 由大到小排序
逐列解讀符號及指數,再將有效數相乘,得到下表。其中 均已扣除偏移量 。
第 4 題20 分
The following mathematical equation shows the relationship among different elements in the array, A[ ]. After executing the MIPS codes listed in Figure 1, the value of A[i+S] can be computed based on A[i] - A[i+3], where i and S are two positive integers. C0 - C3 denote four integer coefficients. We know that the base address of A[ ] is stored in $s0. Please answer the following questions.
(a) Please calculate C0, C1, C2, and C3.
(b) Please calculate i and S.
(c) Please calculate the value of A[i+S] while (A[i], A[i+1], A[i+2], A[i+3]) = (-8, 10, -11, 7).
(d) In hardware implementation, we can utilize a 5-stage pipelined MIPS CPU to execute this program. If considering the forwarding (bypass) technique to fix or relax the possible data hazard, what is the minimum number of total clock cycles to complete this program?
🖼️【此處有附圖,請對照原卷】
登入後即可作答並保存紀錄。
核心觀念
這題考兩個重點:
- 由 MIPS 暫存器運算反推陣列係數:
lw從陣列載入元素,後續的加減與位移可逐步化簡成 到 的線性組合。 - 五階段管線的資料冒險:有 forwarding 時,多數相鄰指令相依可直接轉送結果;但
lw的載入資料要到較後階段才可用,緊接著使用載入值時仍須停等一個 cycle。
題目中的陣列元素是 32-bit 整數,因此每個元素占 4 bytes。sll $t2, $t2, 3 等同乘以 。
解題方法
依原卷 Figure 1,指令可整理如下:
lw $a0, 128($s0)
lw $a1, 132($s0)
sub $t0, $a0, $a1
lw $a2, 136($s0)
add $t1, $a2, $a2
sub $t1, $t1, $a1
add $t2, $t1, $t1
add $t2, $t2, $t0
sll $t2, $t2, 3
sub $t2, $t2, $a0
lw $a3, 140($s0)
sll $t0, $a3, 2
sub $t0, $t0, $a3
add $t2, $t2, $t0
sub $t1, $t2, $t1
addi $t2, $t1, -5
sw $t2, 264($s0)
(a) 求
設四個載入值依序為 。
前三個暫存器中間值為:
接著左移 3 位並減去 :
另一條運算路徑為:
將兩條路徑相加,再減去 $t_1