atomicAdd() problem...

Hi everyone,

I have a problem with atomicAdd(). A have an array named “odata” in global memory and arrays named “sdata” in shared memory for each block. I tried to progress the following code, but some results are not true. I have (64,1) blocks.

if( blockIdx.x%4 == 3 )
atomicAdd(&odata[399+tid], sdata[tid]);

But I change the code as the following, the results are true.

if( blockIdx.x%4 == 3 )
atomicAdd(&odata[tid], sdata[tid]);

Is there anyone to know why? How can I run atomicAdd(&odata[399+tid], sdata[tid])? Thanks…