Integer Compare And Swap In Openacc

Hi Dear
I have a problem with this code
This is my code

/*#pragma acc data region copyin(i , intlocalResult[0:Nsize], boolFlags[0:Nsize] ) , copy( intEndResult[0:Nsize]) ,  present_or_copyin( offset[0:Nsize+1]  ,  node[0:Msize] , weightArray[0:Msize])/*
#pragma acc  kernels
{
#pragma acc for independent
for ( int index = 0; index < Nsize; index++ )
{
if ( boolFlags[index] )
{
	boolFlags[index] = false;
#pragma acc for independent
	for (i = offset[index]; i <offset[index + 1]; i++)
	{
		if (intlocalResult[node[i]] > intEndResult[index] + weightArray[i])
			intlocalResult[node[i]] = intEndResult[index] + weightArray[i];
		
	}
}/*End Kernel1*/

//... Other Kernels
#pragma acc for independent
fo()
{
}

I need an int CAS for this piece of My code , But i don’t know how to implement it’s efficient or I don’t know how use compare and swap in openacc or c++ ?
Or i don’t know witch c or c++ library can help me

if (intlocalResult[node[i]] > intEndResult[index] + weightArray[i])
			intlocalResult[node[i]] = intEndResult[index] + weightArray[i];

Please Help me?

I Google it but i could not found Solution.

I have another Question , If i use Compare and swap , so this for is serial? and have bad effort on my run time?
What is best way to handle this situation?

Duplicate. Please see: Integer Compare And Swap In Openacc