In this article
The double-buffer overload can modify both allocations and updates which buffer holds the result; the original input pointer is not a reliable output contract.
Identify which overload owns the output decision
The rocPRIM sort reference distinguishes ordinary input/output iterators from double-buffer overloads. In the latter, the current buffer supplies input and the operation updates which allocation contains the output. An application that keeps reading its original pointer can observe stale or intermediate data despite a successful sort call. Preserve the overload contract when replacing a separate-output implementation with a double-buffer optimization.
Read the selector rather than assuming pass parity
The double-buffer utility reference exposes current and alternate buffer access. Use the current result after execution has been submitted successfully, while retaining the required stream dependency before a consumer reads device values. Do not predict the chosen allocation from an assumed number of radix passes. Algorithm configuration and implementation changes can make that prediction fragile even when the mathematical sorting order remains unchanged.
Keep both data allocations alive
The sort documentation permits modification of both buffers. Treat the alternate allocation as active algorithm storage, not as an untouched backup of the original input. Retain both regions until dependent work completes, and keep separate temporary-storage requirements distinct from the full data buffers. A buffer-pool optimization that reassigns the alternate region too early can corrupt a sort without changing the visible current pointer in host bookkeeping.
Preserve paired values with their keys
The radix-sort source includes paired-key/value double-buffer paths. Read the updated selectors for the corresponding outputs instead of combining sorted keys from one result with values from an old allocation. For diagnosis, attach a recognizable identity to each input key and verify associations after sorting, including repeated keys. Sorted key order alone cannot establish that attached records followed their intended permutation.
Make any fixed-output copy explicit
If a downstream interface requires a permanent output address, add a necessary copy from the selected current buffer or use a suitable separate-output overload. Include that work in the end-to-end comparison. The existing stream-dependency guide and software reproducibility guide support related context. A correct optimization records buffer selection and ownership rather than exposing an accidental pointer convention that depends on one observed implementation run.
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.