gpucoder.atomicInc
Atomically increment variable in global or shared memory within upper bound
Since R2021b
Description
The gpucoder.atomicInc function reads a value from a global or
shared GPU memory location, increments the value, and writes the result back to the memory
location. In generated GPU
code, the operation is atomic, which means that a GPU thread performs the
read-modify-write operation without interference from other threads.
A = gpucoder.atomicInc(
increments the value of A,B)A within the upper bound B. If
the value of A is greater than or equal to B, it is
reset to zero.
Call
the gpucoder.atomicInc function directly inside a for-loop that
you want to execute on the GPU in the generated CUDA® code. Each iteration of the loop must be able to read and write to
A.
Use the
coder.gpu.kernel pragma before the loop that contains
gpucoder.atomicInc.
Examples
Input Arguments
Extended Capabilities
Version History
Introduced in R2021b