I have the following code:

if (localID == 0) {

for (int i=0; i<49; i++) {
aux+=count[i];
atom_add(&cov[idy], aux);
}
}

The problem is that if I just want to save those sums on cov array (which is global), outside the kernel I can read the data and everything is fine. But, if I want to do this after:

*f = cov[0];

The values stored on cov array (on any of its positions) are not consistent yet, even if before this line I put a fence or barrier. In this case, shouldn't occur some sort of flushing on the atomic operations so the values on cov[] could be used?

Thanks