﻿# GPU thread blocks: what must fit before a block can run

A GPU block becomes resident only when its combined resource requirements fit; changing block size can therefore change several constraints at once.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/learn-thread-block-residency/
Language: en

A thread block is a cooperation group in the CUDA programming model and a resource-allocation unit during execution. Its threads need registers, execution slots and any requested shared memory. Looking at those requirements together makes block residency easier to understand than treating the grid as a bag of independently scheduled threads.

## The block has a shared resource footprint

Each thread contributes register demand while the block contributes shared-memory demand and a launch shape. Hardware limits apply to these demands together. A block can be valid under the API and still leave little room for another block on the same multiprocessor. Residency describes allocated work rather than a promise that all its instructions execute simultaneously. The distinction matters when comparing launch shapes that contain the same total number of logical elements.

Primary reference: [CUDA Programming Guide: Writing SIMT Kernels](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-cuda-kernels.html).

## A tiled example exposes the tradeoff

Imagine a matrix operation where a block stages input tiles in shared memory. Enlarging the tile increases reuse, but it also increases the storage and cooperative work assigned to that block. Fewer blocks may then coexist. This does not prove that the larger tile is slower: better reuse can outweigh reduced residency. The example explains why tile size, memory footprint and execution opportunity should be considered as one design rather than optimized independently.

Primary reference: [CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/).

## Edges are a different kind of unused work

A grid may include blocks that partly lie beyond the logical input boundary. Bounds checks keep those threads from reading invalid elements, but the launch still reserves resources according to its declared shape. A launch can therefore lose useful work through edge masking even when its theoretical residency looks attractive. Keep the problem dimensions visible in the comparison. Divisible synthetic dimensions can hide a tail that matters for the shapes used by the application.

Primary reference: [Nsight Compute Profiling Guide](https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html).

## Use compiled resource evidence

Source code alone does not determine the final register footprint. Compiler decisions, specialization and generated instructions affect the resources used by the actual kernel. Examine compiled resource information and the profiler’s launch statistics for the exact build under study. Do not transfer a count from a differently specialized kernel merely because the function name is similar. The relevant unit is the compiled launch, including dynamic shared memory and the selected problem configuration.

## Compare shapes with one mathematical task

A useful experiment keeps the matrix operation and accepted numerical error fixed while varying a small set of launch shapes. For each shape, record tile storage, compiled registers, useful edge coverage and observed execution. The result can reveal whether reuse, parallel alternatives or masked work dominates. A residency calculation narrows the hypothesis space; measured completion and correctness decide whether the chosen block arrangement improves this workload.

Related reading: [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/); [Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/).
