What Is GPU Global Memory? Understand CUDA Data Lifetime and Access Efficiency
GPU global memory is the device-side address space that every thread in a CUDA kernel can access. It stores large inputs and results and lets data pass between kernels, but the word “global” does not mean that the CPU and GPU automatically share the same physical memory. On a discrete GPU, host and device memory are usually separate, and both data transfers and thread address patterns affect performance.
What Is GPU Global Memory? Understand CUDA Data Lifetime and Access Efficiency
GPU global memory is the device-side address space that every thread in a CUDA kernel can access. It stores large inputs and results and lets data pass between kernels, but the word “global” does not mean that the CPU and GPU automatically share the same physical memory. On a discrete GPU, host and device memory are usually separate, and both data transfers and thread address patterns affect performance.
What is global memory, and who can share it?
In CUDA, global memory is an address space in device memory. Every thread in a kernel grid can access it, so it is used for large inputs and outputs and for data that multiple threads must read or write. A CUDA allocation remains available until it is freed or the application ends. A cache may serve some requests to these addresses, but an L2 cache neither replaces a global-memory allocation nor manages its lifetime. Conflicting concurrent writes still require correct synchronization and memory-order rules. CUDA Programming Guide — Writing SIMT Kernels
| Memory | Main access scope | Lifetime and purpose |
|---|---|---|
| Host memory | CPU code | Holds data prepared by the CPU and results returned to it. On a discrete GPU it may be separate from device global memory. |
| Device global memory | All threads in GPU kernels | Holds large inputs, outputs, and data passed between kernels. A CUDA allocation lasts until it is freed or the app exits. |
Managed memory (cudaMallocManaged) | CPU and GPU on supported systems | A CUDA allocation accessible to both processors. Physical location and migration depend on system support; it does not mean the data is always fixed in one place. |
| L2 cache | Hardware serving some memory requests | It is not an array that you allocate and manage for its lifetime. A cache hit or continued residency is not guaranteed. |
The following is a typical data path on a discrete GPU. Integrated GPUs, managed memory, and special sharing features can use a different physical path.
Input in CPU host memory
│ cudaMemcpy: Host → Device
▼
Global-memory allocation in GPU device memory
│ kernel threads read it and write computed results
▼
Result in GPU device memory
│ cudaMemcpy: Device → Host
▼
CPU reads the result from host memoryHow does data travel from the host through a kernel and back?
Consider vector addition. The CPU prepares two input arrays, the CUDA runtime allocates device memory, and the inputs are copied to the GPU. A kernel computes each element and writes to an output array. After the kernel finishes, the result is copied back to the host, checked, and the device allocations are freed. NVIDIA’s CUDA examples use this global-memory lifecycle with cudaMalloc, cudaMemcpy, a kernel launch, a result copy, and cudaFree. CUDA Programming Guide — Programming Model
Keep two boundaries clear. First, CPU pointers and GPU device pointers generally cannot be used interchangeably. Second, if a kernel reads an input or the CPU reads a result before the relevant copy has completed, the required ordering may be missing. Synchronous cudaMemcpy and a stream-associated asynchronous copy have different completion behavior, so wait according to the API and stream you use. cudaMemcpyAsync is asynchronous with respect to the host and may return before the copy completes; use stream ordering and synchronization to determine when the data is safe to use. CUDA Runtime API — cudaMemcpyAsync cudaMallocManaged provides an allocation accessible to CPU and GPU, but it does not guarantee that host-device movement has no cost or that performance is always the same. CUDA Programming Guide — heterogeneous systems and memory
When evaluating application performance, include transfer time if transfers are part of the application path. If input is already on the GPU and reused by several kernels, transfer cost may be a small share. If each call sends a small input and returns a result, transfers may account for a substantial share of total time. Measure the actual call boundary and data reuse rather than assuming either case.
How can thread addresses change memory efficiency?
CUDA tries to combine memory requests from a warp into as few transactions as possible. This is called coalescing. When neighboring threads usually read neighboring elements, requested bytes can be served by fewer transactions. If warp threads request far-apart addresses, some of the transferred data may go unused. Exact transaction rules depend on compute capability and access conditions, so a particular byte count should not be treated as a rule for every GPU. CUDA C++ Best Practices Guide — coalesced global-memory accesses
| Example accesses within one warp | Request pattern | What to examine first |
|---|---|---|
Thread i reads A[i] and writes C[i] | Neighboring threads access neighboring elements | This is a typical coalesced pattern for vector addition. Also check cases where boundary threads are inactive. |
Thread i reads A[i × stride] | Address spacing between threads may grow | Check stride, the actual data layout, and the number of transactions requested by the warp. |
A warp reads only field x from an array of structures | Each thread may read a field separated by the structure size | If one field is processed frequently, compare separate arrays such as x[], y[], and z[]. If all fields are usually used together, an array of structures may fit better. |
Assumption-based example: Suppose particle positions are stored as an array of {x, y, z} structures, and one kernel computes only x for every particle. Neighboring threads may then read x values separated by the structure size. Separate x, y, and z arrays place the x values next to one another for that kernel. However, the split may not help when other kernels always read all three coordinates together or the conversion cost is high. This is a layout example, not a performance measurement on a particular GPU.
How can you identify a global-memory bottleneck in a kernel?
Nsight Compute’s Memory Workload Analysis examines GPU memory resources and data movement. NVIDIA’s guides explain that comparing requested and actual throughput can help estimate bandwidth wasted by inefficiently coalesced accesses. Report fields and metric names can differ by GPU and tool version. Do not conclude that global memory is the bottleneck just because traffic is high; also examine kernel time, memory throughput, and compute utilization. Nsight Compute Profiling Guide
Draw where inputs and outputs reside, and when each CPU↔GPU copy happens.
Write down the index expression for each thread; check the spacing and alignment of addresses requested by one warp instruction.
Measure the actual bottleneck first. Compare memory throughput and requested versus actual traffic in the profiler, alongside memory analysis and compute utilization.
Change one factor at a time, such as index mapping or array layout. Check that results remain correct at every input boundary.
With the same input and execution conditions, compare kernel time and application time including copies. Revert a change if its benefit is not repeatable or another call becomes slower.
Coalescing is an important way to use global-memory bandwidth efficiently, but it is not the only factor that determines performance. Cache reuse, work per instruction, instruction issue, memory dependencies, and host-device transfers can all affect total time. After a change, confirm that it helps the path you measured.
Sources
[NVIDIA CUDA Programming Guide — Writing SIMT Kernels](https://docs.nvidia.com/cuda/cuda-programming-guide/02-basics/writing-cuda-kernels.html)
[NVIDIA CUDA Programming Guide — Programming Model](https://docs.nvidia.com/cuda/cuda-programming-guide/01-introduction/programming-model.html)
[NVIDIA CUDA C++ Best Practices Guide](https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html)
[NVIDIA Nsight Compute — Profiling Guide](https://docs.nvidia.com/nsight-compute/ProfilingGuide/index.html)
[NVIDIA CUDA Runtime API — Memory Management](https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html)