松田研究室
FindingID: phase5-step30b-timing
Status: stable / task #5.30b
← Findings Index
Phase 5 · step 30b kernel timing

Phase 5 step 30b — kernel-by-kernel timing 計測結果

M4 Max で F config 2000 iter の kernel ごと GPU timer total を計測。rasterize_backwards が 52.1% (24.1 ms/call) で dominant、atomic_fetch_add が律速と判定。step 33 prototype (SIMD prefix sum で 32× atomic 削減) の最有力ターゲット確定。

positiverank: highaccepted第 3 軸phase-5step-30bkernel-timingrasterize-backwardsatomic-bottleneckm4-maxhotspot
Impact
kernel-level GPU timer で rasterize_backwards が 24.1 ms/call / 52.1% total と確定 dominant。atomic float add が律速と判定し、step 33 SIMD prefix sum reduction prototype の最有力ターゲットを確定。期待 ROI は 50% 削減で iter -13%、80% 削減で -21%。
01

本文

M4 Max 上で F config (L1+SSIM, λ=0.20, K=7) 2000 iter の kernel ごと GPU timer total を計測。rasterize_backwards が 52.1% / 24.1 ms/call で dominant、atomic float add が GPU compute を律速していると判定。step 33 prototype (SIMD prefix sum で 1 atomic per warp = 32× 削減) の最有力ターゲットを確定。

実施
2026-04-30 17:42、commit 9617683 (timing instrumentation 直後)
Hardware
M4 Max
設定
F config + L1+SSIM (λ=0.20, K=7)、2000 iter
集計範囲
iter 50 で reset (cold cache + ramp 排除)、iter 50-2000 の 1951 iter ぶん
splat 数
iter 500 まで 5207、refine 範囲 [500, 1500] で 76,363 まで成長、その後固定
Script
3dgs-rs/scripts/phase5/run_step30b_timing.sh
Log
3dgs-rs/runs/phase5-step30b/step30b_2000iter_F.log (gitignored)

計測結果

kerneltotalcallsavg/call%total
rasterize_backwards47.036 s195124.109 ms52.1%
radix_hist13.506 s31216432.660 µs15.0%
project_soa8.341 s19514.275 ms9.2%
emit_pairs7.211 s19513.696 ms8.0%
ssim_fwd_bwd5.791 s19512.968 ms6.4%
rasterize_f323.126 s19511.602 ms3.5%
adam_step2.707 s9755277.481 µs3.0%
project_backwards1.008 s1951516.846 µs1.1%
radix_scatter825.828 ms3121626.455 µs0.9%
extract_offsets748.205 ms1951383.497 µs0.8%
TOTAL90.300 s

Wall-clock 整合

  • GPU timer total: 90.3 s
  • Wall-clock total: 132.4 s
  • 比率: 68% GPU compute / 32% CPU encoding + IPC
  • step 30 findings の「~70% GPU compute / ~30% CPU encoding」と一致 ✅

ホットスポット ranking

1. rasterize_backwards: 52.1% (dominant) ⭐⭐⭐

  • 24.1 ms/call、最遅 kernel
  • 1 iter に 1 回呼ばれる、全 splat の 9 field gradient を atomic float add で accumulate
  • atomic ADD が GPU compute を律速していると仮定 → SIMD prefix sum で warp 内 reduction → 1 atomic per warp に削減可能
  • 期待 ROI: 50% 削減で iter 速度 90s → 78s (-13%)、80% 削減で → 71s (-21%)

step 33 prototype の最有力ターゲット確定

2. radix_hist: 15.0% (radix sort histogram phase)

  • 432 µs/call、16 pass × 1951 iter = 31,216 calls (1 iter あたり 16 calls)
  • 1 iter あたり 6.9 ms
  • 削減余地: ICB (将来) で 16 pass を 1 commit に、または workgroup サイズ tuning
  • ROI 中、step 32 (ICB) で取り組む候補

3. project_soa: 9.2% (forward projection)

  • 4.3 ms/call、1 iter 1 回
  • 削減余地: SH 評価が dominant な可能性、SIMD 化で短縮余地あり
  • ROI 中、step 33 後の候補

4. emit_pairs: 8.0% (tile binning)

  • 3.7 ms/call、1 iter 1 回
  • 削減余地: tile_id 計算 + atomic counter 更新、SIMD 化
  • ROI 低 → 中、step 32 / 33 の後

5. ssim_fwd_bwd: 6.4% (SSIM forward + backward in 1 cmd buffer)

  • 3.0 ms/call (forward + backward 計)、1 iter 1 回
  • 削減余地: 7×7 gaussian conv 2 pass を tile shader / imageblock_data で TBDR 高速化
  • step 34 (tile shader) のターゲット候補、ROI 中

6. rasterize_f32: 3.5% (forward rasterize)

  • 1.6 ms/call、forward と比較対称な kernel
  • backward が 24ms なら forward が 1.6ms = 15× の速度差 → atomic が backward を律速の証拠
  • 改善余地: forward 自体は速いので priority 低

結論と次着手

step 33 prototype 確定 (rasterize_backwards atomic 削減)

現行の rasterize_backwards.metal は per-pixel ループ内で per-splat に 9 field × atomic_fetch_add を発行している (atomic float add via M4 native support)。

最適化案 (SIMD prefix sum reduction):

  1. tile (16×16 = 256 pixels = 8 warps × 32 threads on M-series GPU) 内で
  2. 各 thread が自分の (pixel, splat) 寄与を計算
  3. SIMD group (32 threads = 1 warp) 内で simd_sum() (Metal 内蔵) で warp 内 reduction → 1 thread が代表
  4. 代表 thread が atomic_fetch_add を 1 回 → 32× atomic 削減

期待効果: atomic call 数 256 thread × 9 field → 8 warp × 9 field = 32× 削減。ただし atomic が時間支配なのか、その他 (memory bandwidth、warp divergence) なのかは実装後の再 profile で確認。

gate (step 33 採否判断)

  • ✅ 採用: rasterize_backwards avg/call が 24 ms → ≤ 12 ms (≥ 1.5× 短縮)
  • ❌ 見送り: 24 ms → > 19 ms (< 1.2× 短縮)
  • 中間 (1.2-1.5×): 個別判断、コード明確性とのトレードオフ
Methodology

F (scale_reg) / G (MCMC) の formulation 失敗から学んだ早期 reject ポリシーを継続。kernel-level 計測で dominant hotspot を pre-commit gate 付きで attack する流れを Phase 5 で確立。

03

関連 finding

© 2026 大竹律輝 — 松田研究室