hip-rocm
AMD HIP and ROCm ecosystem for cross-platform GPU development. Execute hipify conversion tools, generate HIP-compatible kernel code, handle CUDA/HIP API differences, configure ROCm toolchain, and profile with rocprof.
What this skill does
# hip-rocm
You are **hip-rocm** - a specialized skill for AMD HIP and ROCm ecosystem development. This skill provides expert capabilities for cross-platform GPU programming targeting AMD GPUs.
## Overview
This skill enables AI-powered AMD GPU development including:
- Execute hipify conversion tools (hipify-perl, hipify-clang)
- Generate HIP-compatible kernel code
- Handle CUDA/HIP API differences
- Configure ROCm toolchain compilation
- Profile with rocprof and omniperf
- Support MI100/MI200/MI300 architectures
- Maintain single-source NVIDIA/AMD code
- Benchmark cross-platform performance
## Prerequisites
- ROCm 5.0+
- HIP runtime
- hipify tools
- AMD GPU (or NVIDIA GPU with HIP)
## Capabilities
### 1. CUDA to HIP Conversion
Convert CUDA code to HIP:
```bash
# Using hipify-perl (quick conversion)
hipify-perl cuda_file.cu > hip_file.cpp
# Using hipify-clang (more accurate)
hipify-clang cuda_file.cu -o hip_file.cpp
# Batch conversion
hipify-perl -inplace *.cu
hipconvertinplace.sh .
# Generate conversion statistics
hipify-perl --print-stats cuda_file.cu
# Exclude certain patterns
hipify-perl --skip-includes cuda_file.cu > hip_file.cpp
```
### 2. HIP Kernel Development
Write HIP-compatible kernels:
```cpp
#include <hip/hip_runtime.h>
// HIP kernel (portable to CUDA and AMD)
__global__ void vectorAdd(const float* a, const float* b, float* c, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
c[idx] = a[idx] + b[idx];
}
}
// Launch syntax (same as CUDA)
int main() {
// Allocate memory
float *d_a, *d_b, *d_c;
hipMalloc(&d_a, size);
hipMalloc(&d_b, size);
hipMalloc(&d_c, size);
// Copy to device
hipMemcpy(d_a, h_a, size, hipMemcpyHostToDevice);
hipMemcpy(d_b, h_b, size, hipMemcpyHostToDevice);
// Launch kernel
int blockSize = 256;
int numBlocks = (n + blockSize - 1) / blockSize;
hipLaunchKernelGGL(vectorAdd, dim3(numBlocks), dim3(blockSize),
0, 0, d_a, d_b, d_c, n);
// Alternative launch syntax
vectorAdd<<<numBlocks, blockSize>>>(d_a, d_b, d_c, n);
// Synchronize and copy back
hipDeviceSynchronize();
hipMemcpy(h_c, d_c, size, hipMemcpyDeviceToHost);
// Cleanup
hipFree(d_a);
hipFree(d_b);
hipFree(d_c);
}
```
### 3. API Compatibility Macros
Handle CUDA/HIP differences:
```cpp
// Platform detection
#ifdef __HIP_PLATFORM_AMD__
// AMD-specific code
#elif defined(__HIP_PLATFORM_NVIDIA__)
// NVIDIA HIP code
#elif defined(__CUDA_ARCH__)
// CUDA-specific code
#endif
// Common compatibility header
#if defined(__HIPCC__) || defined(__HIP__)
#include <hip/hip_runtime.h>
#define DEVICE_SYNC hipDeviceSynchronize
#define MALLOC hipMalloc
#define FREE hipFree
#define MEMCPY hipMemcpy
#else
#include <cuda_runtime.h>
#define DEVICE_SYNC cudaDeviceSynchronize
#define MALLOC cudaMalloc
#define FREE cudaFree
#define MEMCPY cudaMemcpy
#endif
// Warp size handling
#ifdef __HIP_PLATFORM_AMD__
#define WARP_SIZE 64 // AMD wavefront
#else
#define WARP_SIZE 32 // NVIDIA warp
#endif
```
### 4. ROCm Compilation
Compile HIP code:
```bash
# Compile for AMD GPU
hipcc -o program program.cpp
# Specify target architecture
hipcc --offload-arch=gfx90a -o program program.cpp # MI200
hipcc --offload-arch=gfx942 -o program program.cpp # MI300
# Multiple targets
hipcc --offload-arch=gfx908 --offload-arch=gfx90a -o program program.cpp
# With optimization
hipcc -O3 -o program program.cpp
# Generate assembly
hipcc -S --offload-arch=gfx90a program.cpp
# Verbose compilation
hipcc -v -o program program.cpp
# CMake configuration
set(CMAKE_CXX_COMPILER hipcc)
set(GPU_TARGETS "gfx90a" CACHE STRING "GPU architectures")
```
### 5. Profiling with rocprof
Profile AMD GPU applications:
```bash
# Basic profiling
rocprof ./program
# Collect specific metrics
rocprof -i metrics.txt ./program
# Generate trace
rocprof --hip-trace ./program
rocprof --hsa-trace ./program
# System trace
rocprof --sys-trace ./program
# Export to JSON
rocprof --stats --json ./program
# Metrics file example (metrics.txt)
# pmc: SQ_WAVES, SQ_INSTS_VALU, SQ_INSTS_SMEM
# pmc: TCC_HIT_sum, TCC_MISS_sum
```
### 6. Omniperf Analysis
Deep performance analysis:
```bash
# Profile application
omniperf profile -n workload_name ./program
# Analyze profile
omniperf analyze -p workload_name
# Web-based GUI
omniperf analyze -p workload_name --gui
# Compare profiles
omniperf analyze -p baseline -p optimized --compare
# Specific analysis sections
omniperf analyze -p workload_name --metric-set memory
omniperf analyze -p workload_name --metric-set compute
```
### 7. Architecture-Specific Optimization
Optimize for AMD architectures:
```cpp
// Wave-aware programming (64-thread wavefront)
__device__ int waveReduceSum(int val) {
#pragma unroll
for (int offset = 32; offset > 0; offset >>= 1) {
val += __shfl_down(val, offset);
}
return val;
}
// Use LDS (Local Data Share) efficiently
__shared__ __align__(16) float lds[256];
// Memory coalescing for AMD (256-byte granularity)
__global__ void coalescedKernel(float4* data, int n) {
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < n) {
float4 val = data[idx]; // 16-byte aligned load
// Process...
data[idx] = val;
}
}
// Architecture-specific kernels
#if __gfx90a__ || __gfx942__
// MI200/MI300 optimizations
// Use matrix cores (MFMA instructions)
#elif __gfx908__
// MI100 optimizations
#endif
```
### 8. hipBLAS and rocBLAS
GPU math libraries:
```cpp
#include <hipblas/hipblas.h>
// Or for ROCm-native
#include <rocblas/rocblas.h>
hipblasHandle_t handle;
hipblasCreate(&handle);
// GEMM operation
float alpha = 1.0f, beta = 0.0f;
hipblasSgemm(handle,
HIPBLAS_OP_N, HIPBLAS_OP_N,
M, N, K,
&alpha,
d_A, M,
d_B, K,
&beta,
d_C, M);
// rocBLAS with explicit stream
rocblas_handle roc_handle;
rocblas_create_handle(&roc_handle);
rocblas_set_stream(roc_handle, stream);
rocblas_sgemm(roc_handle,
rocblas_operation_none, rocblas_operation_none,
M, N, K,
&alpha, d_A, M, d_B, K, &beta, d_C, M);
```
### 9. RCCL Collective Operations
AMD's NCCL equivalent:
```cpp
#include <rccl/rccl.h>
// Initialize RCCL (same API as NCCL)
rcclComm_t comm;
rcclUniqueId id;
rcclGetUniqueId(&id);
rcclCommInitRank(&comm, worldSize, id, rank);
// All-reduce
rcclAllReduce(sendbuff, recvbuff, count, rcclFloat, rcclSum, comm, stream);
// Cleanup
rcclCommDestroy(comm);
```
## Process Integration
This skill integrates with the following processes:
- `hip-porting-cross-platform.js` - Cross-platform porting
- `multi-gpu-programming.js` - Multi-GPU development
## Output Format
```json
{
"operation": "hipify",
"status": "success",
"input_files": ["kernel.cu", "main.cu"],
"output_files": ["kernel.cpp", "main.cpp"],
"conversion_stats": {
"cuda_calls_converted": 45,
"manual_review_needed": 3,
"warnings": ["__shfl_sync not directly portable to HIP"]
},
"target_architectures": ["gfx90a", "gfx942"],
"recommendations": [
"Review wavefront size (64 vs 32) in reduction kernels",
"Consider using rocBLAS for BLAS operations"
]
}
```
## Dependencies
- ROCm 5.0+
- HIP runtime
- hipify-perl or hipify-clang
- rocprof/omniperf (for profiling)
## Constraints
- Warp/wavefront size differs (32 vs 64)
- Some CUDA intrinsics need manual porting
- Texture memory API differs
- CUDA-specific features may not port
Related in Ads & Marketing
ads
IncludedMulti-platform paid advertising audit and optimization skill. Analyzes Google, Meta, YouTube, LinkedIn, TikTok, Microsoft, and Apple Ads. 250+ checks with scoring, parallel agents, industry templates, and AI creative generation.
banana
IncludedAI image generation Creative Director powered by Google Gemini Nano Banana models. Use this skill for ANY request involving image creation, editing, visual asset production, or creative direction. Triggers on: generate an image, create a photo, edit this picture, design a logo, make a banner, visual for my anything, and all /banana commands. Handles text-to-image, image editing, multi-turn creative sessions, batch workflows, and brand presets.
rpg-migration-analyzer
IncludedAnalyzes legacy RPG (Report Program Generator) programs from AS/400 and IBM i systems for migration to modern Java applications. Extracts business logic from RPG III/IV/ILE source code, identifies data structures (D-specs), file operations (F-specs), program dependencies (CALLB/CALLP), and converts RPG constructs to Java equivalents. Generates migration reports, complexity estimates, and Java implementation strategies with POJO classes, JPA entities, and service methods. Use when modernizing AS/400 or IBM i legacy systems, analyzing RPG source files (.rpg, .rpgle, .RPGLE), converting RPG to Java, mapping data specifications to Java classes, planning legacy system migration, or when user mentions RPG analysis, Report Program Generator, RPG III/IV/ILE, AS/400 modernization, IBM i migration, packed decimal conversion, or mainframe application rewrite.
brand-library-architect
IncludedBuild a complete brand library for a product — visual asset render pipeline, brand documentation set (BRAND, COPY, MANIFESTO, BIOS, FAQ, GLOSSARY, TONE, PRICING), open-source convention files (README, CONTRIBUTING, SECURITY, CODE_OF_CONDUCT), and a self-contained press kit. This skill should be used when the user asks to "build a brand library / brand kit / press kit / brand assets" for a product, "set up a brand library workflow," "create a positioning manifesto plus visual identity," or any combination of brand documentation + visual asset pipeline. Apply phase-by-phase or run end-to-end. Templates are product-agnostic and use {{TOKEN}} placeholders the skill prompts the user to fill.
writing-tech-post
IncludedAuthors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
blog-google
IncludedGoogle API integration for blog performance: PageSpeed Insights, CrUX Core Web Vitals with 25-week history, Search Console performance, URL Inspection, Indexing API, GA4 organic traffic, NLP entity analysis for E-E-A-T, YouTube video search for embedding, and Google Ads Keyword Planner. Progressive feature availability based on credential tier (API key, OAuth/service account, GA4, Ads). Shares config with claude-seo at ~/.config/claude-seo/google-api.json. Use when user says "google data", "page speed", "core web vitals", "search console", "indexation", "GA4", "keyword research", "nlp entities", "blog performance", "youtube search", "google api setup".