Fix rare race conditions in scan kernels.
Fix rare race conditions in scan kernels.

diku-dk/futhark,ihc/futhark,diku-dk/futhark,ihc/futhark,diku-dk/futhark,HIPERFIT/futhark,diku-dk/futhark,diku-dk/futhark,ihc/futhark,HIPERFIT/futhark,HIPERFIT/futhark