cuda-c-basics

Explain and implement basic CUDA-C kernel programming for GPU acceleration.

258|48|Updated Jun 22, 2020
One-click install
npx skills add https://github.com/mindspore-ai/akg --skill cuda-c-basics-mindspore-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cuda-c-basics
Source: https://github.com/mindspore-ai/akg/tree/main/akg_agents/python/akg_agents/op/resources/skills/cuda-c/guides/cuda-c-basics
Command: npx skills add https://github.com/mindspore-ai/akg --skill cuda-c-basics-mindspore-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

CUDA-C basics provide a practical foundation for writing and reasoning about GPU kernels, memory usage, and launch configurations.

Core Features & Use Cases

  • Understand the standard CUDA kernel structure and how to launch kernels from host code.
  • Learn memory hierarchies (global, shared, registers, constant) and how they impact performance.
  • Apply best practices for simple GPU computations using the five-step kernel pattern.

Quick Start

Compile and run a minimal CUDA-C kernel that doubles each element in an array using a standard five-step pattern.

Frequently Asked Questions about cuda-c-basics

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

FAQPage Schema
How do I write and launch a basic CUDA-C kernel for GPU acceleration?

To write and launch a CUDA-C kernel, define a __global__ function, allocate device memory, transfer data from host to device, execute the kernel across a grid and block configuration, and copy results back to the host.

What is the standard five-step structure for CUDA kernel programming?

The standard five-step CUDA kernel structure involves allocating GPU memory, copying input data from host to device, launching the kernel with specified grid and block dimensions, copying output data back to host, and freeing the allocated device memory.

How does CUDA memory management work with global, shared, and constant memory?

CUDA memory management categorizes data by access scope and speed: global memory for host-device transfers, shared memory for inter-thread communication within a block, constant memory for read-only data, and registers for fast thread-local access.

How do I calculate global thread indices when launching a CUDA kernel?

To calculate global thread indices in a CUDA kernel, multiply the block index by the block dimension and add the thread index, ensuring each thread maps to a unique data element across the entire grid configuration.

Do I need PyTorch experience to learn CUDA-C kernel programming basics?

No, PyTorch experience is not strictly required to learn CUDA-C kernel programming basics, though understanding tensor operations helps; this foundational skill focuses directly on writing C kernels and managing GPU memory hierarchies.

What is the best way to structure host-device data transfers in a simple GPU computation?

The best way to structure host-device data transfers is to use the standard five-step kernel pattern: explicitly allocate device memory, copy inputs to the GPU before launch, and retrieve outputs to the host immediately after kernel execution.