From 15d036a417acb7b5c11d2a6d933eb20690e33285 Mon Sep 17 00:00:00 2001 From: Nghia Truong Date: Sun, 29 May 2022 06:19:16 -0700 Subject: [PATCH] Try to reverse `sort_helper.cu` Signed-off-by: Nghia Truong --- cpp/src/groupby/sort/sort_helper.cu | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cpp/src/groupby/sort/sort_helper.cu b/cpp/src/groupby/sort/sort_helper.cu index a0abaf71160..10201782854 100644 --- a/cpp/src/groupby/sort/sort_helper.cu +++ b/cpp/src/groupby/sort/sort_helper.cu @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -33,11 +32,17 @@ #include #include +#include #include #include +#include #include +#include #include +#include +#include #include +#include #include #include @@ -218,13 +223,22 @@ sort_groupby_helper::index_vector const& sort_groupby_helper::group_labels( _group_labels = std::make_unique(num_keys(stream), stream); auto& group_labels = *_group_labels; + if (num_keys(stream) == 0) return group_labels; - cudf::detail::label_segments(group_offsets(stream).begin(), - group_offsets(stream).end(), - group_labels.begin(), - group_labels.end(), - stream); + thrust::uninitialized_fill(rmm::exec_policy(stream), + group_labels.begin(), + group_labels.end(), + index_vector::value_type{0}); + thrust::scatter(rmm::exec_policy(stream), + thrust::make_constant_iterator(1, decltype(num_groups(stream))(1)), + thrust::make_constant_iterator(1, num_groups(stream)), + group_offsets(stream).begin() + 1, + group_labels.begin()); + + thrust::inclusive_scan( + rmm::exec_policy(stream), group_labels.begin(), group_labels.end(), group_labels.begin()); + return group_labels; }