[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EJ083BQ5EP0GEP11RTTZJ9":3,"skill-same:01M7EJ083BQ5EP0GEP11RTTZJ9":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":14,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7EJ083BQ5EP0GEP11RTTZJ9","cuda-profiling",null,"CUDA profiling skill for NVIDIA GPU performance analysis. Use when profiling kernels with Nsight Systems or Nsight Compute, interpreting roofline models, diagnosing memory-bound vs compute-bound kernels, or annotating code with NVTX ranges. Activates on queries about Nsight, NCU, ncu CLI, GPU roofline, occupancy metrics, or CUDA profiling workflow.","OzcanOrhanDemirci\u002FMode_Code","OzcanOrhanDemirci","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121283180?v=4","01M7EHZJ2ZRPZ3SQE0WD2TQK9Z","Özcan Orhan Demirci","01M7EHZJ3GX6AWZ3P0NW6J4HV6",0,"MIT","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills-external\u002Fcuda-profiling\u002FLICENSE.source","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills-external\u002Fcuda-profiling\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cuda-profiling\ndescription: CUDA profiling skill for NVIDIA GPU performance analysis. Use when profiling kernels with Nsight Systems or Nsight Compute, interpreting roofline models, diagnosing memory-bound vs compute-bound kernels, or annotating code with NVTX ranges. Activates on queries about Nsight, NCU, ncu CLI, GPU roofline, occupancy metrics, or CUDA profiling workflow.\n---\n\n# CUDA Profiling\n\n## Purpose\n\nGuide agents through profiling CUDA applications with Nsight Systems (timeline-level) and Nsight Compute (kernel-level metrics), using the NCU CLI for automated metric collection, interpreting roofline models, and diagnosing whether kernels are memory-bound or compute-bound.\n\n## When to Use\n\n- A CUDA kernel is slower than expected and you need bottleneck identification\n- Comparing kernel variants (tiling strategies, block sizes)\n- Building CI performance regression checks with `ncu` metrics\n- Correlating CPU and GPU activity in multi-stream pipelines\n- Annotating application phases with NVTX for timeline visibility\n- Interpreting occupancy, memory throughput, and SM utilization metrics\n\n## Workflow\n\n### 1. Choose profiling tool\n\n```\nWhat do you need?\n├── System-wide timeline (CPU+GPU+CUDA API) → Nsight Systems (nsys)\n├── Per-kernel deep metrics (occupancy, memory) → Nsight Compute (ncu)\n└── Quick metric from CLI in CI → ncu --metrics ...\n```\n\n### 2. Nsight Systems — timeline profiling\n\n```bash\n# Profile entire application\nnsys profile --trace=cuda,nvtx,osrt --output=report .\u002Fmy_cuda_app\n\n# Open report\nnsys-ui report.nsys-rep\n\n# CLI summary\nnsys stats report.nsys-rep\n```\n\nWhat to look for in the timeline:\n- Gaps between kernel launches (CPU bottleneck or sync points)\n- `cudaDeviceSynchronize` stalls\n- Overlap between H2D copies and kernel execution across streams\n- CUDA API call overhead\n\n```bash\n# Capture with CUDA graph info\nnsys profile --capture-range=cudaProfilerApi .\u002Fmy_cuda_app\n```\n\n### 3. NVTX range annotations\n\n```cpp\n#include \u003Cnvtx3\u002FnvToolsExt.h>\n\nvoid pipeline(void) {\n    nvtxRangePushA(\"H2D copy\");\n    cudaMemcpyAsync(d_in, h_in, size, cudaMemcpyHostToDevice, stream);\n    nvtxRangePop();\n\n    nvtxRangePushA(\"kernel\");\n    my_kernel\u003C\u003C\u003Cgrid, block, 0, stream>>>(d_in, d_out, n);\n    nvtxRangePop();\n\n    nvtxRangePushA(\"D2H copy\");\n    cudaMemcpyAsync(h_out, d_out, size, cudaMemcpyDeviceToHost, stream);\n    nvtxRangePop();\n}\n```\n\nCompile with `-lnvToolsExt` or link nvtx3 header-only. Ranges appear as colored bands in Nsight Systems.\n\n### 4. Nsight Compute — kernel analysis\n\n```bash\n# Profile all kernels, save report\nncu -o kernel_report .\u002Fmy_cuda_app\n\n# Profile specific kernel by name\nncu --kernel-name regex:matmul_tiled .\u002Fmy_cuda_app\n\n# Launch UI\nncu-ui kernel_report.ncu-rep\n```\n\nKey sections in NCU report:\n- **Speed of Light**: SM throughput vs memory throughput vs peak\n- **Occupancy**: Active warps vs hardware limit\n- **Memory Workload Analysis**: L1\u002FL2 hit rates, coalescing efficiency\n- **Warp State Statistics**: Stall reasons (memory, barrier, dispatch)\n\n### 5. NCU CLI metrics\n\n```bash\n# Essential metrics set\nncu --metrics \\\n  sm__throughput.avg.pct_of_peak_sustained_elapsed,\\\n  dram__throughput.avg.pct_of_peak_sustained_elapsed,\\\n  sm__warps_active.avg.pct_of_peak_sustained_active,\\\n  l1tex__t_sectors_pipe_lsu_mem_global_op_ld.sum,\\\n  smsp__sass_thread_inst_executed_op_ffma_pred_on.sum \\\n  .\u002Fmy_cuda_app\n\n# CSV export for CI\nncu --csv --metrics dram__bytes_read.sum,dram__bytes_write.sum .\u002Fmy_cuda_app\n\n# Set kernel replay mode for accurate counters\nncu --kernel-replay-mode application .\u002Fmy_cuda_app\n```\n\n### 6. Memory-bound vs compute-bound diagnosis\n\n```\nRoofline interpretation\n├── dram__throughput near peak AND sm__throughput low → memory-bound\n│   └── Fix: coalescing, shared mem tiling, reduce traffic\n├── sm__throughput near peak AND dram low → compute-bound\n│   └── Fix: tensor cores, loop unrolling, ILP\n└── Both low → launch config, occupancy, or sync overhead\n```\n\nRoofline model (conceptual):\n\n```\nPerformance (GFLOP\u002Fs)\n    |     \u002F\\  compute roof\n    |    \u002F  \\\n    |   \u002F    \\____ memory roof (bandwidth-limited region)\n    |  \u002F\n    +------------------ Arithmetic Intensity (FLOP\u002Fbyte)\n```\n\nMeasure arithmetic intensity: `smsp__sass_thread_inst_executed_op_ffma_pred_on.sum * 2 \u002F dram__bytes.sum`\n\n### 7. Occupancy analysis\n\n```bash\nncu --metrics sm__warps_active.avg.pct_of_peak_sustained_active,\\\nlaunch__occupancy_limit_registers,\\\nlaunch__occupancy_limit_shared_mem,\\\nlaunch__occupancy_limit_block_size \\\n.\u002Fmy_cuda_app\n```\n\n| Limiting factor | Typical fix |\n|-----------------|-------------|\n| Registers | `-maxrregcount`, simplify kernel |\n| Shared memory | Reduce tile size, split phases |\n| Block size | Try 128 or 256 instead of 512+ |\n\n### 8. Profiling workflow checklist\n\n```bash\n# 1. Build with line info (not -G unless debugging)\nnvcc -lineinfo -O3 -arch=sm_80 -o app main.cu\n\n# 2. Timeline first\nnsys profile --trace=cuda,nvtx -o timeline .\u002Fapp\n\n# 3. Deep dive on hot kernel\nncu --kernel-name regex:hot_kernel --set full .\u002Fapp\n\n# 4. Compare before\u002Fafter\nncu --csv --metrics sm__throughput.avg.pct_of_peak_sustained_elapsed .\u002Fapp_v1 > v1.csv\nncu --csv --metrics sm__throughput.avg.pct_of_peak_sustained_elapsed .\u002Fapp_v2 > v2.csv\n```\n\n## Common Problems\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `ERR_NVGPUCTRPERM` | Insufficient profiling permissions | Run with sudo or set `NVreg_RestrictProfilingToAdminUsers=0` |\n| All metrics show zero | Profiling disabled or wrong GPU | Check `CUDA_VISIBLE_DEVICES`; use `--target-processes all` |\n| NCU report empty | Kernel too short or not launched | Increase workload; verify `cudaGetLastError()` |\n| Huge profiling overhead | Full metric sets on many kernels | Use `--kernel-name` filter; `--launch-skip` |\n| Timeline shows no overlap | Single default stream | Create multiple streams; use async copies |\n| Occupancy looks fine but kernel slow | Memory latency not hidden | Check memory coalescing; increase active warps |\n\n## Related Skills\n\n- `skills\u002Fgpu\u002Fcuda` — kernel writing, occupancy tuning, nvcc flags\n- `skills\u002Fgpu\u002Fgpu-memory-model` — coalescing, bank conflicts, SIMT model\n- `skills\u002Fgpu\u002Fcuda-debugging` — correctness before performance tuning\n- `skills\u002Fprofilers\u002Fintel-vtune-amd-uprof` — CPU-side roofline and hotspot analysis\n- `skills\u002Fprofilers\u002Fflamegraphs` — CPU flamegraphs complementary to nsys timeline\n- `skills\u002Fprofilers\u002Fhardware-counters` — general perf stat concepts","# CUDA Profiling\n\n## Purpose\n\nGuide agents through profiling CUDA applications with Nsight Systems (timeline-level) and Nsight Compute (kernel-level metrics), using the NCU CLI for automated metric collection, interpreting roofline models, and diagnosing whether kernels are memory-bound or compute-bound.\n\n## When to Use\n\n- A CUDA kernel is slower than expected and you need bottleneck identification\n- Comparing kernel variants (tiling strategies, block sizes)\n- Building CI performance regression checks with `ncu` metrics\n- Correlating CPU and GPU activity in multi-stream pipelines\n- Annotating application phases with NVTX for timeline visibility\n- Interpreting occupancy, memory throughput, and SM utilization metrics\n\n## Workflow\n\n### 1. Choose profiling tool\n\n```\nWhat do you need?\n├── System-wide timeline (CPU+GPU+CUDA API) → Nsight Systems (nsys)\n├── Per-kernel deep metrics (occupancy, memory) → Nsight Compute (ncu)\n└── Quick metric from CLI in CI → ncu --metrics ...\n```\n\n### 2. Nsight Systems — timeline profiling\n\n```bash\n# Profile entire application\nnsys profile --trace=cuda,nvtx,osrt --output=report .\u002Fmy_cuda_app\n\n# Open report\nnsys-ui report.nsys-rep\n\n# CLI summary\nnsys stats report.nsys-rep\n```\n\nWhat to look for in the timeline:\n- Gaps between kernel launches (CPU bottleneck or sync points)\n- `cudaDeviceSynchronize` stalls\n- Overlap between H2D copies and kernel execution across streams\n- CUDA API call overhead\n\n```bash\n# Capture with CUDA graph info\nnsys profile --capture-range=cudaProfilerApi .\u002Fmy_cuda_app\n```\n\n### 3. NVTX range annotations\n\n```cpp\n#include \u003Cnvtx3\u002FnvToolsExt.h>\n\nvoid pipeline(void) {\n    nvtxRangePushA(\"H2D copy\");\n    cudaMemcpyAsync(d_in, h_in, size, cudaMemcpyHostToDevice, stream);\n    nvtxRangePop();\n\n    nvtxRangePushA(\"kernel\");\n    my_kernel\u003C\u003C\u003Cgrid, block, 0, stream>>>(d_in, d_out, n);\n    nvtxRangePop();\n\n    nvtxRangePushA(\"D2H copy\");\n    cudaMemcpyAsync(h_out, d_out, size, cudaMemcpyDeviceToHost, stream);\n    nvtxRangePop();\n}\n```\n\nCompile with `-lnvToolsExt` or link nvtx3 header-only. Ranges appear as colored bands in Nsight Systems.\n\n### 4. Nsight Compute — kernel analysis\n\n```bash\n# Profile all kernels, save report\nncu -o kernel_report .\u002Fmy_cuda_app\n\n# Profile specific kernel by name\nncu --kernel-name regex:matmul_tiled .\u002Fmy_cuda_app\n\n# Launch UI\nncu-ui kernel_report.ncu-rep\n```\n\nKey sections in NCU report:\n- **Speed of Light**: SM throughput vs memory throughput vs peak\n- **Occupancy**: Active warps vs hardware limit\n- **Memory Workload Analysis**: L1\u002FL2 hit rates, coalescing efficiency\n- **Warp State Statistics**: Stall reasons (memory, barrier, dispatch)\n\n### 5. NCU CLI metrics\n\n```bash\n# Essential metrics set\nncu --metrics \\\n  sm__throughput.avg.pct_of_peak_sustained_elapsed,\\\n  dram__throughput.avg.pct_of_peak_sustained_elapsed,\\\n  sm__warps_active.avg.pct_of_peak_sustained_active,\\\n  l1tex__t_sectors_pipe_lsu_mem_global_op_ld.sum,\\\n  smsp__sass_thread_inst_executed_op_ffma_pred_on.sum \\\n  .\u002Fmy_cuda_app\n\n# CSV export for CI\nncu --csv --metrics dram__bytes_read.sum,dram__bytes_write.sum .\u002Fmy_cuda_app\n\n# Set kernel replay mode for accurate counters\nncu --kernel-replay-mode application .\u002Fmy_cuda_app\n```\n\n### 6. Memory-bound vs compute-bound diagnosis\n\n```\nRoofline interpretation\n├── dram__throughput near peak AND sm__throughput low → memory-bound\n│   └── Fix: coalescing, shared mem tiling, reduce traffic\n├── sm__throughput near peak AND dram low → compute-bound\n│   └── Fix: tensor cores, loop unrolling, ILP\n└── Both low → launch config, occupancy, or sync overhead\n```\n\nRoofline model (conceptual):\n\n```\nPerformance (GFLOP\u002Fs)\n    |     \u002F\\  compute roof\n    |    \u002F  \\\n    |   \u002F    \\____ memory roof (bandwidth-limited region)\n    |  \u002F\n    +------------------ Arithmetic Intensity (FLOP\u002Fbyte)\n```\n\nMeasure arithmetic intensity: `smsp__sass_thread_inst_executed_op_ffma_pred_on.sum * 2 \u002F dram__bytes.sum`\n\n### 7. Occupancy analysis\n\n```bash\nncu --metrics sm__warps_active.avg.pct_of_peak_sustained_active,\\\nlaunch__occupancy_limit_registers,\\\nlaunch__occupancy_limit_shared_mem,\\\nlaunch__occupancy_limit_block_size \\\n.\u002Fmy_cuda_app\n```\n\n| Limiting factor | Typical fix |\n|-----------------|-------------|\n| Registers | `-maxrregcount`, simplify kernel |\n| Shared memory | Reduce tile size, split phases |\n| Block size | Try 128 or 256 instead of 512+ |\n\n### 8. Profiling workflow checklist\n\n```bash\n# 1. Build with line info (not -G unless debugging)\nnvcc -lineinfo -O3 -arch=sm_80 -o app main.cu\n\n# 2. Timeline first\nnsys profile --trace=cuda,nvtx -o timeline .\u002Fapp\n\n# 3. Deep dive on hot kernel\nncu --kernel-name regex:hot_kernel --set full .\u002Fapp\n\n# 4. Compare before\u002Fafter\nncu --csv --metrics sm__throughput.avg.pct_of_peak_sustained_elapsed .\u002Fapp_v1 > v1.csv\nncu --csv --metrics sm__throughput.avg.pct_of_peak_sustained_elapsed .\u002Fapp_v2 > v2.csv\n```\n\n## Common Problems\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| `ERR_NVGPUCTRPERM` | Insufficient profiling permissions | Run with sudo or set `NVreg_RestrictProfilingToAdminUsers=0` |\n| All metrics show zero | Profiling disabled or wrong GPU | Check `CUDA_VISIBLE_DEVICES`; use `--target-processes all` |\n| NCU report empty | Kernel too short or not launched | Increase workload; verify `cudaGetLastError()` |\n| Huge profiling overhead | Full metric sets on many kernels | Use `--kernel-name` filter; `--launch-skip` |\n| Timeline shows no overlap | Single default stream | Create multiple streams; use async copies |\n| Occupancy looks fine but kernel slow | Memory latency not hidden | Check memory coalescing; increase active warps |\n\n## Related Skills\n\n- `skills\u002Fgpu\u002Fcuda` — kernel writing, occupancy tuning, nvcc flags\n- `skills\u002Fgpu\u002Fgpu-memory-model` — coalescing, bank conflicts, SIMT model\n- `skills\u002Fgpu\u002Fcuda-debugging` — correctness before performance tuning\n- `skills\u002Fprofilers\u002Fintel-vtune-amd-uprof` — CPU-side roofline and hotspot analysis\n- `skills\u002Fprofilers\u002Fflamegraphs` — CPU flamegraphs complementary to nsys timeline\n- `skills\u002Fprofilers\u002Fhardware-counters` — general perf stat concepts",{"name":5,"description":7},"main","2efa23a75aae77f2552978f93b467264812fc436","skills-external\u002Fcuda-profiling","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci","2026-11-03 22:11:38",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add OzcanOrhanDemirci\u002FMode_Code --skill cuda-profiling",{"tool":37,"command":38},"bunx","bunx skills add OzcanOrhanDemirci\u002FMode_Code --skill cuda-profiling",{"tool":40,"command":41},"pnpm","pnpm dlx skills add OzcanOrhanDemirci\u002FMode_Code --skill cuda-profiling","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills-external\u002Fcuda-profiling\u002FSKILL.md",true,[45],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":16},"LICENSE.source","LICENSE","许可证",1065,[51,59,66,73,80,87],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":20},"01M7EJ63F7XYXF9CWC5PV0NRVH","verify","Verify the current work with fresh evidence before calling it done; run by the person.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Fverify\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":20},"01M7EJ5ZH7FNKBPT0EZQW7BEEM","turkish-text","Check Turkish text in this project (docs, app strings, store listings) for long dashes and the question particle's vowel harmony, then read for what a script cannot judge; run by the person.","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Fturkish-text\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":20},"01M7EJ5VSERBFR0GZ18H4GCWA9","trust-audit","Audit what runs inside Claude Code besides the model (plugins, hooks, MCP servers, skills) for what it could do; run by the person.","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Ftrust-audit\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":20},"01M7EJ5SBRX3N6ZFYTZP302YDF","store-check","Check whether this app project is ready for the App Store and Google Play, measured file by file and in the built package; run by the person.","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Fstore-check\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":20},"01M7EJ5QF30FZ0KWT18N587V1K","session-search","Find a past Claude Code session on this computer by what was said or done in it; run by the person.","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Fsession-search\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":20},"01M7EJ5N5C66CBN83YK0B6H06J","security","Check this project for secrets in files and history, vulnerable dependencies and risky settings; run by the person.","https:\u002F\u002Fgithub.com\u002FOzcanOrhanDemirci\u002FMode_Code\u002Fblob\u002Fmain\u002Fskills\u002Fsecurity\u002FSKILL.md",[],[]]