cuda-c-optimization

Optimize CUDA C kernels for performance, memory access, and numerical stability.

6|1|Updated Apr 19, 2026
One-click install
npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill cuda-c-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cuda-c-optimization
Source: https://github.com/xchang1121/AutoResearch-CC-hook/tree/main/skills/cuda-c/guides/cuda-c-optimization
Command: npx skills add https://github.com/xchang1121/AutoResearch-CC-hook --skill cuda-c-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

CUDA C kernels 常常存在性能不足、数值稳定性差和调试困难的问题。本 Skill 提供一个结构化、可操作的指南,帮助你优化 CUDA-C 代码、提升吞吐量、确保在常见工作负载中的数值可靠性。

Core Features & Use Cases

  • 块大小选择策略:针对不同内核类型(元素级、规约、矩阵乘法、图像处理)给出推荐的线程块大小与网格配置。
  • 内存访问优化:实现共存、对齐访问,避免 Bank 冲突,提升带宽利用率。
  • 计算优化:减少分支发散、使用快速数学函数、最小化全局原子操作。
  • 占用率与调试:检查网格/块配置,维护易于维护的调试检查表。
  • 数值稳定性技巧:可靠的规约、安全的除法与平方根、避免溢出/下溢。
  • 使用场景:适用于需要性能调优、内存访问优化和数值稳定性的 CUDA-C 计算密集型任务。

Quick Start

Follow the guide to profile a kernel, adjust block sizes, improve memory access, and validate numerical stability in your CUDA C code.

Frequently Asked Questions about cuda-c-optimization

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

FAQPage Schema
How do I optimize CUDA C kernel performance and improve memory coalescing?

Reduce branch divergence in CUDA kernels by restructuring control flow to ensure threads within a warp follow similar execution paths. Apply structured debugging checklists and minimize global atomic operations to further improve computational throughput.

How do I maintain numerical stability in CUDA reductions and divisions?

Maintain numerical stability in CUDA kernels by using reliable reduction algorithms, safe division, and square root functions. Apply specific techniques to prevent overflow and underflow when processing compute-heavy numerical tasks.

What is the best way to choose block sizes for different CUDA kernel types?

Use a structured debugging checklist for CUDA C kernels to validate grid configurations, check occupancy, and trace memory access issues. Follow a step-by-step guide to profile, adjust block sizes, and validate numerical stability in your code.

Why does my CUDA kernel have low occupancy and how can I debug it?

Low occupancy in CUDA kernels often stems from improper grid and block configurations or excessive register usage. Debug it by checking block sizing strategies and verifying memory access patterns to identify bank conflicts and divergence.