ai-infra-interview-305

第 26 题:如何用Nsight Compute分析kernel性能?关注哪些metrics?

题目

如何用Nsight Compute分析kernel性能?关注哪些metrics?


完整讲解

一、Nsight Compute 能看什么?

Nsight Compute(ncu)针对 单个 kernel 做细粒度分析:占用率(occupancy)warp 执行效率memory throughput(与 roofline 对比)、指令吞吐stall 原因(等内存、等指令、等同步等)、shared memory bank conflictL1/L2 缓存 等。先录一次 run:ncu -o report python script.py 或对已抓的 kernel 指定名字;再用 GUI 或 ncu --import report.ncu-rep 看指标。

二、关键 metrics 怎么读?

三、使用流程建议

先用 Nsight Systems 找「哪个 kernel 占时多」,再用 Nsight Compute 对该 kernel 看上述指标;根据 stall 与 throughput 决定:加 occupancy、改 coalescing、减 bank conflict、或优化计算密度。


面试要点


记忆要点

  1. Nsight Compute = 单 kernel 分析;occupancy、throughput、warp 效率、stall、roofline。
  2. 低 occupancy + 依赖 stall → 试减 register/shared;低 throughput → 看 coalescing/bank/cache。
  3. 流程:Systems 定 kernel → Compute 看指标 → 按 stall/throughput 改。
返回模块 返回总览