hip-kernel-optimization

hip-kernel-optimization is a skill for Claude Code, Codex from AMD-AGI/Apex. It costs 56 tokens per session (2,699 once invoked), scanned A, original, MIT.

A guide for writing and tuning HIP kernels, which are GPU programs that can run on AMD and NVIDIA hardware. It covers memory access, shared memory, occupancy, vectorization, asynchronous operations, loop unrolling, and profiling.

In plain words
What is it for?
Use it to write or review HIP kernels, port CUDA code to HIP, profile with rocprof, and improve memory access, tiling, block sizing, or loop performance.
Why use it?
It helps diagnose whether a kernel is limited by memory, computation, or the number of active GPU threads, and suggests relevant tuning steps.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to write or review HIP kernels, port CUDA code to HIP, profile with rocprof, and improve memory access, tiling, block sizing, or loop performance.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/amd-agi/apex/hip-kernel-optimization
View source ↗ AMD-AGI/Apex
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add AMD-AGI/Apex --skill hip-kernel-optimization
Clone the repo
git clone --depth 1 https://github.com/AMD-AGI/Apex

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for hip-kernel-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/amd-agi/apex/hip-kernel-optimization/github.svg)](https://agentmods.dev/skills/amd-agi/apex/hip-kernel-optimization)
Your own site
<a href="https://agentmods.dev/skills/amd-agi/apex/hip-kernel-optimization"><img src="https://agentmods.dev/badge/skills/amd-agi/apex/hip-kernel-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for hip-kernel-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/amd-agi/apex/hip-kernel-optimization"><img src="https://agentmods.dev/badge/skills/amd-agi/apex/hip-kernel-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,699 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00056 $0.02699
Opus 5.5 $0.00022 $0.01080
Sonnet 5.5 $0.00011 $0.00540
Haiku 4.5 $0.00006 $0.00270

Measured 1mo ago against content hash a9c9cfd80b48, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

hip-kernel-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

tools/skills/hip-kernel-optimization/SKILL.md · 256 lines

How it starts

The opening of the file, as written. The whole thing — 256 lines — stays where its author put it; the contents beside it link to each section on GitHub.

HIP Kernel Optimization

Purpose

Provide ready patterns for efficient HIP kernels and guide diagnosis of memory throughput, occupancy, and synchronization bottlenecks.

When to Use

  • Implementing or reviewing HIP kernels for AMD MI/CDNA architectures or CUDA-portable code
  • Porting CUDA code to HIP while retaining performance
  • Preparing profiling runs with rocprof

Optimization Priority

Phase 1: Low-hanging fruit (try first, low risk)

  1. #pragma unroll on hot loops with small, fixed trip counts
  2. Enable -ffast-math compiler flag for floating-point kernels
  3. Use 32B vectorized loads/stores instead of 16B
  4. Add __launch_bounds__(maxThreads, minBlocks) to guarantee occupancy
  5. Add const qualifiers on read-only pointers
  6. Verify memory coalescing (consecutive threads → consecutive addresses)

Phase 2: Targeted improvements (profile first) 7. Profile with rocprof to confirm bottleneck 8. If memory-bound: CK-Tile buffer views with vectorization 9. If compute-bound: Shared memory tiling 10. Dynamically calculate block size based on problem dimensions 11. Replace large 2D shared arrays with atomicAdd for sparse patterns 12. Provide multiple block size configurations to avoid register spill 13. Add explicit rounding mode control for numerical correctness 14. Pre-compute workspace size to avoid dynamic allocation 15. Implement CSV-based tuning cache for repeated GEMM shapes

Phase 3: Complex transformations (high effort) 16. Algorithm changes (e.g., Top-K-only softmax) 17. gfx950: Use 16x16x32 MFMA instead of 2x 16x16x16 18. Kernel fusion (multi-op in single kernel) 19. Persistent kernels for repeatedly executed operations 20. Shape-based heuristic dispatching

Anti-patterns:

  • Optimizing everything at once
  • Manual loop unrolling (use #pragma unroll instead)
  • Over-unrolling (factor > 8)
  • Premature vectorization without alignment check
  • Unnecessary buffer coherence flags (e.g., glc)

Core Optimization Patterns

1. Memory Access

  • Coalescing: Map consecutive threads to consecutive addresses; prefer SoA over AoS
  • Vectorization: Use CK-Tile buffer views for efficient I/O; prefer 32B loads over 16B
  • Boundary handling: Separate fast vectorized path from slow boundary path
    if(idx + VEC_SIZE <= d) {
        vec_o out_vec;
        #pragma unroll
        for(size_t j = 0; j < VEC_SIZE; j++) {
            out_vec[j] = compute(x[j], y[j]);
        }
        buffer_out.template set(idx, 0, true, out_vec);  // Fast path
    } else {
        for(size_t j = 0; j < VEC_SIZE; j++) {          // Boundary path
            if(idx + j < d) ptr_out[idx + j] = compute(...);
        }
    }
    

Read the full file on GitHub · 256 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 256 lines · 56 tokens per session scan A a9c9cfd80b48

Subscribe to this mod's changes

hip-kernel-optimization is a skill published in the GitHub repository AMD-AGI/Apex (78 stars, last pushed 23d ago), licensed MIT. It adds 56 tokens to every session and 2,699 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

optimize-global-memory-access

Guide the agent through diagnosing and restructuring CUDA global memory access patterns to maximize effective memory bandwidth, covering coalescing requirements, vectorized loads, AoS vs SoA layouts, shared memory staging for non-coalesced patterns, and L2 cache behavior.

tensormux/kernel-skills · 0 tokens

doca-argp

Use this skill for hands-on DOCA Arg Parser CLI work on a shipped sample or new DOCA-using app — adding / removing / renaming flags; wiring docaargpinit → register params → docaargpstart → docaargpdestroy in order; picking a parameter type from the full public enum (DOCAARGPTYPESTRING, INT, BOOLEAN, DEVICE, DEVICEREP…

NVIDIA/skills · 267 tokens

embedded-stm32

Best practices for embedded C/C++ development on STM32 microcontrollers using the HAL, covering peripherals, DMA, interrupts, memory constraints, and hardware-focused testing. Use when writing STM32 HAL code, configuring peripherals generated by STM32CubeMX, working with interrupts or DMA, debugging with SWD/JTAG…

Mindrally/skills · 87 tokens

acad-arx-wizard

Agentic ObjectARX project scaffolding for AutoCAD 2027 / Visual Studio 2026. Replaces the broken .vsz VsWizardEngine wizard with a PowerShell script that generates identical C++ project files. Works for new ARX/DBX/CRX projects and add-on class wizards (Jig, Reactors, Custom Object, MFC, .NET Wrapper, COM Wrapper…

autodesk-platform-services/skills · 92 tokens

cortex-m-patterns

Cortex-M code patterns for SysTick, NVIC priority grouping, FPU enable, MPU regions, AAPCS inline assembly, DWT cycle counting, vector table relocation, and WFI sleep entry. Use when writing core-level Cortex-M code or checking it against a known-good pattern.

HermeticOrmus/LibreEmbed-Claude-Code · 65 tokens

bare-metal-patterns

Register-level C patterns for Cortex-M without a HAL: bit manipulation macros, GPIO and polled UART setup, SysTick timebase, interrupt-driven UART ring buffer, linker sections and map files, and weak default ISR handlers. Use when writing or reviewing HAL-free drivers and startup code.

HermeticOrmus/LibreEmbed-Claude-Code · 62 tokens