Description
The following operations perform arithmetic and bitwise computations. All of these operations are applicable to an object of any atomic integer type. The key, operator, and computation correspondence is given in table below:
key 
op 
computation 

+ 
addition 

 
subtraction 

 
bitwise inclusive or 

^ 
bitwise exclusive or 

& 
bitwise and 

min 
compute min 

max 
compute max 
For atomic_fetch and modify functions with key = 
C atomic_fetch_key(volatile A *object, M operand)
C atomic_fetch_key_explicit(volatile A *object,
M operand,
memory_order order)
C atomic_fetch_key_explicit(volatile A *object,
M operand,
memory_order order,
memory_scope scope)
Atomically replaces the value pointed to by object with the result of the
computation applied to the value pointed to by object
and the given
operand.
Memory is affected according to the value of order
.
These operations are atomic readmodifywrite operations (as defined by
section 5.1.2.4 of the C11 Specification).
For signed integer types, arithmetic is defined to use two’s complement
representation with silent wraparound on overflow; there are no undefined
results.
For address types, the result may be an undefined address, but the
operations otherwise have no undefined behavior.
Returns atomically the value pointed to by object
immediately before the
effects.
See Also
Document Notes
For more information, see the OpenCL C Specification
This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.
Copyright
Copyright (c) 20142020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.