What is Latency hiding?

Keeping waits, such as for memory, from showing up in performance by doing other work in the meantime. GPUs do it by switching among many warps.

Field: GPU Programming

Japanese name: レイテンシ隠蔽

The idea

Latency is the delay between issuing a request and receiving its result. A read from memory is an operation with a large delay. If the arithmetic units do nothing meanwhile, throughput falls. Latency hiding means doing other work during the wait so that the arithmetic units are not left idle. The wait itself does not get shorter. It simply shows up less in the overall throughput.

The mechanism on a GPU, with an example

On NVIDIA GPUs, an SM holds many warps and executes whichever are ready to issue an instruction. Warp state stays on the SM, so switching takes no extra effort. Assume one issue mechanism that can issue an instruction from one warp per cycle. If each warp repeatedly issues instructions for 20 cycles and then waits 400 cycles, one round is 20 + 400 = 420 cycles. With42020=21420 ÷ 20 = 21warps taking turns, the gaps are filled.

Difference from a CPU, and limits

A CPU mainly reduces the waits of one thread with caches, prefetching and out-of-order execution. A GPU puts more weight on filling the waits with other warps than on shortening them. So when few warps are resident on an SM, that is, when occupancy is low, the waits cannot be fully hidden. If a single thread has enough independent instructions to issue during the wait, those can, in some cases, fill the gap as well.

Try it: questions about Latency hiding

Assume an SM of a GPU has one issue unit that can issue instructions from one warp per cycle. Each warp repeatedly issues 20 cycles of instructions and then waits 400 cycles for the result of a memory load. If switching warps takes no time, at least how many warps are needed to eliminate idle time due to memory waits (latency hiding)?

  1. A21
  2. B2
  3. C420
Show answer and explanation

Answer: A. 21

One warp can issue instructions for only 20 out of every 420 cycles (20 + 400). To keep the issue unit busy,42020=21420 ÷ 20 = 21warps must take turns: while one warp waits 400 cycles, the other 20 warps fill that time by issuing 20 cycles each. With too few warps, the wait shows up in performance and the execution units sit idle. On a real GPU the number needed depends on the wait length and the instruction mix, and waits can also be filled by adding mutually independent instructions within one warp (instruction-level parallelism).

FAQ

Does latency hiding make a single thread run faster?

No. The time each thread waits for memory is unchanged. What rises is the amount of work the whole GPU completes per unit time.

How does it differ from an operating system switching threads?

The cost of switching differs. An OS context switch saves and swaps state such as registers. On a GPU the state of each warp stays on the SM, so no such swapping is needed.

Questions that mention Latency hiding (5)

Latency hiding appears in 6 practice questions across 3 topics, including GPU Programming, Memory Hierarchy, DRAM.

  1. Which correctly describes a "rank" on a DRAM module?
  2. When inserting software prefetch instructions, which statement about how far ahead to fetch (the prefetch distance) is correct?
  3. What is the main advantage of a non-blocking cache, which accepts other accesses while a miss is being serviced?
  4. Which statement about GPU occupancy is correct?
  5. In general, how do GPU caches compare with CPU caches?

Books on GPU Programming Ad

As an Amazon Associate I earn from qualifying purchases.

Semiconductor, Electronics and Computing Calculators

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary