                 maxval[0] = (T)smaxval[0];
                 minloc[0] = sminloc[0];
                 maxloc[0] = smaxloc[0];
+                blocks_finished = 0;
             }
 		}
 #else

        {
            minval[0] = (T)sminval[0];
            maxval[0] = (T)smaxval[0];
        }
    }


        scount[tid] = tid < size ? count[tid] : 0;
		sum_is_smem<nthreads, unsigned int>(scount, tid);

		if (tid == 0) 
        {
            count[0] = scount[0];
            blocks_finished = 0;
        }
    }


