Home Knowledge Base Latency Hiding

Latency Hiding is the parallel computing technique of overlapping computation with data movement (memory loads, network communication, disk I/O) so that the processor is never idle waiting for data — using mechanisms like prefetching, double buffering, multithreading, and pipeline parallelism to mask the latency of slow operations behind useful computation, which is the fundamental strategy that makes both GPUs and modern CPUs achieve high throughput despite memory latencies being 100-1000× longer than computation time.

The Latency Problem

Latency Hiding Techniques

TechniqueMechanismHides
Thread-level parallelism (GPU)Switch warps on stallMemory latency
PrefetchingLoad data before neededMemory/cache latency
Double bufferingCompute on buffer A while loading BTransfer latency
Pipeline parallelismOverlap stagesEnd-to-end latency
Async memcpyDMA transfer concurrent with computePCIe/NVLink latency
Comm-compute overlapAllReduce during backward passNetwork latency

GPU Thread-Level Latency Hiding

Double Buffering

# Without double buffering:
for batch in dataset:
    data = load(batch)      # CPU idle during load
    result = compute(data)  # GPU idle during next load

# With double buffering:
buffer_a = load(batch_0)    # Initial load
for i in range(1, N):
    buffer_b = async_load(batch_i)  # Load next batch
    compute(buffer_a)               # Compute current batch (overlapped)
    swap(buffer_a, buffer_b)        # Swap buffers
compute(buffer_a)           # Process last batch

Communication-Computation Overlap in ML Training

Forward:  [Layer 1 → Layer 2 → Layer 3 → Layer 4]
Backward: [Grad 4 → Grad 3 → Grad 2 → Grad 1]
                ↓AllReduce    ↓AllReduce

Hardware Prefetching (CPU)

Async CUDA Operations

// Overlap transfer and compute using CUDA streams
cudaStream_t stream_compute, stream_transfer;
cudaMemcpyAsync(d_next, h_next, size, H2D, stream_transfer);
my_kernel<<<grid, block, 0, stream_compute>>>(d_current);
cudaDeviceSynchronize();
// Transfer and compute happen simultaneously

Latency hiding is the single most important principle in high-performance computing — it is why GPUs with 200ns memory latency achieve 80%+ compute utilization, why distributed training scales to thousands of GPUs despite microsecond network latencies, and why modern CPUs run at near-peak throughput despite the memory wall, making latency hiding techniques the foundational skill that separates competent from expert parallel programmers.

latency hidingprefetching parallelcomputation communication overlappipelining latencydouble buffering

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.