How gr0mila/cuda-flame-graph works
cuda-flame-graph is a CUDA program profiler that launches an application with the profiler library injected, captures CPU and GPU profiling data, and emits folded stacks for flame-graph visualization. The README documents filtering and display options, plus execution-time and stall-profiling modes. The source excerpts are partial, so the graph omits uncertain callback wiring and shows only the evidenced capture, aggregation, and launch relationships.
Main entry points: profiler.cpp CUDA profiler · loader.cc cuprof loader · interface.cpp Options and profiles · init.cc Load and unload hooks
Components 17
Launch and configuration
- cuprof loader
loader/loader.cc - Profiler library
utils/shared_library.h - Options and profiles
src/interface.cpp - Load and unload hooks
loader/init.cc
Sample capture
- Profiler lifecycle
src/interface.cpp - CUDA profiler
src/profiler.cpp - Linux perf events
src/profiler.cpp - Kernel activities
src/profiler.cpp - PC stall sampling
src/profiler.cpp
Stack processing
- Stack resolution
src/profiler.cpp - Frame filtering
src/profiler.cpp - Stack aggregation
src/profiler.cpp
Results
- Folded stacks
src/profiler.cpp
Other components
- Profiler user
- CUDA application
- CUPTI
- FlameGraph tool
Connections 19
- Profiler user → cuprof loader: runs with options
- cuprof loader → Profiler library: loads library
- cuprof loader → Options and profiles: calls parser
- Options and profiles → cuprof loader: sets environment
- cuprof loader → CUDA application: launches with preload
- CUDA application → Load and unload hooks: loads profiler
- Load and unload hooks → Profiler lifecycle: enables profiling
- Profiler lifecycle → CUDA profiler: initializes and finalizes
- CUDA profiler → Linux perf events: samples CPU stacks
- CUDA profiler → CUPTI: configures and subscribes
- CUPTI → Kernel activities: delivers activity records
- CUDA profiler → Kernel activities: processes GPU timing
- CUDA profiler → PC stall sampling: processes stall records
- CUDA profiler → Stack resolution: resolves sampled stacks
- Stack resolution → Frame filtering: classifies frames
- Frame filtering → Stack aggregation: adds accepted stacks
- Stack aggregation → Folded stacks: prints folded counts
- Profiler user → FlameGraph tool: visualizes output
- Folded stacks → FlameGraph tool: reads folded stacks