0Pricing
CUDA Academy · Lesson

Grid-Stride Loops

Handling arrays larger than the grid.

When the Array Is Huge

Sometimes the data is far bigger than the threads you launch. One thread per element no longer fits, so you need each thread to handle several elements.

The Grid Has a Size

The total number of threads is the grid size: blocks times threads per block. This stride is how far apart each thread's elements sit.

int stride = blockDim.x * gridDim.x;

All lessons in this course

  1. The Classic Index Formula
  2. Guarding Against Out-of-Range
  3. Rounding Up the Block Count
  4. Grid-Stride Loops
← Back to CUDA Academy