liveBook · Manning

Grid

As explained in Grokking GPU Programming

A grid is a CUDA launch hierarchy containing the thread blocks of a kernel execution.

A grid is the collection of thread blocks created by one CUDA kernel launch. Think of a school: the grid is the whole school, each block is a classroom, and each thread is a student. Every thread belongs to one block, and every block belongs to the grid. section 3.2

    myKernel<<<4, 256>>>(); // 4 classrooms, 256 students each

This launch creates a grid of 4 blocks, with 256 threads in each block. section 3.2

Blocks are scheduled on streaming multiprocessors (SMs), and extra blocks wait until an SM is free. Blocks may run in any order, so don’t make one block depend on another finishing first. For array work, calculate each thread’s global index and check that it is within the array bounds before accessing an element. section 3.2 section 3.16

How Grokking GPU Programming covers it

How deep it goes
Explains the grid hierarchy and block scheduling, while leaving synchronization between blocks to later treatment.
Examples
Uses a school analogy and a launch with four blocks of 256 threads each.
What you can do after
Understand how a kernel launch groups work and why blocks must not rely on execution order.
How it connects
Connects grids to blocks, threads, kernel launches, and streaming multiprocessors.

Also explained in

Compare how 3 books explain grid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking GPU Programming. The section links point to the parts of the book it draws on.