 
 	int index = threadIdx.x;
 	int offset = 1;
+
+	int n = blockIdx.x * blockDim.x + threadIdx.x;
+	if (n * 2 >= num) {
+		return;
+	}
 
 	// Copy input data to shared memory
 	temp[2 * index] = src[2 * index + (blockIdx.x * blockDim.x * 2)];

		return;
	}

	dst[index] = src0[(index + 1) * stride - 1] + src1[(index + 1) * stride - 1];

	if (index == 0) {
		dst[index] = 0;
	}
}


namespace idaten {
	void compact()
	{
		//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 c = aten::nextPow2(AT_COUNTOF(f));

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

		idaten::TypedCudaMemory<int> src;
		src.init(x.size());
		src.writeByNum(&x[0], x.size());

		idaten::TypedCudaMemory<int> dst;
		dst.init(x.size());

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

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

