gpucoder.atomicExch
Description
The gpucoder.atomicExch function reads from a global or shared GPU
memory location, then writes a value into 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.atomicExch(
atomically writes the value from A,B)B into the shared or global GPU memory
location, A.
Call
the gpucoder.atomicExch 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.atomicExch.