Williams, Waterman, Patterson "Roofline: An Insightful Visual Performance Model" (CACM 2009)
수치 출처: NVIDIA A100/H100 whitepapers · cross-ref ↗ V02 §8·§9
log FLOP/s
▲
│ ┌──────── P_peak (compute roof)
│ /
│ slope=BW /
│ /
│ / ← memory roof (BW·AI)
│ /
└────────┼─────────────────► log AI
AI*
kernel point (AI, P_obs):
below both roofs → headroom
on memory roof → memory-bound
on compute roof → compute-bound
| roof | 지표 |
|---|---|
| FP64 peak | scientific |
| FP32 CUDA core | general |
| FP16/BF16 TC | training |
| FP8 TC | inference |
| INT8 TC | quantized |
dtype별로 서로 다른 roof line — 같은 plot에 여러 수평선
| level | BW (per SM·cycle or agg.) | AI* (FP16 TC) |
|---|---|---|
| HBM | ~1.5 TB/s | ~208 |
| L2 | ~5 TB/s | ~62 |
| SMEM (per SM agg.) | ~19 TB/s | ~16 |
| Register | ~TB/s 단위 실효 | — |
order-of-magnitude · A100 whitepaper / NVIDIA Tuning Guide · ↗ V02 §15
log FLOP/s
▲
│ ──────── P_peak
│ /
│ / SMEM roof (19 TB/s · AI_smem)
│ / ← 기울기 가장 급
│ /
│ / L2 roof (5 TB/s · AI_L2)
│ /
│ /
│ / HBM roof (1.5 TB/s · AI_HBM)
│ /
└──┼─────────────────────────► log AI
각 level의 AI = FLOPs / Bytes_level
level별로 kernel 좌표 다름
| M=N=K | AI (FP16) | region |
|---|---|---|
| 128 | ~21 | memory-bound |
| 512 | ~85 | mem/comp 경계 |
| 1024 | ~170 | compute 근처 |
| 4096 | ~683 | compute-bound |
| 8192 | ~1365 | deep compute |
AI ≈ d/6 근사 · ridge AIH100=295 대비
Split-K / Stream-K 선택 ↗ V06 §5
cross-ref ↗ V07 §4 FA AI 유도
| op | AI (FP16) |
|---|---|
| add, mul | ~0.25 |
| RMSNorm | ~0.5 |
| softmax (1 pass) | ~0.5 |
| LayerNorm | ~1.0 |
항상 memory-bound → fusion 만이 유일 해결책 ↗ V08
NVIDIA Nsight Compute Documentation · Section 정의만 참조
| prefix | 의미 |
|---|---|
sm__ | SM 단위 카운터 |
smsp__ | SM sub-partition |
l1tex__ | L1/TEX unit |
lts__ | L2 slice |
dram__ | HBM 컨트롤러 |
gpc__ | GPC (SM 묶음) |
| suffix | 의미 |
|---|---|
.avg | 평균 |
.sum | 합계 |
.pct_of_peak | peak 대비 % |
.per_cycle_active | active cycle당 |
.ratio | 비율 |
| section | 답하는 질문 |
|---|---|
| SOL | compute vs memory 어디? |
| Memory | 어느 계층이 포화? |
| Compute | 어느 pipe가 포화? |
| Scheduler | warp가 충분히 준비? |
| Warp State | 왜 stall? |
| Source | 어느 라인? |
| 지표 | peak 기준 |
|---|---|
| SOL SM | SM compute pipe 포화 |
| SOL Memory | HBM BW 포화 |
| SOL TEX/L1 | L1/TEX 단위 처리량 |
| SOL L2 | L2 cache 처리량 |
| 조건 | 판정 |
|---|---|
| SOL Mem > SOL SM (차이 큼) | memory-bound 후보 |
| SOL SM > SOL Mem (차이 큼) | compute-bound 후보 |
| 둘 다 낮음 (< 60%) | latency-bound 의심 |
| 둘 다 높음 | balanced, 목표 상태 |
NVIDIA Nsight Compute Kernel Profiling Guide — SOL Section 해석 rule
DRAM
↓ bytes_r / bytes_w
L2 (hit rate %)
↓
L1/TEX (hit rate %)
↓
SMEM (load/store · bank conflict)
↓
Register file
| level | hit rate 의미 |
|---|---|
| L1 hit | block 내 reuse |
| L2 hit | SM 간 공유 / prefetch 성공 |
| DRAM (miss) | HBM 까지 내려감 |
Hit rate 낮음 = traffic 증폭 = DRAM BW 낭비
| 지표 | 해석 |
|---|---|
| SMEM load throughput | reuse 활용도 |
| SMEM store throughput | write 빈도 |
| bank conflict count | access pattern 문제 |
| wavefronts per request | 1 이상 = 충돌 |
NVIDIA Nsight Compute · Warp State Statistics Section · ↗ V02 §11
| 이름 | 의미 | 전형적 원인 범주 | 해법 범주 프레임 수준 |
|---|---|---|---|
| Long Scoreboard | global/local memory load 결과 대기 | HBM latency, reuse 부족, prefetch 없음 | shmem tiling, cp.async pipelining, L2 hit ↑ |
| Short Scoreboard | SMEM load / MIO 결과 대기 | shared memory 지연, bank conflict | swizzle, ldmatrix, padding |
| Wait | 이전 instruction의 fixed latency 대기 | dependency chain, low ILP | unroll, 독립 op 삽입, ILP 확보 |
| Not Selected | ready 인데 scheduler가 다른 warp 선택 | eligible warp 과다 (좋은 신호) | 통상 건드리지 않음 — ILP 확보 여지 |
| Drain | block exit 시점 작업 drain 대기 | tail effect, block 수 vs SM 배수 부정합 | grid 크기 조정, persistent kernel |
| Barrier | __syncthreads / cluster barrier 대기 |
sync 빈도 과다, work imbalance | sync 횟수 ↓, warp specialization |
| MIO Throttle | Memory I/O unit queue 포화 | uniform load 쏠림, LDG 폭주 | load 분산, vectorize (LDG.128) |
| Tex Throttle | TEX/L1 unit 포화 | texture/L1 요청 과다 | request 분산, cache 활용 재검토 |
"해법"은 프레임워크 수준 범주일 뿐 — 구체 튜닝 사례·UI 조작은 단권화 범위 밖 (out-of-scope)
| 지배 stall | 추정 bound |
|---|---|
| Long Scoreboard ↑↑ | HBM latency/BW bound |
| Short Scoreboard ↑↑ | SMEM bound |
| Barrier ↑↑ | sync bound (work imbalance) |
| Wait ↑↑ + Math pipe ↑↑ | compute bound |
| Not Selected ↑↑ | 여유 있음 — bottleneck은 다른 곳 |
SM 내부 구조 ↗ V02 §1·§11
| metric | 의미 |
|---|---|
| Active Warps | assigned warp 수 (평균/SM) |
| Eligible Warps / cycle | issue 가능 warp 수 |
| Issued Warps / cycle | 실제 issue된 warp 수 |
Active → Eligible → Issued ↓ ↓ ↓ stalled not-selected success
| 조건 | 진단 |
|---|---|
| Active 높음, Eligible 낮음 | 전원 stall — latency hiding 실패 |
| Eligible 높음, Issued 낮음 | issue 단의 pipe 제약 |
| Eligible > 1 | ILP 여유 있음 (Not Selected ↑) |
| Eligible < 1 | warp 수 부족, occupancy ↑ 검토 |
Occupancy 상세 ↗ p11 §10
Pipe 구성 세대별 차이 ↗ V02 §1
| pipe | 담당 연산 |
|---|---|
| FMA | FP32 fused multiply-add |
| ALU | int / logical / bitwise |
| FP64 | double precision |
| LSU | load/store unit |
| Tensor (TC) | MMA, WGMMA |
| SFU | sin, cos, rcp, rsqrt, exp |
| XU (Ampere+) | branch, predicate, misc |
| 포화 pipe | bound 의미 |
|---|---|
| Tensor ↑↑ | TC-bound — 목표 상태 (GEMM) |
| FMA ↑↑ | FP32 compute-bound |
| ALU ↑↑ | int 연산 포화 (indexing 과다?) |
| LSU ↑↑ | load/store 집중 (SMEM traffic) |
| SFU ↑↑ | 초월함수 병목 (exp, softmax) |
| 모든 pipe 낮음 | compute 아닌 다른 bound |
| 포화 pipe | 개선 방향 (범주) |
|---|---|
| ALU 과다 | indexing 단순화, const folding |
| LSU 과다 | vectorized load, SMEM tiling |
| SFU 과다 | fast-math, approx 함수 |
| TC 낮음 | shape/dtype 재검토 ↗ V06 |
| 종류 | 의미 |
|---|---|
| Theoretical | HW 자원 한계로 정해지는 상한 |
| Achieved | 실행 중 실제 평균 |
Achieved < Theoretical → tail effect, sync imbalance
| 자원 | 제약 |
|---|---|
| Register / thread | reg · threads · warp32 ≤ 256KB/SM |
| Shared Mem / block | blocks · smem/block ≤ SMEM/SM |
| Threads / block | blocks · threads ≤ max_threads |
| Blocks / SM | ≤ 16 (Ampere) / 32 (Hopper) |
상수 ↗ V02 §2·§3
__launch_bounds__ 로 reg 상한 힌트Nsight Compute · Source Counters Section
| 계층 | 표시 |
|---|---|
| CUDA C | 원본 라인 |
| PTX | 가상 ISA (컴파일 중간) |
| SASS | 실제 실행 명령 ↗ V04 §12 |
C ↔ PTX ↔ SASS 대응은 컴파일러가 주석으로 제공 — 1:1 아닐 수 있음
| metric | 의미 |
|---|---|
| Sampled Warp State | 이 라인에서 관측된 stall reason 분포 |
| Instructions Executed | 누적 실행 횟수 |
| Predicated-Off | predicate false로 무효 처리 |
| Live Registers | 이 지점 live reg 개수 |
| Branch Taken / NotTaken | 분기 통계 |
__launch_bounds__| Nsight Systems | Nsight Compute | |
|---|---|---|
| scope | system-wide timeline | single kernel deep-dive |
| 단위 | μs~s | cycle |
| 질문 | "언제·어디서" | "왜 느린가" |
| 대상 | CPU+GPU 협업 | GPU kernel 내부 |
cudaMalloc, Memcpy, launchCPU thread 0 | cudaMemcpyAsync | launch | sync | CUDA HWQ | H2D | kernelA | kernelB | NVLink | | allreduce | NVTX | [forward ][backward]
lane별 독립 타임라인 — 겹침(overlap) 확인에 사용
| 패턴 | 해석 |
|---|---|
| kernel + Memcpy 겹침 | stream 병렬 활용 OK |
| compute + comm 겹침 | comm hiding 성공 |
| kernel 직후 긴 host gap | launch overhead / sync 대기 |
| GPU idle span | host 병목 |
nvtxRangePush/Pop 으로 구간 태깅NCCL 통신 상세 ↗ V15 §5·§6
Start
│
├─ SOL Mem > SOL SM (큰 차이)? ── Y → [Memory Bound]
│ N
├─ SOL SM > SOL Mem (큰 차이)? ── Y → [Compute Bound]
│ N
├─ 둘 다 < 60%? ─────────────── Y → [Latency Bound]
│ N
├─ Warp Divergence 크다? ────── Y → [Divergence Bound]
│ N
└─ Eligible < 1? ────────────── Y → [Occupancy Bound]
N → Balanced (목표)
| bound type | 우선 검사 metric | 가능한 원인 범주 |
|---|---|---|
| Memory Bound | SOL Memory, DRAM throughput, L2/L1 hit rate, sectors/req, Long Scoreboard % | reuse 부족, uncoalesced access, hit rate 낮음, working set > L2, prefetch 없음 |
| Compute Bound | SOL SM, pipe utilization (FMA/TC/SFU), Wait stall, Math pipe % | peak 도달 (목표), 또는 특정 pipe 편중 (SFU 초월함수, ALU indexing) |
| Latency Bound | Eligible Warps / cycle, Issue Slot Util, Wait stall, Active Warps | warp 수 부족, ILP 부족, dependency chain, register spill |
| Divergence Bound | Warp Execution Efficiency, Branch Efficiency, SM active cycles | data-dependent branch, uneven work, lane 별 다른 path |
| Occupancy Bound | Achieved Occupancy, Theoretical limiter (reg/smem/block), Active Warps | reg/thread 과다 (spill 가능), smem/block 과다, block 수 부족 |
| Sync / Barrier Bound | Barrier stall %, Drain stall %, Achieved vs Theoretical gap | __syncthreads 과다, work imbalance, tail effect |
| SMEM Bound | Short Scoreboard %, SMEM throughput, wavefronts/request (bank conflict) | bank conflict, swizzle 부재, ldmatrix 누락, SMEM 용량 과다 |
범주적 원인만 · 구체 tuning trick / benchmark 수치 / UI 조작은 out-of-scope
| bound | 관련 권 |
|---|---|
| HW 구조 근거 | ↗ V02 |
| GEMM tuning frame | ↗ V06 |
| FA tuning frame | ↗ V07 |
| Distributed overlap | ↗ V15 |
| Inference latency | ↗ V16 |