Atomics Application Binary Interface
The mappings of programming languages’ atomic operations to the PTX ISA need to be implemented in a consistent manner across all programming languages that may concurrently access shared memory. The mapping from C++11 atomics for the CUDA architecture are proven correct in A Formal Analysis of the NVIDIA PTX Memory Consistency Model. The PTX ISA provides atomic memory operations and fences for acquire, release, acquire-release, and relaxed C++ memory ordering semantics.
Note
The memory order parameter is monotonic, and so it is valid to strengthen any such parameter. For example, it is valid to
strengthen fence.sc.<scope>; ld.relaxed.<scope>;
to fence.sc.<scope>; ld.acquire.<scope>;
for sequentially consistent
loads. The same applies for all mappings below.
Note
Where there is a choice of PTX ABI ISA mapping for a given C, C++, or CUDA C++ API it is acceptable to pick either and to mix mappings within the same binary.
The PTX ABI for C++ sequentially consistent atomic operations is the following:
C or C++ or CUDA C++ API |
PTX ABI ISA mapping |
---|---|
|
|
|
fence.sc.<scope>; ld.acquire.<scope>; (recommended) ORfence.sc.<scope>; ld.relaxed.<scope>; fence.acquire.<scope>; |
|
|
|
fence.sc.<scope>; atom.acquire.<scope>.<rmw op>; (recommended) ORfence.sc.<scope>; atom.relaxed.<scope>.<rmw op>; fence.acquire.<scope>; |
The PTX ABI for C++ release atomic operations is the following:
C or C++ or CUDA C++ API |
PTX ABI ISA mapping |
---|---|
|
|
|
st.release.<scope>; (recommended) ORfence.release.<scope>; st.relaxed.<scope>; |
|
atom.release.<scope>.<rmw op>; (recommended) ORfence.release.<scope>; atom.relaxed.<scope>.<rmw op>; |
The PTX ABI for C++ acquire atomic operations is the following:
C or C++ or CUDA C++ API |
PTX ABI ISA mapping |
---|---|
|
|
|
ld.acquire.<scope>; (recommended) ORld.relaxed.<scope>; fence.acquire.<scope>; |
|
atom.acquire.<scope>.<rmw op>; (recommended) ORatom.relaxed.<scope>.<rmw op>; fence.acquire.<scope>; |
The PTX ABI for C++ acquire-release atomic operations is the following:
C or C++ or CUDA C++ API |
PTX ABI ISA mapping |
---|---|
|
|
|
atom.acq_rel.<scope>.<rmw op>; (recommended) ORfence.release.<scope>; atom.acquire.<scope>.<rmw op>; ORfence.release.<scope>; atom.relaxed.<scope>.<rmw op>; fence.acquire.<scope>; |
The PTX ABI for C++ relaxed atomic operations is the following:
C or C++ or CUDA C++ API |
PTX ABI ISA mapping |
---|---|
|
|
|
|
|
|