The check for mod64 has no real reason, other than trying to be extra safe ;)
The profiler counts too many global loads, for example:
gld_incoherent: 4511
gld_coherent: 179
gst_incoherent: 0
gst_coherent: 700
The storing seems to work fine… which confuses me a bit, since loading and storing both use the same mechanism.
128 threads per block did not work.
The first two lines also contain one global memory access, so I tried to make this access only once per threadBlock:
 // copy assignments
 __shared__ int* to;
 __shared__ int* from;
Â
 if(threadIdx.x==0){
    to  = (int*)(ASSIGNMENT(&assign_in,scan_result[blockIdx.x]));
    from = (int*)(ASSIGNMENT(&assign_out,blockIdx.x));
 }
Â
 __syncthreads();
Â
 for(int i=threadIdx.x; i<variables+1; i+=THREADS_PER_BLOCK)
to[i] = from[i];
But besides a compiler warning, nothing really changed.
(“Advisory: Cannot tell what pointer points to, assuming global memory space”)
*EDIT
I think I may have found the problem. Not quoted was another if(…) which also contained one global memory read. Using a shared value like above, this value is now only read once to a shared variable and global incoherent loads went down by a few thousand :)
But now I’d like to get rid of this compiler warning External Image