Write CUDA GEMM Kernel

Design and implement a CUDA GEMM kernel with FP32 accumulation and tiling.

54|7|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/KrxGu/kernel-skills --skill write-cuda-gemm-kernel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Write CUDA GEMM Kernel
Source: https://github.com/KrxGu/kernel-skills/tree/main/skills/cuda/write-cuda-gemm-kernel
Command: npx skills add https://github.com/KrxGu/kernel-skills --skill write-cuda-gemm-kernel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides engineers through designing and implementing a correct, performance-aware CUDA GEMM kernel (C = alpha * A * B + beta * C) with decisions about tiling strategy, memory hierarchy usage, tensor core eligibility, and when to defer to cuBLAS or CUTLASS.

Core Features & Use Cases

  • Guided design of a custom GEMM kernel including tiling, shared memory layout, and epilogue fusion decisions.
  • Decision framework for when to use cuBLAS or CUTLASS and how to handle batched or nonstandard layouts.
  • Applicable in constrained hardware scenarios or research contexts where maximum control over memory and compute is required.

Quick Start

Provide the problem specifications (M, N, K; dtypes; layouts; transpositions; target SM) and initiate the kernel design workflow for a CUDA GEMM.

Frequently Asked Questions about Write CUDA GEMM Kernel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a custom CUDA GEMM kernel with shared memory tiling?

A custom CUDA GEMM kernel implementation requires defining a tiling hierarchy, planning shared memory layouts for matrix blocks, and handling epilogue logic for operations like alpha*A*B + beta*C to maximize hardware utilization.

When should I write a custom GEMM kernel instead of using cuBLAS or CUTLASS?

Writing a custom CUDA GEMM kernel is necessary for workloads requiring nonstandard memory layouts, fused epilogue operations, or constrained hardware scenarios where cuBLAS or CUTLASS do not fit exact project requirements.

How does double buffering and shared memory improve GEMM kernel performance?

Double buffering and shared memory improve GEMM performance by overlapping data loading with computation, reducing memory latency, and ensuring continuous thread execution during tiled matrix multiplication.

Can I use tensor cores for FP32 accumulation in my CUDA GEMM kernel?

Tensor core eligibility for a CUDA GEMM kernel depends on checking target SM specifications and input dtypes, allowing you to determine if hardware acceleration applies to your FP32 accumulation workload.

What is the best way to handle boundary conditions in a tiled CUDA GEMM kernel?

Handling boundary conditions in a tiled CUDA GEMM kernel requires careful shared memory planning and explicit checks during matrix block loading to prevent out-of-bounds memory access when dimensions mismatch tile sizes.

Does this CUDA GEMM kernel design support batched matrix multiplication?

The guided CUDA GEMM kernel design framework includes decision logic for handling batched or nonstandard layouts, ensuring correctness guarantees while maintaining performance across multiple matrix operations.