Convolution 練習題 (Practice - Convolution Fundamentals and the Basic Parallel Kernel)



Question 1 - Convolution 定義與 filter radius [recall]

用一句話定義 convolution;filter 為何大小是奇數 2r+1?書中為何把權重陣列改稱 "filter" 而非 "convolution kernel"?

Question 2 - Ghost cells 與邊界條件 [recall]

什麼是 ghost cells?多數應用給它什麼預設值?2D convolution 的邊界條件比 1D 複雜在哪?

Question 3 - 基本 2D Kernel 的映射與瓶頸 [recall]

基本平行 2D convolution kernel 如何把 thread 映射到 output?它的算術強度是多少、瓶頸為何?另有什麼次要問題?

Question 4 - Constant Memory 宣告與拷貝 [recall]

如何把 filter F 放進 constant memory?宣告語法、host 端拷貝 API、容量限制、以及 kernel 如何存取 F 分別為何?

Question 5 - 為何 F 適合 Constant Cache [recall]

書中列出 F 的哪三項存取特性使它適合 constant memory + caching?constant cache 在什麼存取模式下效益最大?最終把 OP/B 提升到多少?

Question 6 - Input/Output Tile、Halo 與兩個 if [recall]

寫出 input tile 與 output tile 的尺寸關係公式;halo cells 與 ghost cells 差在哪?方案 A (Fig 7.12) 的兩個 if 條件各負責什麼?__syncthreads() 該放在哪?

Question 7 - 計算 1D Convolution 輸出 [application]

N = {4, 1, 3, 2, 3}、filter F = {2, 1, 4}(r=1,ghost = 0)做 1D convolution,求輸出陣列。

Question 8 - Tiled Kernel 的資源用量與比值計算 [application]

用方案 A (Fig 7.12) 對 N×N 陣列、M×M filter、T×T output tile 做 tiled 2D convolution:(a) 需要幾個 thread block?(b) 每 block 幾個 thread?(c) 每 block 需多少 shared memory?(d) 並驗證 5×5 filter、32×32 input tile 的算術強度。

Question 9 - 方案 A vs 方案 B (halo in shared vs halo in cache) [analysis]

比較「方案 A:block = input tile、把 halo 載進 shared memory」與「方案 B:block = output tile、halo 靠 cache」兩種 tiled 設計,在載入複雜度、計算複雜度、divergence、block/tile 尺寸與 halo DRAM 流量上的取捨。

Question 10 - Constant Cache vs Shared Memory,及大 Filter 的權衡 [analysis]

(a) constant cache 與 shared memory 在「透明度 / 使用機制」上最大的差異是什麼?(b) 為何 filter 越大、算術強度的「上界」越高,但「實際值與上界的落差」也越大?小 tile 為何危險?