CUDA Dynamic Parallelism (動態平行) 練習題 (Practice - Dynamic Parallelism Fundamentals and Overview)



Question 1 - Dynamic Parallelism 是什麼 [recall]

情境/題目:用一句話定義 CUDA Dynamic Parallelism (CDP),並說明它解除了早期 CUDA 的什麼限制?哪些演算法特徵最受益?

Question 2 - Kernel-in-kernel Launch 語法 [recall]

情境/題目:device 端從 kernel 內呼叫 kernel 的語法為何?<<<Dg, Db, Ns, S>>> 四個參數各代表什麼、預設值為何?S 有什麼特別限制?

Question 3 - Fig. 21.4 迴圈版 Kernel 的兩個問題 [recall]

情境/題目:Fig. 21.4 中每個 thread 先做前置運算、再 for-loop 走訪自己負責的一串資料元素。這種寫法有哪兩個主要問題?把迴圈改成 child grid 後分別如何被解決?

Question 4 - Bezier 版本的三項關鍵改動 [recall]

情境/題目:Bezier 範例從無 CDP(Fig. 21.6)改成有 CDP(Fig. 21.7)時,做了哪三項關鍵改動:索引單位、記憶體配置、記憶體釋放?

Question 5 - Parent/Child 記憶體可見性 [recall]

情境/題目:parent thread 可以把哪些記憶體類型的指標傳給 child grid?哪些不行?parent 與 child 「記憶體視圖一致」的兩個保證時刻是什麼?

Question 6 - Pending Launch Pool [recall]

情境/題目:什麼是 pending launch pool?預設容量多少?超過會怎樣?如何調整?什麼時候才該調?

Question 7 - Per-Thread Streams 與序列化 [recall]

情境/題目:device thread launch child grid 時若不指定 stream 會發生什麼?stream 的作用範圍是什麼?要讓同 block 內不同 thread 的 child grid 併發該怎麼做?

Question 8 - Nesting Depth 與 Synchronization Depth [recall]

情境/題目:什麼是 nesting depth?硬體上限多少?遞迴 kernel(如 quadtree)為何 launch 前必須檢查它?synchronization depth 與它有何不同?

Question 9 - Constant 與 Shared/Local 的可見性 (Ex.4 & Ex.5) [recall]

情境/題目:判斷真偽並說明理由:(a) parent kernel 可以定義新的 __constant__ 變數讓 child kernel 繼承。(b) child kernel 可以存取其 parent 的 shared memory 與 local memory。

Question 10 - Bezier 計數題 (Ex.1) [application]

情境/題目:Bezier 範例中,判斷以下敘述真偽:(a) N_LINES=1024, BLOCK_DIM=64 → launch 16 個 child kernel。(b) N_LINES=1024 時應把 fixed pool 從 2048 調成 1024 以求最佳效能。(c) N_LINES=1024, BLOCK_DIM=64 且用 per-thread streams → 共 16 個 stream。

Question 11 - Quadtree 深度與 Launch 數 (Ex.2 & Ex.3) [application]

情境/題目:64 個等距點以 quadtree 分類(每象限點數須 > 2 才再細分,完美均分)。(a) quadtree 的最大深度(含 root)是多少?(b) 總共啟動多少個 child kernel launch?

Question 12 - NULL Stream 下的併發上限 (Ex.6) [application]

情境/題目:6 個 block、每 block 256 threads 執行一個 parent kernel,每條 thread launch 一個 child kernel,且使用 default NULL stream。最多有幾個 child kernel 能併發執行?

Question 13 - For-loop vs Child-grid:何時反而更糟 [analysis]

情境/題目:對「每個工作單位工作量動態變化且差異大」的問題,比較「無 CDP 的 for-loop 版」與「有 CDP 的 child-grid 版」在平行度、control divergence、SM 利用率上的差異。CDP 版在什麼情況下反而比原版更慢?

Question 14 - Quadtree Reorder:Scatter vs Gather [analysis]

情境/題目:quadtree 的 reorder_points() 用 scatter(對象限計數器 atomicAdd 取得目的 index 再寫出)把點分群。為什麼這裡選 scatter 而非 gather?scatter 的代價是什麼?整個「count → scan → reorder」流程與哪個經典演算法同構?

Question 15 - 4-element Scan:序列 vs 平行 [analysis]

情境/題目:quadtree 的 scan_for_offsets()4 個象限計數器做 exclusive scan,卻只用單一 thread 序列完成,而非套用平行的 Kogge-Stone / Brent-Kung。請說明這個選擇的理由,並說明它呼應了什麼「演算法選擇」原則。