Examples demonstrating how to use kerncap to extract, replay, and validate GPU kernels.
Full kerncap pipeline on a multi-kernel HIP application.
Run:
python examples/extract_and_replay.pyWhat it does:
- Compiles
mini_pipeline.hip(five GPU kernels in a single file) - Profiles the application to rank kernels by GPU time
- Extracts the target kernel into a standalone reproducer
- Replays the captured kernel in isolation and reports timing
- Validates the reproducer for correctness
Options:
# Extract a different kernel (default: vector_scale)
python examples/extract_and_replay.py --kernel histogram_atomic
# Benchmark with more iterations
python examples/extract_and_replay.py --iterations 50
# Save the reproducer to a specific directory
python examples/extract_and_replay.py --output ./my_reproducerA standalone HIP application with five kernels exercising common GPU patterns:
| Kernel | Pattern |
|---|---|
vector_add |
Elementwise addition |
vector_scale |
Scalar multiplication |
vector_bias_relu |
Fused bias + ReLU activation |
vector_shift |
Elementwise shift |
histogram_atomic |
Atomic histogram (different grid size) |
Compile and run directly:
hipcc -O2 -o mini_pipeline examples/mini_pipeline.hip
./mini_pipeline- ROCm installed (
hipcc,rocprofv3on PATH) - AMD GPU (MI300+ recommended)
- kerncap installed:
pip install -e kerncap/