Home Knowledge Base Persistent Threads

Persistent Threads is a GPU programming pattern where a fixed number of threads remain alive for the entire program duration — repeatedly fetching work from a shared queue rather than being launched and terminated for each work item, reducing kernel launch overhead and enabling dynamic load balancing.

Traditional GPU Programming

Persistent Thread Pattern

__global__ void persistent_kernel(WorkQueue* queue) {
    // Launch exactly: num_SMs * warps_per_SM threads
    while (true) {
        WorkItem item;
        if (!queue->try_pop(&item)) break;  // Atomic dequeue
        process(item);                        // Variable-cost work
    }
}

// Launch once, process all work
persistent_kernel<<<num_SMs, WARPS_PER_SM * 32>>>(queue);

Work Queue Implementation

Benefits

Challenges

Use Cases

Persistent threads are a powerful pattern for irregular, dynamic GPU workloads — they trade the simplicity of fixed-size kernel launches for the flexibility needed by graph algorithms, simulation systems, and real-time streaming applications where work size and arrival time cannot be predicted at launch time.

persistent threads gpupersistent kernelwarp level programmingproducer consumer gpucircular buffer gpu

Explore 500+ Semiconductor & AI Topics

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