Atomics beginner question

Hi there,

I have a piece of serial code which does s.th like this

if( ! variable )
{
do some initialization here 
variable = true;
}

I understand that this works perfectly fine in serial and will only be executed once. What atomics operation would be the correct one here in Cuda ??

thanks in advance

Atomic Exchange.