$sum = AtomicAdd
(<DeviceId>, "<$Variable>", <Value>)
the value of a variable in a particular device.
device where the variable is declared.
variable whose value is to be modified.
value to be incremented/decremented.
Returns an integer value.
- The function performs only integer addition/subtraction.
- While executing this statement, the system would
perform a Lock on the variable to prevent any
on its value.
$ret = AtomicAdd(1, "$Count", 5)
- if prior to addition $Count = 5, then after this both $Count and $ret will contain 10.
$ret = AtomicAdd(1, "$Count", -1)
- if $Count = 5, then after this operation, both $Count and $ret will contain 4.