         vertex_out,
         v_out_offset,
         far_pile_offset,
+        node_num);
+}
+
+template<typename KernelPolicy, typename ProblemData, typename PriorityQueue, typename Functor>
+__launch_bounds__ (KernelPolicy::THREADS, KernelPolicy::BLOCKS)
+    __global__
+void Compact2(
+        typename KernelPolicy::VertexId     *vertex_in,
+        typename PriorityQueue::NearFarPile *pq,
+        int                                 selector,
+        typename KernelPolicy::SizeT        input_queue_length,
+        typename KernelPolicy::VertexId     *vertex_out,
+        typename KernelPolicy::SizeT        v_out_offset,
+        typename KernelPolicy::SizeT        node_num)
+{
+    Dispatch<KernelPolicy, ProblemData, PriorityQueue, Functor>::Compact2(
+        vertex_in,
+        pq,
+        selector,
+        input_queue_length,
+        vertex_out,
+        v_out_offset,
         node_num);
 }
 

        //printf("valid near, far: %d, %d\n", pq->d_valid_near[my_id], pq->d_valid_far[my_id]);
    }

    static __device__ __forceinline__ void Compact(
                                            VertexId        *&vertex_in,
                                            NearFarPile     *&pq,

            node_num);
}

template<typename KernelPolicy, typename ProblemData, typename PriorityQueue, typename Functor>
__launch_bounds__ (KernelPolicy::THREADS, KernelPolicy::BLOCKS)
    __global__
void MarkValid(
        typename KernelPolicy::VertexId     *vertex_in,
        typename PriorityQueue::NearFarPile *pq,
        typename ProblemData::DataSlice     *problem,
        typename KernelPolicy::SizeT        input_queue_length,
        typename KernelPolicy::SizeT        node_num)
{
    Dispatch<KernelPolicy, ProblemData, PriorityQueue, Functor>::MarkValid(
            vertex_in,
            pq,
            problem,
            input_queue_length,
            node_num);
}

/**
 * @brief Compact the input queue into near far pile, remove the duplicate IDs,
 * append the newly generated far pile at the end of current priority queue
