 	int index = threadIdx.x;
 	int offset = 1;
 
+	auto 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)];
 	temp[2 * index + 1] = src[2 * index + 1 + (blockIdx.x * blockDim.x * 2)];

		dst.init(x.size());

		scan(src, dst);
	}
}


// NOTE
// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch39.html
// https://github.com/bcrusco/CUDA-Path-Tracer/blob/master/stream_compaction/efficient.cu

// ubNPʂŌvZ exclusiveScan ̑al𑫂̂vZ.
__global__ void computeBlockCount(
