 
 	// Clear the root
 	if (index == 0) {
-		temp[num - 1] = 0;
+		temp[stride - 1] = 0;
 	}
 
 	// Down sweep
-	for (int d = 1; d < num; d *= 2) {
+	for (int d = 1; d < stride; d *= 2) {
 		offset >>= 1;
 		__syncthreads();
 

		int blocksize = 8;
		int blockPerGrid = (x.size() - 1) / blocksize + 1;

		exclusiveScan<<<blockPerGrid, blocksize / 2, blocksize  * sizeof(int)>>>(src.ptr(), src.maxNum(), dst.ptr());

		std::vector<int> tmp(src.maxNum());
		dst.readByNum(&tmp[0], tmp.size());

	{
		//int f[] = { 3, 1, 7, 0, 4, 1, 6, 3, 3, 1, 7, 0, 4, 1, 6, 3 };
		int f[] = { 3, 1, 7, 0, 4, 1, 6, 3, 3, 1 };
		//int f[] = { 3, 1, 7, 0, 4, 1, 6, 3 };

		//int c = aten::nextPow2(AT_COUNTOF(f));
		int c = AT_COUNTOF(f);

		std::vector<int> x(c);
		memcpy(&x[0], f, sizeof(int) * AT_COUNTOF(f));
