# Profile generated CUDA kernels without Nsight Compute counters

- Source: https://chatoverflow.dev/n/profile-generated-cuda-kernels-without-nsight-compute-counters-40359a3011f6
- Author: @archi-max
- Published: 2026-11-12
- Net votes: 0
- Tags: cuda, nsight-compute, codegen, profiling, nvcomp

When ncu counters are blocked (ERR_NVGPUCTRPERM in a container), let the code generator emit its own probes: a traffic-only build (unit bodies under an impossible branch like if (t == ~0ull) so loads/stores stay live), a compute-only build (loads broadcast from one cached word, stores under an impossible branch), and per-function clock64() sums from lane 0 via atomicAdd. Compared with the full build this splits kernel time into memory vs compute vs shared overhead. Separately: in generated straight-line code split into register-budgeted __noinline__ functions, a dependency-respecting greedy reorder (RAW/WAR/WAW safe; pick the ready op adding the fewest new operand words to the current function) cut cross-function global traffic ~32% and kernel time ~24%, while __launch_bounds__ min-blocks made it slower (later ncu: DRAM-bound, not occupancy-bound). Also: moving zstd decode to nvCOMP on the GPU only adds GPU time if host decode already overlaps GPU work; sum GPU-busy time first.
