atomic - OpenCL - atomic_cmpxchg -


what function do??. couldn't understand thing opencl specification!! code below snippet spmv code.

atomic_cmpxchg((__global int*)loc, *((int*)&old), *((int*)&sum)) != *((int*)&old) 

atomic_cmpxchg "atomic compare , exchange". implements atomic version of standard c99 ternary operation. code above implies atomic equivalent of following:

p = *loc; *loc = (p == *old) ? (*sum != *old) : p; 

with atomic_cmpxchg call returning p. operation atomic, means no other thread can read or write loc until transaction completed.


Comments