From 14b149ac0f1fcc085cb492a2cbcfebc26ca6f516 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:22:20 -0500 Subject: [PATCH] Use offsetalator in cudf::row_bit_count() (#15003) Updates `cudf::row_bit_count()` to use the offsetalator to compute chars size for a strings column. Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Bradley Dice (https://github.com/bdice) - Nghia Truong (https://github.com/ttnghia) URL: https://github.com/rapidsai/cudf/pull/15003 --- cpp/src/transform/row_bit_count.cu | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpp/src/transform/row_bit_count.cu b/cpp/src/transform/row_bit_count.cu index a91dc8fbbc6..e4698fb1262 100644 --- a/cpp/src/transform/row_bit_count.cu +++ b/cpp/src/transform/row_bit_count.cu @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -352,11 +353,12 @@ __device__ size_type row_size_functor::operator()(column_device_vie return 0; } - auto const offsets_size = sizeof(size_type) * CHAR_BIT; + auto const offsets_size = + (offsets.type().id() == type_id::INT32 ? sizeof(int32_t) : sizeof(int64_t)) * CHAR_BIT; auto const validity_size = col.nullable() ? 1 : 0; - auto const chars_size = - (offsets.data()[row_end] - offsets.data()[row_start]) * CHAR_BIT; - return ((offsets_size + validity_size) * num_rows) + chars_size; + auto const d_offsets = cudf::detail::input_offsetalator(offsets.head(), offsets.type()); + auto const chars_size = (d_offsets[row_end] - d_offsets[row_start]) * CHAR_BIT; + return static_cast(((offsets_size + validity_size) * num_rows) + chars_size); } /**