CPU, GPU AND RAM

GPU memory prefetch and advice: placement hints have different jobs

In this article
THE QUICK TAKE

Use advice to describe intended access and ordered prefetch to prepare a range; completion and ownership must still follow explicit dependencies.

Managed-memory advice and prefetch are different tools. Advice supplies information about intended access, while prefetch submits placement work with stream ordering. Neither replaces correct synchronization of application data. Understanding the distinction makes it possible to prepare an upcoming GPU phase without treating a preferred location as a permanent reservation or assuming that a submitted transfer has already finished.

A preference describes intent rather than certainty

A preferred-location hint helps the runtime understand where data is expected to be useful. It does not promise that every future access stays local or that competing processors cannot affect placement. The program must remain correct without the hint. This is a valuable test: remove advice and verify identical valid results. If correctness changes, the application is relying on an accidental placement effect instead of a required synchronization relationship.

Primary reference: CUDA Programming Guide: Unified Memory.

Prefetch belongs to a stream timeline

A prefetch operation is ordered with earlier and later operations in its stream. Placing it before a consuming kernel in that stream establishes a useful preparation sequence. A consumer in another stream needs an appropriate dependency if it must wait for that preparation. Calling prefetch from the host and immediately launching work elsewhere is not evidence that the range is already ready at the desired location.

Primary reference: CUDA C++ Best Practices Guide.

Prepare the range the next phase will touch

Suppose a large allocation contains several regions, but the next kernel touches only an active subset. Prefetching the entire allocation may move unnecessary data and compete with useful resident pages. Use the algorithm’s actual next-phase working set when possible. Include the preparation time in the phase budget. Moving a delay out of the kernel timer can improve that timer while leaving the application completion time unchanged.

Primary reference: CUDA Programming Guide: Writing SIMT Kernels.

Read-mostly data differs from alternating writes

A mostly read-only table used by several processors has different placement opportunities from a range repeatedly rewritten by both CPU and GPU. Advice should reflect that difference. Do not mark a range read-mostly merely because one particular kernel only reads it; consider the whole lifecycle. A later writer can invalidate the expected reuse pattern. Keep access-phase transitions explicit so performance experiments describe the real ownership sequence.

Measure placement as part of the workflow

Compare a demand-driven baseline, advice alone, and ordered prefetch using identical inputs and ownership transitions. Record both preparation duration and subsequent processing duration. A useful optimization reduces the combined critical path or enables meaningful overlap with independent work. Recheck platform support and memory-pressure conditions, because the same hint can have different effects across systems. The API expresses intent; measurements establish whether that intent helped the actual workload.

Related reading: A GPU inference benchmark you can trust; Reproducible inference stacks: preserving a GPU pilot’s result.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles