What runs while a warp waits?
Follow a load dependency and compare what happens with one ready warp or two.
Before you run
Each thread doubles two input values. A multiply needs its loaded input before it can proceed. The scheduling model below shows which warp can run an instruction while another waits for data on the same SM.
Definitions
- Resident warp
- A warp whose state and required resources are allocated on a streaming multiprocessor (SM). Its next instruction may still be waiting for data.
- Issue slot
- One opportunity in this model for the scheduler to start a ready instruction.
Read the starter excerpts
Read-only CUDA C++ · doubleValues · starter kernel
__global__ void doubleValues(const float* input, float* output) {
int i = threadIdx.x;
output[i] = input[i] * 2.0f;
i += blockDim.x;
output[i] = input[i] * 2.0f;
}doubleValues gives each thread two elements, separated by blockDim.x. Each assignment loads an input value, multiplies that value by 2.0 and stores the result. main sets threads from warpsPerBlock and allocates twice as many elements. The teaching trace models this dependency, not compiler instruction order.
CUDA C++ · launch inside main()
doubleValues<<<1, threads>>>(input, output);The settings inside <<< >>> give the block count and threads per block. Parentheses pass the arguments to the kernel. These read-only excerpts show the starter. The CUDA source editor contains the storage and launch settings.
Edit and run CUDA
The CUDA source editor opens with the complete starter or your saved draft. To run the starter again, use Editor tools → Restore starter. Choose Undo restore there to recover the previous draft.
Click Compile and run with the starter. In Console, find Threads, values and last output. The starter launches 32 threads and doubles 64 values.
Change the source
In the CUDA source editor, above doubleValues, change warpsPerBlock from 1 to 2. Predict Threads and values, then compare those fields in Console after running again. Both runs double every input. Next use Compare ready and waiting warps below to inspect which instructions can run during a load wait; the CUDA output does not measure scheduling or time.
Read the starter’s execution diagram
- Load inputWarp A issues the load.
- Wait for the valueA cannot multiply yet. A ready warp B can issue here.
- MultiplyA can issue when its value arrives.
This dependency belongs to warp A. It need not stop warp B.
Hardware context
An SM keeps resident warps and their register values available. A warp scheduler selects a ready instruction for an appropriate execution unit. Another warp can issue while a load dependency blocks the first.
Read the hardware key
- Resident warp
- A warp has 32 lane positions; a small block can leave some unused. A resident warp has its state and required resources allocated on an SM. Its next instruction may still be waiting for data.
- Instruction
- One operation run by GPU hardware, such as a load, multiply or store.
- Warp scheduler
- Selects ready warp instructions for available execution hardware.
- Registers
- Hold working values associated with individual threads.
- Execution units
- Perform arithmetic and other instructions for threads; they are shared hardware.
- Load/store units
- Execute memory instructions, forming requests from active lanes’ addresses.
- L1 / L2 cache
- Keep recently used data on the GPU chip. L1 is local to an SM; L2 is shared across SMs in this simplified view.
CPU side · CUDA host
Host ↔ device · copies move data; launches request execution
GPU device
GPU compute chip
SM · streaming multiprocessor
Logical groups using this SM’s resources
Issue to the appropriate units
Registers ↔ execution units · operands and results
Have their own execution hardware and registers.
Blocks may be assigned to different SMs.
Global-memory requests ↔ on-chip interconnect
Chip ↔ device memory · data transfers
Simplified NVIDIA-style architecture. Boundaries show containment; arrows name relationships. Unit counts, block placement and timing vary by GPU. A thread or warp is not a dedicated physical processor.
Compare ready and waiting warps
Predict and run
The multiply depends on the loaded input. While a warp waits for its load, another warp on the same SM can issue an instruction if its own operands are ready. This teaching machine issues one instruction per slot and makes each load usable six slots after issue. Each warp handles two consecutive groups of 32 inputs.
Try it
Select One warp under Resident warps and click Run model. Use Next step to find an issue slot where no warp issues an instruction. Select Two warps, predict how many instructions issue before the first idle slot, then run and step again. Compare idle slots rather than elapsed GPU time.
These controls change only this model and its displayed excerpt; they do not edit the CUDA program above. Enter a prediction to compare with the model result.
CUDA C++ excerpt
// Host launch: 1 block of 32 threads, 64 elements.
// Device body. n is exactly twice the block size.
int i = threadIdx.x;
output[i] = input[i] * 2.0f;
i += blockDim.x;
output[i] = input[i] * 2.0f;Both assignments require a load, multiply and store. The model follows that source order for each warp. Changing the launch changes the amount of work, so compare idle slots between instructions.
Apply what you saw
With two warps, why can the machine still have idle slots even though each warp has work left?
Compare your explanation
Both warps can be waiting for different loads at the same time. A scheduler can only select an instruction whose operands are ready.
Watch ready warps share one SM 1 min 53 sec · Video walkthrough, captions and transcript
Use fullscreen to inspect the code and diagram labels.
Read the transcript
A pending load creates a dependency
Each thread in this starter doubles two inputs. Follow just the first load, multiply and store sequence. A multiply cannot use its input before that input arrives. What can the SM do during that wait?
Warps keep separate working values
The SM holds state for multiple resident warps. Registers hold values belonging to their threads. Resident means the warp’s state and required resources are present on this SM; it does not mean every instruction is ready.
Warp A’s operands become ready
In this chosen sequence, warp A requests its data and then receives it. Its first thread can now multiply one point zero. The scheduler selects ready instructions; the picture is not a measured schedule or a fixed GPU latency.
Warp B waits while A stays ready
Warp B now has an outstanding load. Warp A still has usable operands in its own registers. The two warps do not need separate arithmetic units to make progress.
Must the whole SM wait for B?
Pause here. Warp B’s load is pending, but warp A’s multiply has its operands. Can the scheduler choose A’s ready multiply without discarding B’s state?
Shared arithmetic runs a ready instruction
Yes. The arithmetic hardware uses A’s ready operands and produces two point zero for the selected thread. B’s state remains resident while its load is pending. This is hardware sharing between warps, not one processor reserved for every thread.
The same hardware can later run B
When B’s values arrive, the same arithmetic hardware can use them. Its selected input of thirty-three point zero becomes sixty-six point zero. More resident warps can supply ready instructions, but dependencies and resource limits still matter. This sequence does not predict a speed-up.
References hardware multithreading · launch and occupancy
The browser exercises need no installed CUDA documentation version. For local execution, use the documentation matching your toolkit. External references need internet access.
- CUDA · hardware multithreading (new tab)
A scheduler can issue a ready warp instruction while another warp waits, when the required execution resources are available.
Warp A awaits a load, but warp B has ready operands. Must the SM wait for A before issuing B?
Compare your answer
No. A scheduler can issue a ready instruction from B to suitable available hardware. This does not establish the latency or throughput of a particular GPU.
- CUDA · launch and occupancy (new tab)
Per-block registers, shared memory and thread counts constrain how many blocks can reside on an SM.
If a block uses more shared memory, can you conclude that more blocks fit on an SM or that the kernel becomes faster?
Compare your answer
Neither follows. Greater per-block use can reduce residency. Reuse and other effects may still help, so verify correctness and measure the actual workload on the target GPU.
Further GPU investigation Run this CUDA example on an NVIDIA GPU
In the CUDA source editor, open Editor tools and choose Export .cu to save the complete program. Use an NVIDIA GPU and a matching CUDA toolkit to run it outside the browser.
Browser simulation checks program behaviour; physical GPU timing requires a hardware measurement.
Enable JavaScript to save completion.