Source-Level GPU Performance Profiling

VerifiedSafe

Profile GPU kernels at source-line granularity using cycle-level timing and stall analysis. Identify performance hotspots and instruction-level metrics mapped to source lines.

Sby Skills Guide Bot
DevelopmentAdvanced
8/11/2026
Claude CodeCursorWindsurf
#gpu-profiling#rocm#performance-analysis#kernel-optimization#amd

Recommended for

Automated summary

Profiles GPU kernels at source-line granularity by mapping cycle and stall metrics from the compiled code to individual source lines.

Strengths

  • Attributes total cycles, stall cycles and idle cycles to each source line and each ISA instruction
  • Automatically sorts source lines by total_cycles descending so hotspots surface first
  • Exposes stall_percent to separate memory-bound lines from dependency-bound ones
  • Can be driven either through MCP tools (profile_application, analyze_instruction_hotspots) or the Linex Python API

Limitations

  • Requires AMD ROCm 7.0+ with rocprofv3, so it does not apply to NVIDIA GPUs or older ROCm releases
  • Source mapping only works for kernels compiled with -g; without debug symbols line-level profiling is unavailable
  • Beyond noting that debug symbols must exist, the skill gives little guidance for frameworks such as Triton
When to use it

Use it when you need to pinpoint exactly which lines of a GPU kernel consume the most cycles or cause stalls.

When not to use it

Avoid it when the target is not an AMD GPU on ROCm 7.0+, or when the binary cannot be rebuilt with debug symbols.

Security analysis

Safe
Quality score82/100

The skill provides instructions for using a GPU profiling library and API. It does not contain destructive commands, data exfiltration, obfuscation, or unsafe execution patterns. The only execution is running the user's own target application through a profiler, which is the intended legitimate purpose.

No concerns found

How this analysis is made

Examples

Top hotspot lines
Use Linex to profile ./my_app with kernel_filter='my_kernel' and show me the top 5 source lines by total_cycles with their stall percentages.
Memory-bound line analysis
Profile my HIP kernel with Linex and list every source line whose stall_percent is above 50, so I can see which ones are memory-bound.
Instruction drill-down
Run analyze_instruction_hotspots on my collected Linex profile and break down the instructions and latencies for the single hottest source line.

name: linex-profiling description: Profile GPU kernels at source-line granularity with cycle-level timing and stall analysis. Use when identifying performance hotspots at the source code level or analyzing instruction-level metrics mapped to source lines.

Linex: Source-Level GPU Performance Profiling

Map GPU performance metrics to your source code lines. Get cycle-level timing, stall analysis, and instruction-level metrics for each line of source code.

When to Use

  • User asks to profile a GPU application at source-line granularity
  • Need to identify which specific lines of code are performance bottlenecks
  • Analyzing stall patterns and execution bottlenecks at the source level
  • Understanding cycle-level timing for each line of code
  • Instruction-level analysis mapped to source lines

Instructions

  1. Ensure the target runs on AMD ROCm 7.0+ with rocprofv3 available.
  2. Kernels must be compiled with -g (debug symbols) for source mapping.
  3. Choose execution path:
    • If a Linex MCP server is available, use its MCP tools:
      • profile_application to run and profile a target application with the options below.
      • analyze_instruction_hotspots to perform instruction-level hotspot analysis on collected profiles.
    • Otherwise use the Python API from the environment where Linex is installed.

Python API

from linex import Linex

profiler = Linex(
    target_cu=0,                      # Target compute unit
    shader_engine_mask="0xFFFFFFFF",  # All shader engines
    activity=10,                      # Activity counter polling
)

profiler.profile("./my_app", kernel_filter="my_kernel")

# Show hotspots (sorted by total_cycles)
for line in profiler.source_lines[:5]:
    print(f"{line.file}:{line.line_number}")
    print(f"  {line.total_cycles:,} cycles ({line.stall_percent:.1f}% stalled)")
    print(f"  Executed {line.execution_count} times")

# Find memory-bound lines
memory_bound = [
    l for l in profiler.source_lines 
    if l.stall_percent > 50
]

# Instruction-level analysis
for line in profiler.source_lines[:1]:
    for inst in line.instructions:
        print(f"{inst.isa}: {inst.latency_cycles} cycles")

SourceLine Properties

  • file - Source file path
  • line_number - Line number
  • total_cycles - Sum of all instruction cycles
  • stall_cycles - Cycles spent waiting
  • idle_cycles - Cycles slot was idle
  • execution_count - Total executions
  • instructions - List of ISA instructions
  • stall_percent - Convenience: stall_cycles / total_cycles * 100

InstructionData Properties

  • isa - ISA instruction text
  • latency_cycles - Total cycles for this instruction
  • stall_cycles - Cycles spent waiting
  • idle_cycles - Cycles slot was idle
  • execution_count - How many times it ran
  • instruction_address - Virtual address in GPU memory
  • file - Parsed from source_location
  • line - Parsed from source_location
  • stall_percent - Convenience: stall_cycles / latency_cycles * 100

Workflow

  1. Ensure the target binary is built with -g (debug symbols) for source mapping.
  2. Create a Linex() profiler; optionally set target_cu, shader_engine_mask, or activity.
  3. Call profiler.profile(command, kernel_filter=...) to run profiling.
  4. Access profiler.source_lines (sorted by total_cycles) to find hotspots.
  5. Use line.stall_percent to identify memory-bound or dependency-bound lines.
  6. Drill down into line.instructions for instruction-level analysis.
  7. Use relative paths for the target binary so the skill is portable.

Notes

  • Requires ROCm 7.0+ with rocprofv3 support.
  • Source mapping requires kernels compiled with -g (debug symbols).
  • source_lines are automatically sorted by total_cycles (descending).
  • Use kernel_filter to profile specific kernels by name (regex pattern).
  • For Triton or other frameworks, ensure debug symbols are available in the compiled output.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/source-level-gpu-performance-profiling-mso6xg0a/download' --output '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md.part' && mv '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md.part' '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md' && test -s '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/linex-profiling' && cp -R '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a' '.claude/skills/linex-profiling'

Cursor
test -f '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md' && test -s '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/linex-profiling' && cp -R '.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a' '.cursor/skills/linex-profiling'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/source-level-gpu-performance-profiling-mso6xg0a'

openskills read 'source-level-gpu-performance-profiling-mso6xg0a'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/source-level-gpu-performance-profiling-mso6xg0a/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills