Skip to content
6 changes: 2 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -943,18 +943,16 @@ add_library(
src/reductions/segmented/nunique.cu
src/reductions/segmented/product.cu
src/reductions/segmented/reductions.cpp
src/reductions/segmented/std.cu
src/reductions/segmented/std_var.cu
src/reductions/segmented/sum.cu
src/reductions/segmented/sum_of_squares.cu
src/reductions/segmented/update_validity.cu
src/reductions/segmented/var.cu
src/reductions/std.cu
src/reductions/std_var.cu
src/reductions/sum.cu
src/reductions/sum_of_squares.cu
src/reductions/sum_overflow.cu
src/reductions/unique_count.cu
src/reductions/unique_count_column.cu
Comment thread
vyasr marked this conversation as resolved.
src/reductions/var.cu
src/replace/clamp.cu
src/replace/nans.cu
src/replace/nulls.cu
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/strings/detail/copy_if_else.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ std::unique_ptr<cudf::column> copy_if_else(StringIterLeft lhs_begin,
});

// convert vector into strings column
auto result = make_strings_column(indices.begin(), indices.end(), stream, mr);
auto result = cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
result->set_null_mask(std::move(null_mask), null_count);
return result;
}
Expand Down
20 changes: 18 additions & 2 deletions cpp/include/cudf/strings/detail/strings_children.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/memory_resource.hpp>
#include <cudf/utilities/prefetch.hpp>
#include <cudf/utilities/span.hpp>

#include <rmm/exec_policy.hpp>

Expand All @@ -31,6 +32,21 @@ namespace cudf {
namespace strings {
namespace detail {

/**
* @brief Create an offsets column from already-materialized string sizes.
*
* This overload centralizes the common size_type input case so callers do not each
* instantiate the same CUB scan kernels.
*
* @param sizes The per-string byte sizes
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return Offsets column and total bytes
* @throw std::overflow_error if the output exceeds the column size limit
*/
std::pair<std::unique_ptr<column>, int64_t> make_offsets_child_column(
device_span<size_type const> sizes, cuda::stream_ref stream, rmm::device_async_resource_ref mr);

Comment thread
vyasr marked this conversation as resolved.
Comment thread
vyasr marked this conversation as resolved.
template <typename Iter>
struct string_offsets_fn {
Iter _begin;
Expand Down Expand Up @@ -242,8 +258,8 @@ auto make_strings_children(SizeAndExecuteFunction size_and_exec_fn,
for_each_fn(size_and_exec_fn);

// Convert the sizes to offsets
auto [offsets_column, bytes] = cudf::strings::detail::make_offsets_child_column(
output_sizes.begin(), output_sizes.end(), stream, mr);
auto [offsets_column, bytes] =
cudf::strings::detail::make_offsets_child_column(output_sizes, stream, mr);
size_and_exec_fn.d_offsets =
cudf::detail::offsetalator_factory::make_input_iterator(offsets_column->view());

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/column/column_factories.cu
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ std::unique_ptr<cudf::column> column_from_scalar_dispatch::operator()<cudf::stri
indices.begin(),
indices.end(),
row_value);
return cudf::strings::detail::make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
}

template <>
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/interop/from_arrow_device.cu
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ dispatch_tuple_t dispatch_from_arrow_device::operator()<cudf::string_view>(
d_indices.begin(),
binary_view_to_string_index_pair{d_items, d_ptrs, d_mask, skip_mask});
// gather strings into output column
auto out_col =
cudf::strings::detail::make_strings_column(d_indices.begin(), d_indices.end(), stream, mr);
auto out_col = cudf::make_strings_column(d_indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
owned.emplace_back(std::move(out_col));
return std::make_tuple<column_view, owned_columns_t>(owned.front()->view(), std::move(owned));
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/interop/from_arrow_host_strings.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -113,7 +113,7 @@ std::unique_ptr<column> from_arrow_stringview(ArrowSchemaView const* schema,
return {data, size};
});

return cudf::strings::detail::make_strings_column(d_indices.begin(), d_indices.end(), stream, mr);
return cudf::make_strings_column(d_indices, stream, mr);
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/parquet/experimental/variant_extract.cu
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ std::unique_ptr<column> get_variant_field(column_view const& variant_column,

// Convert sizes to offsets
auto [offsets_column, total_bytes] =
cudf::strings::detail::make_offsets_child_column(d_sizes.begin(), d_sizes.end(), stream, mr);
cudf::strings::detail::make_offsets_child_column(d_sizes, stream, mr);
CUDF_EXPECTS(total_bytes <= std::numeric_limits<size_type>::max(),
"VARIANT extracted bytes exceed cudf size_type limit",
std::overflow_error);
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/io/utilities/data_casting.cu
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,8 @@ static std::unique_ptr<column> parse_string(string_view_pair_it str_tuples,
CUDF_CUDA_TRY(cudaGetLastError());
}

auto [offsets, bytes] =
cudf::strings::detail::make_offsets_child_column(sizes.begin(), sizes.end(), stream, mr);
auto d_offsets = cudf::detail::offsetalator_factory::make_input_iterator(offsets->view());
auto [offsets, bytes] = cudf::strings::detail::make_offsets_child_column(sizes, stream, mr);
auto d_offsets = cudf::detail::offsetalator_factory::make_input_iterator(offsets->view());

// CHARS column
rmm::device_uvector<char> chars(bytes, stream, mr);
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/json/json_path.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand Down Expand Up @@ -1018,8 +1018,7 @@ std::unique_ptr<cudf::column> get_json_object(cudf::strings_column_view const& c
CUDF_CUDA_TRY(cudaGetLastError());

// convert sizes to offsets
auto [offsets, output_size] =
cudf::strings::detail::make_offsets_child_column(sizes.begin(), sizes.end(), stream, mr);
auto [offsets, output_size] = cudf::strings::detail::make_offsets_child_column(sizes, stream, mr);
d_offsets = cudf::detail::offsetalator_factory::make_input_iterator(offsets->view());

// allocate output string column
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/lists/interleave_columns.cu
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ struct interleave_list_entries_impl<T, std::enable_if_t<std::is_same_v<T, cudf::
cuda::counting_iterator<size_type>{0},
num_output_lists,
comp_fn);
return cudf::strings::detail::make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
}
};

Expand Down
Comment thread
vyasr marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ namespace cudf {
namespace reduction {
namespace detail {

// segmented_variance is intentionally co-located with segmented_standard_deviation in this
// translation unit. Both reductions use the same var_std intermediate and segmented CUB reduction
// shape; keeping them together avoids emitting duplicate device kernel instantiations.
std::unique_ptr<cudf::column> segmented_standard_deviation(column_view const& col,
device_span<size_type const> offsets,
cudf::data_type const output_dtype,
Expand All @@ -27,6 +30,19 @@ std::unique_ptr<cudf::column> segmented_standard_deviation(column_view const& co
col.type(), reducer(), col, offsets, output_dtype, null_handling, ddof, stream, mr);
}

std::unique_ptr<cudf::column> segmented_variance(column_view const& col,
device_span<size_type const> offsets,
cudf::data_type const output_dtype,
null_policy null_handling,
size_type ddof,
cuda::stream_ref stream,
rmm::device_async_resource_ref mr)
{
using reducer = compound::detail::compound_segmented_dispatcher<op::variance>;
return cudf::type_dispatcher(
col.type(), reducer(), col, offsets, output_dtype, null_handling, ddof, stream, mr);
}

} // namespace detail
} // namespace reduction
} // namespace cudf
31 changes: 0 additions & 31 deletions cpp/src/reductions/segmented/var.cu

This file was deleted.

15 changes: 15 additions & 0 deletions cpp/src/reductions/std.cu → cpp/src/reductions/std_var.cu
Comment thread
vyasr marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace cudf {
namespace reduction {
namespace detail {

// variance is intentionally co-located with standard_deviation in this translation unit. Both
// reductions use the same var_std intermediate and CUB reduction shape; keeping them together
// avoids emitting duplicate device kernel instantiations.
std::unique_ptr<cudf::scalar> standard_deviation(column_view const& col,
cudf::data_type const output_dtype,
size_type ddof,
Expand All @@ -27,6 +30,18 @@ std::unique_ptr<cudf::scalar> standard_deviation(column_view const& col,
return cudf::type_dispatcher(col_type, reducer(), col, output_dtype, ddof, stream, mr);
}

std::unique_ptr<cudf::scalar> variance(column_view const& col,
cudf::data_type const output_dtype,
size_type ddof,
cuda::stream_ref stream,
rmm::device_async_resource_ref mr)
{
using reducer = compound::detail::element_type_dispatcher<op::variance>;
auto col_type =
cudf::is_dictionary(col.type()) ? dictionary_column_view(col).keys().type() : col.type();
return cudf::type_dispatcher(col_type, reducer(), col, output_dtype, ddof, stream, mr);
}

} // namespace detail
} // namespace reduction
} // namespace cudf
32 changes: 0 additions & 32 deletions cpp/src/reductions/var.cu

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/src/replace/clamp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ std::unique_ptr<cudf::column> clamp_string_column(strings_column_view const& inp
indices.begin(),
fn);

return cudf::strings::detail::make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
}

template <typename T, typename OptionalIterator, typename ReplaceIterator>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/reshape/interleave_columns.cu
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ struct interleave_columns_impl<T, std::enable_if_t<std::is_same_v<T, cudf::strin
indices.begin(),
interleave_strings_fn{*d_table});

return cudf::strings::detail::make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
}
};

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/case.cu
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ std::unique_ptr<column> convert_case(strings_column_view const& input,
ccfn, *d_strings, sizes.data());
CUDF_CUDA_TRY(cudaGetLastError());
// convert sizes to offsets
return cudf::strings::detail::make_offsets_child_column(sizes.begin(), sizes.end(), stream, mr);
return cudf::strings::detail::make_offsets_child_column(sizes, stream, mr);
}();

// build sub-offsets
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/extract/extract.cu
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ std::unique_ptr<column> extract_single(strings_column_view const& input,
launch_transform_kernel(
extract_single_fn{*d_strings, group}, *d_prog, indices.data(), input.size(), stream);

return make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.
}

} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/extract/extract_all.cu
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ std::unique_ptr<column> extract_all_record(strings_column_view const& input,
launch_for_each_kernel(
extract_fn{*d_strings, d_offsets, indices.data()}, *d_prog, strings_count, stream);

auto strings_output = make_strings_column(indices.begin(), indices.end(), stream, mr);
auto strings_output = cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.

// Build the lists column from the offsets and the strings.
return make_lists_column(
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/filling/fill.cu
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ std::unique_ptr<column> fill(strings_column_view const& input,
indices.begin(),
fn);

return make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
}

} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/merge/merge.cu
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::unique_ptr<column> merge(strings_column_view const& lhs,
});

// convert vector into strings column
return make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
}

} // namespace detail
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/strings/positions.cu
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ std::unique_ptr<column> create_offsets_from_positions(strings_column_view const&
});

// finally, convert the counts into offsets
return std::get<0>(
cudf::strings::detail::make_offsets_child_column(counts.begin(), counts.end(), stream, mr));
return std::get<0>(cudf::strings::detail::make_offsets_child_column(counts, stream, mr));
}

} // namespace cudf::strings::detail
2 changes: 1 addition & 1 deletion cpp/src/strings/replace/find_replace.cu
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ std::unique_ptr<cudf::column> find_and_replace_all(
indices.begin(),
find_replace_fn{*d_input, *d_values_to_replace, *d_replacements});

return make_strings_column(indices.begin(), indices.end(), stream, mr);
return cudf::make_strings_column(indices, stream, mr);
}

} // namespace detail
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/strings/replace/multi.cu
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,11 @@ std::unique_ptr<column> replace_character_parallel(strings_column_view const& in
});

// use this utility to gather the string parts into a contiguous chars column
auto chars = make_strings_column(indices.begin(), indices.end(), stream, mr);
auto chars = cudf::make_strings_column(indices, stream, mr);
auto chars_data = chars->release().data;

// create offsets from the sizes
offsets = std::get<0>(
cudf::strings::detail::make_offsets_child_column(counts.begin(), counts.end(), stream, mr));
offsets = std::get<0>(cudf::strings::detail::make_offsets_child_column(counts, stream, mr));

// build the strings columns from the chars and offsets
return make_strings_column(strings_count,
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/strings/replace/replace.cu
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,11 @@ std::unique_ptr<column> replace_character_parallel(strings_column_view const& in
});

// use this utility to gather the string parts into a contiguous chars column
auto chars = make_strings_column(indices.begin(), indices.end(), stream, mr);
auto chars = cudf::make_strings_column(indices, stream, mr);
auto chars_data = chars->release().data;

// create offsets from the sizes
offsets = std::get<0>(
cudf::strings::detail::make_offsets_child_column(counts.begin(), counts.end(), stream, mr));
offsets = std::get<0>(cudf::strings::detail::make_offsets_child_column(counts, stream, mr));

// build the strings columns from the chars and offsets
return make_strings_column(strings_count,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/strings/search/findall.cu
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ std::unique_ptr<column> findall(strings_column_view const& input,
});
}();

auto strings_output = make_strings_column(indices.begin(), indices.end(), stream, mr);
auto strings_output = cudf::make_strings_column(indices, stream, mr);
Comment thread
vyasr marked this conversation as resolved.

// Build the lists column from the offsets and the strings
return make_lists_column(input.size(),
Expand Down
Loading
Loading