atomic_inc (OpenCL) equivalent to atomicInc (CUDA)

Hi All,

Firstly, I’m a newby here , so hi to all:)
Secondly, I’m looking for the answer to the question concerning the difference between atomicInc in CUDA and atomic_inc in OpenCL.

The first one is two-parameter function: pointer to a table containing a number (old), second - is an integer value (val) which is compared with the old. Memory address ponited by a pointer and containing old is changed according to the following.

((old >= val) ? 0 : (old+1))

The second one just increases atomically the value at memory address pointed by function parameter.

How can I achieve CUDA functionality in OpenCL?

Below there’s a piece of kernel (pseudo) code I need to translate:

shared bool sum;

if (threadIdx.x == 0) {
int i = index;
int s= size;
int old = atomicInc(table+i,s-1);
sum = ( old == s - 1 );

Best regards,