---
# System prepended metadata

title: 成大 108 硬體
tags: ['108', NCKU, 硬體]

---

# 成大 108 硬體
###### tags: `NCKU` `108` `硬體`
1. (1) 

| |35|149|43|90|191|91|148|14|42|190|69|15|
|-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|
|tag|0|2|0|1|2|1|2|0|0|2|1|0|
|index|4|2|3|3|7|3|4|6|2|6|0|1|
|h/m|M|M|M|M|M|H|M|M|M|M|M|M|

(2)

| |35|149|43|90|191|91|148|14|42|190|69|15|
|-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|:-|
|tag|2|9|2|5|11|5|9|0|2|11|4|0|
|index|0|0|1|1|1|1|0|1|1|1|0|1|
|h/m|M|M|M|M|M|H|H|M|H|H|M|H|

(3)
$\frac{1}{12}(1\times1+11\times201)=\frac{553}{3}$
$\frac{1}{12}(5\times1+7\times201)=\frac{353}{3}$

2. (1)
```c=
void calc(int s, int t)
{
    for (int i = 0; i < 10000; i++) {
        for (int j = s; j < t; j++) {
            X[i][j] = Y[j][i] * 5;
        }
    }
}

void main()
{
    ...
    // T3
    thread_run(calc, 0, 2500);
    thread_run(calc, 2500, 5000);
    thread_run(calc, 5000, 7500);
    thread_run(calc, 7500, 10000);
}
```
speed up: $\frac{2+8+16+2}{2+8+4+2}=\frac{7}{4}$
(2)
```c=
void main()
{
    // T2
    for (int i = 0; i < 10000; i++) {
        for (int j = 0; j < 10000; j += 8) {
           Y[i][j]   = Y[i-1][j-1]+2;
           Y[i][j+1] = Y[i-1][j]+2;
           Y[i][j+2] = Y[i-1][j+1]+2;
           Y[i][j+3] = Y[i-1][j+2]+2;
           Y[i][j+4] = Y[i-1][j+3]+2;
           Y[i][j+5] = Y[i-1][j+4]+2;
           Y[i][j+6] = Y[i-1][j+5]+2;
           Y[i][j+7] = Y[i-1][j+6]+2;
        }
    }
}
```
speed up: $\frac{2+8+16+2}{2+1+16+2}=\frac{4}{3}$
(3) the first one is faster

3. (1) 感覺半對半錯。GPU 上的 RAM 確實可以增進 GPU 的效能，但那不是真相的全部。
(2) F， shared memory 應該不適用於不同電腦之間的IPC吧？
(3) F, GPU 不會總是比較快
(4) F, 反了
(5) F, 浮點數的運算順序會影響精度

4. (1) 64KB / 256KB
(2) $40\times512\times\frac{5400}{60}\div1024=900KiB$
(3) $$
10+30+\frac{1}{900}\times10^6\\
10+30+\frac{4}{900}\times10^6
$$
(4) ...有什麼差別嗎 (゜皿。)

5. (1) Interrupt / dispatch latency
(2) preemption-based is prefered
(3)
average waiting time: $\frac{17+24+53}{4}=\frac{94}{4}$
average turnaround time: $\frac{17\times4+24\times3+53\times2+68}{4}=\frac{314}{4}$
(4) $4!$