Home Knowledge Base CUDA Streams

CUDA Streams are queues of GPU operations that execute in order within the stream but potentially overlap with operations in other streams — enabling concurrent execution of kernels, memory transfers, and other GPU operations to maximize GPU utilization.

Default Stream Behavior

Creating and Using Streams

cudaStream_t stream1, stream2;
cudaStreamCreate(&stream1);
cudaStreamCreate(&stream2);

// Launch kernel on stream1
my_kernel<<<grid, block, 0, stream1>>>(...);

// Transfer data on stream2 concurrently
cudaMemcpyAsync(dst, src, size, cudaMemcpyHostToDevice, stream2);

// Wait for both streams
cudaStreamSynchronize(stream1);
cudaStreamSynchronize(stream2);

cudaStreamDestroy(stream1);
cudaStreamDestroy(stream2);

Overlap Patterns

Transfer-Compute Overlap:

Kernel-Kernel Overlap:

CUDA Events for Timing and Synchronization

cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventRecord(start, stream1);    // Mark start in stream1
// ... kernel ...
cudaEventRecord(stop, stream1);
cudaEventSynchronize(stop);
float ms;
cudaEventElapsedTime(&ms, start, stop);

Stream Dependencies

CUDA Graphs (2019+)

CUDA streams are the key to achieving high GPU utilization in production inference pipelines — overlapping data transfer with compute through multi-stream design can recover 20–40% performance that single-stream sequential execution leaves unused.

cuda streamsasync cudastream synchronizationmulti-streamcuda concurrent execution

Explore 500+ Semiconductor & AI Topics

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