diff --git a/cpp/include/cudf/copying.hpp b/cpp/include/cudf/copying.hpp index f1ab6e30f268..d5ed72451864 100644 --- a/cpp/include/cudf/copying.hpp +++ b/cpp/include/cudf/copying.hpp @@ -75,15 +75,14 @@ enum class negative_index_policy : bool { * better performance. If `policy` is set to `DONT_CHECK` and there are out-of-bounds indices * in the gather map, the behavior is undefined. Defaults to `DONT_CHECK`. * @param stream CUDA stream used for device memory operations and kernel launches - * @param mr Device memory resource used to allocate the returned table's device memory + * @param mr Memory resources used for temporary allocations and the returned table * @return Result of the gather */ -std::unique_ptr gather( - table_view const& source_table, - column_view const& gather_map, - out_of_bounds_policy bounds_policy = out_of_bounds_policy::DONT_CHECK, - cuda::stream_ref stream = cudf::get_default_stream(), - rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); +std::unique_ptr
gather(table_view const& source_table, + column_view const& gather_map, + out_of_bounds_policy bounds_policy = out_of_bounds_policy::DONT_CHECK, + cuda::stream_ref stream = cudf::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()); /** * @brief Gathers the specified rows of a set of columns according to a gather map. @@ -112,16 +111,15 @@ std::unique_ptr
gather( * @param bounds_policy Interpretation of out-of-bounds indices * @param neg_indices Interpretation of a negative index `i` in the `gather_map` * @param stream CUDA stream used for device memory operations and kernel launches. - * @param mr Device memory resource used to allocate the returned table's device memory + * @param mr Memory resources used for temporary allocations and the returned table * @return Result of the gather */ -std::unique_ptr
gather( - table_view const& source_table, - column_view const& gather_map, - out_of_bounds_policy bounds_policy, - negative_index_policy neg_indices, - cuda::stream_ref stream = cudf::get_default_stream(), - rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); +std::unique_ptr
gather(table_view const& source_table, + column_view const& gather_map, + out_of_bounds_policy bounds_policy, + negative_index_policy neg_indices, + cuda::stream_ref stream = cudf::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()); /** * @brief Reverses the rows within a table. diff --git a/cpp/include/cudf/detail/gather.cuh b/cpp/include/cudf/detail/gather.cuh index e5bb1f9ff575..eadab047378d 100644 --- a/cpp/include/cudf/detail/gather.cuh +++ b/cpp/include/cudf/detail/gather.cuh @@ -104,6 +104,7 @@ struct gather_bitmask_functor { * @param gather_map_end End of the gather map * @param nullify_out_of_bounds True if map values are checked against `source_size` * @param stream CUDA stream used for kernel launches. + * @param mr Memory resources used for temporary allocations */ template void gather_helper(InputItr source_itr, @@ -112,11 +113,13 @@ void gather_helper(InputItr source_itr, MapIterator gather_map_begin, MapIterator gather_map_end, bool nullify_out_of_bounds, - rmm::cuda_stream_view stream) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { - using map_type = typename std::iterator_traits::value_type; + auto const temp_mr = mr.get_temporary_mr(); + using map_type = typename std::iterator_traits::value_type; if (nullify_out_of_bounds) { - thrust::gather_if(rmm::exec_policy_nosync(stream, cudf::get_current_device_resource_ref()), + thrust::gather_if(rmm::exec_policy_nosync(stream, temp_mr), gather_map_begin, gather_map_end, gather_map_begin, @@ -124,7 +127,7 @@ void gather_helper(InputItr source_itr, target_itr, bounds_checker{0, source_size}); } else { - thrust::gather(rmm::exec_policy_nosync(stream, cudf::get_current_device_resource_ref()), + thrust::gather(rmm::exec_policy_nosync(stream, temp_mr), gather_map_begin, gather_map_end, source_itr, @@ -159,7 +162,7 @@ struct column_gatherer { * @param gather_map_end End of iterator range of integral values representing the gather map * @param nullify_out_of_bounds Nullify values in `gather_map` that are out of bounds * @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 + * @param mr Memory resources used for temporary allocations and the returned column */ template std::unique_ptr operator()(column_view const& source_column, @@ -167,7 +170,7 @@ struct column_gatherer { MapIterator gather_map_end, bool nullify_out_of_bounds, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { column_gatherer_impl gatherer{}; @@ -199,7 +202,7 @@ struct column_gatherer_impl std::unique_ptr operator()(column_view const& source_column, @@ -207,11 +210,12 @@ struct column_gatherer_impl(), source_column.size(), @@ -219,7 +223,8 @@ struct column_gatherer_impl { * @param gather_map_end End of iterator range of integral values representing the gather map * @param nullify_out_of_bounds Nullify values in `gather_map` that are out of bounds * @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 + * @param mr Memory resources used for temporary allocations and the returned column */ template std::unique_ptr operator()(column_view const& source_column, @@ -252,7 +257,7 @@ struct column_gatherer_impl { MapItType gather_map_end, bool nullify_out_of_bounds, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { if (true == nullify_out_of_bounds) { return cudf::strings::detail::gather( @@ -326,42 +331,48 @@ struct column_gatherer_impl { MapItRoot gather_map_end, bool nullify_out_of_bounds, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + lists_column_view list(column); auto gather_map_size = std::distance(gather_map_begin, gather_map_end); // if the gather map is empty, return an empty column if (gather_map_size == 0) { return empty_like(column); } + // List gather helpers still take a single resource ref on this branch; use the output + // resource until the dedicated list/segmented gather MR port lands. // generate gather_data for the next level (N+1) - lists::detail::gather_data gd = nullify_out_of_bounds - ? lists::detail::make_gather_data( - column, gather_map_begin, gather_map_size, stream, mr) - : lists::detail::make_gather_data( - column, gather_map_begin, gather_map_size, stream, mr); + lists::detail::gather_data gd = + nullify_out_of_bounds ? lists::detail::make_gather_data( + column, gather_map_begin, gather_map_size, stream, output_mr) + : lists::detail::make_gather_data( + column, gather_map_begin, gather_map_size, stream, output_mr); // the nesting case. if (list.child().type() == cudf::data_type{type_id::LIST}) { // gather children - auto child = lists::detail::gather_list_nested(list.get_sliced_child(stream), gd, stream, mr); + auto child = + lists::detail::gather_list_nested(list.get_sliced_child(stream), gd, stream, output_mr); // return the final column return make_lists_column(gather_map_size, std::move(gd.offsets), std::move(child), 0, - rmm::device_buffer{0, stream, mr}); + rmm::device_buffer{0, stream, output_mr}); } // it's a leaf. do a regular gather - auto child = lists::detail::gather_list_leaf(list.get_sliced_child(stream), gd, stream, mr); + auto child = + lists::detail::gather_list_leaf(list.get_sliced_child(stream), gd, stream, output_mr); // assemble final column return make_lists_column(gather_map_size, std::move(gd.offsets), std::move(child), 0, - rmm::device_buffer{0, stream, mr}); + rmm::device_buffer{0, stream, output_mr}); } }; @@ -380,7 +391,7 @@ struct column_gatherer_impl { * @param gather_map_end End of iterator range of integral values representing the gather map * @param nullify_out_of_bounds Nullify values in `gather_map` that are out of bounds * @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 + * @param mr Memory resources used for temporary allocations and the returned column * @return New dictionary column with gathered rows. */ template @@ -389,8 +400,10 @@ struct column_gatherer_impl { MapItType gather_map_end, bool nullify_out_of_bounds, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + dictionary_column_view dictionary(source_column); auto output_count = std::distance(gather_map_begin, gather_map_end); if (output_count == 0) return make_empty_column(type_id::DICTIONARY32); @@ -401,11 +414,11 @@ struct column_gatherer_impl { // be relatively smallish. // Also, there are scenarios where the keys are common with other dictionaries // and the original intention was to share the keys here. - auto keys_copy = std::make_unique(dictionary.keys(), stream, mr); + auto keys_copy = std::make_unique(dictionary.keys(), stream, output_mr); // Perform gather on just the indices column_view indices = dictionary.get_indices_annotated(); - auto new_indices = - cudf::allocate_like(indices, output_count, cudf::mask_allocation_policy::NEVER, stream, mr); + auto new_indices = cudf::allocate_like( + indices, output_count, cudf::mask_allocation_policy::NEVER, stream, output_mr); gather_helper( cudf::detail::indexalator_factory::make_input_iterator(indices), indices.size(), @@ -413,8 +426,9 @@ struct column_gatherer_impl { gather_map_begin, gather_map_end, nullify_out_of_bounds, - stream); - return make_dictionary_column(std::move(keys_copy), std::move(new_indices), stream, mr); + stream, + mr); + return make_dictionary_column(std::move(keys_copy), std::move(new_indices), stream, output_mr); } }; @@ -426,8 +440,10 @@ struct column_gatherer_impl { MapItRoot gather_map_end, bool nullify_out_of_bounds, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + auto const gather_map_size = std::distance(gather_map_begin, gather_map_end); if (gather_map_size == 0) { return empty_like(column); } @@ -477,9 +493,9 @@ struct column_gatherer_impl { gather_map_size, std::move(output_struct_members), 0, - rmm::device_buffer{0, stream, mr}, // Null mask will be fixed up in cudf::gather(). + rmm::device_buffer{0, stream, output_mr}, // Null mask will be fixed up in cudf::gather(). stream, - mr); + output_mr); } }; @@ -532,10 +548,13 @@ void gather_bitmask(table_view const& source, std::vector>& target, gather_bitmask_op op, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { if (target.empty()) { return; } + auto const output_mr = mr.get_output_mr(); + auto const temp_mr = mr.get_temporary_mr(); + // Validate that all target columns have the same size auto const target_rows = target.front()->size(); CUDF_EXPECTS(std::all_of(target.begin(), @@ -549,7 +568,7 @@ void gather_bitmask(table_view const& source, not target[i]->nullable()) { auto const state = op == gather_bitmask_op::PASSTHROUGH ? mask_state::ALL_VALID : mask_state::UNINITIALIZED; - auto mask = cudf::create_null_mask(target[i]->size(), state, stream, mr); + auto mask = cudf::create_null_mask(target[i]->size(), state, stream, output_mr); target[i]->set_null_mask(std::move(mask), 0); } } @@ -559,12 +578,10 @@ void gather_bitmask(table_view const& source, std::transform(target.begin(), target.end(), target_masks.begin(), [](auto const& col) { return col->mutable_view().null_mask(); }); - auto d_target_masks = - make_device_uvector_async(target_masks, stream, cudf::get_current_device_resource_ref()); + auto d_target_masks = make_device_uvector_async(target_masks, stream, temp_mr); - auto const device_source = table_device_view::create(source, stream); - auto d_valid_counts = make_zeroed_device_uvector_async( - target.size(), stream, cudf::get_current_device_resource_ref()); + auto const device_source = table_device_view::create(source, stream, temp_mr); + auto d_valid_counts = make_zeroed_device_uvector_async(target.size(), stream, temp_mr); // Dispatch operation enum to get implementation auto const impl = [op]() { @@ -621,7 +638,7 @@ void gather_bitmask(table_view const& source, * better performance. In case there are out-of-bound indices in the gather map, the behavior * is undefined. Defaults to `DONT_CHECK`. * @param[in] stream CUDA stream used for device memory operations and kernel launches. - * @param[in] mr Device memory resource used to allocate the returned table's device memory + * @param[in] mr Memory resources used for temporary allocations and the returned table * @return cudf::table Result of the gather */ template @@ -630,8 +647,10 @@ std::unique_ptr
gather(table_view const& source_table, MapIterator gather_map_end, out_of_bounds_policy bounds_policy, rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + std::vector> destination_columns; // TODO: Could be beneficial to use streams internally here @@ -661,7 +680,8 @@ std::unique_ptr
gather(table_view const& source_table, gather_bitmask(source_table, gather_map_begin, destination_columns, op, stream, mr); } else { for (size_type i = 0; i < source_table.num_columns(); ++i) { - set_all_valid_null_masks(source_table.column(i), *destination_columns[i], stream, mr); + set_all_valid_null_masks( + source_table.column(i), *destination_columns[i], stream, output_mr); } } } diff --git a/cpp/include/cudf/detail/gather.hpp b/cpp/include/cudf/detail/gather.hpp index a5fdf224228f..a7145499c115 100644 --- a/cpp/include/cudf/detail/gather.hpp +++ b/cpp/include/cudf/detail/gather.hpp @@ -21,21 +21,19 @@ namespace cudf { namespace detail { /** - * @copydoc cudf::gather(table_view const&,column_view const&,table_view - * const&,cudf::out_of_bounds_policy,cudf::negative_index_policy,cuda::stream_ref, - * rmm::device_async_resource_ref) + * @copydoc cudf::gather(table_view const&,column_view const&,out_of_bounds_policy, + * negative_index_policy,cuda::stream_ref,memory_resources) */ std::unique_ptr
gather(table_view const& source_table, column_view const& gather_map, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, cuda::stream_ref stream, - rmm::device_async_resource_ref mr); + memory_resources mr); /** - * @copydoc cudf::detail::gather(table_view const&,column_view const&,table_view - * const&,cudf::out_of_bounds_policy,cudf::negative_index_policy,cuda::stream_ref, - * rmm::device_async_resource_ref) + * @copydoc cudf::detail::gather(table_view const&,column_view const&,out_of_bounds_policy, + * negative_index_policy,cuda::stream_ref,memory_resources) * * @throws cudf::logic_error if `gather_map` span size is larger than max of `size_type`. */ @@ -44,7 +42,7 @@ std::unique_ptr
gather(table_view const& source_table, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, cuda::stream_ref stream, - rmm::device_async_resource_ref mr); + memory_resources mr); } // namespace detail } // namespace cudf diff --git a/cpp/include/cudf/detail/sizes_to_offsets_iterator.cuh b/cpp/include/cudf/detail/sizes_to_offsets_iterator.cuh index 79f50d9339dc..3015e877760b 100644 --- a/cpp/include/cudf/detail/sizes_to_offsets_iterator.cuh +++ b/cpp/include/cudf/detail/sizes_to_offsets_iterator.cuh @@ -236,7 +236,7 @@ static sizes_to_offsets_iterator make_sizes_to_offsets_i * * @code{.pseudo} * auto const bytes = cudf::detail::sizes_to_offsets( - * d_offsets, d_offsets + strings_count + 1, d_offsets, stream); + * d_offsets, d_offsets + strings_count + 1, d_offsets, 0, stream, mr); * CUDF_EXPECTS(bytes <= static_cast(std::numeric_limits::max()), * "Size of output exceeds the column size limit", std::overflow_error); * @endcode @@ -249,6 +249,7 @@ static sizes_to_offsets_iterator make_sizes_to_offsets_i * @param result Output iterator for scan result * @param initial_offset Initial offset to add to scan * @param stream CUDA stream used for device memory operations and kernel launches + * @param mr Memory resources used for temporary allocations * @return The last element of the scan */ template @@ -256,20 +257,22 @@ auto sizes_to_offsets(SizesIterator begin, SizesIterator end, OffsetsIterator result, int64_t initial_offset, - rmm::cuda_stream_view stream) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { + auto const temp_mr = mr.get_temporary_mr(); + using SizeType = cuda::std::iter_value_t; static_assert(std::is_integral_v, "Only numeric types are supported by sizes_to_offsets"); - using LastType = std::conditional_t, int64_t, uint64_t>; - auto last_element = - cudf::detail::device_scalar(0, stream, cudf::get_current_device_resource_ref()); + using LastType = std::conditional_t, int64_t, uint64_t>; + auto last_element = cudf::detail::device_scalar(0, stream, temp_mr); auto output_itr = make_sizes_to_offsets_iterator(result, result + std::distance(begin, end), last_element.data()); // This function uses the type of the initialization parameter as the accumulator type // when computing the individual scan output elements. - thrust::exclusive_scan(rmm::exec_policy_nosync(stream, cudf::get_current_device_resource_ref()), + thrust::exclusive_scan(rmm::exec_policy_nosync(stream, temp_mr), begin, end, output_itr, @@ -295,19 +298,16 @@ auto sizes_to_offsets(SizesIterator begin, * @param begin The beginning of the input sequence * @param end The end of the input sequence * @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 + * @param mr Memory resources used for temporary allocations and the returned column * @return Offsets column and total elements */ template std::pair, size_type> make_offsets_child_column( - InputIterator begin, - InputIterator end, - rmm::cuda_stream_view stream, - rmm::device_async_resource_ref mr) + InputIterator begin, InputIterator end, rmm::cuda_stream_view stream, cudf::memory_resources mr) { - auto count = static_cast(std::distance(begin, end)); - auto offsets_column = - make_numeric_column(data_type{type_id::INT32}, count + 1, mask_state::UNALLOCATED, stream, mr); + auto count = static_cast(std::distance(begin, end)); + auto offsets_column = make_numeric_column( + data_type{type_id::INT32}, count + 1, mask_state::UNALLOCATED, stream, mr.get_output_mr()); auto offsets_view = offsets_column->mutable_view(); auto d_offsets = offsets_view.template data(); @@ -327,7 +327,7 @@ std::pair, size_type> make_offsets_child_column( auto input_itr = cudf::detail::make_counting_transform_iterator(0, map_fn); // Use the sizes-to-offsets iterator to compute the total number of elements auto const total_elements = - sizes_to_offsets(input_itr, input_itr + count + 1, d_offsets, 0, stream); + sizes_to_offsets(input_itr, input_itr + count + 1, d_offsets, 0, stream, mr); // the offsets are 32-bit so the total must fit in an int32_t CUDF_EXPECTS( total_elements <= static_cast(std::numeric_limits::max()), diff --git a/cpp/include/cudf/dictionary/detail/encode.hpp b/cpp/include/cudf/dictionary/detail/encode.hpp index 6a212831661c..8edfccfea960 100644 --- a/cpp/include/cudf/dictionary/detail/encode.hpp +++ b/cpp/include/cudf/dictionary/detail/encode.hpp @@ -37,13 +37,13 @@ namespace dictionary::detail { * @param column The column to dictionary encode. * @param indices_type The integer type to use for the indices. * @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. + * @param mr Memory resources used for temporary allocations and the returned column. * @return Returns a dictionary column. */ std::unique_ptr encode(column_view const& column, data_type indices_type, cuda::stream_ref stream, - rmm::device_async_resource_ref mr); + memory_resources mr); /** * @brief Create a column by gathering the keys from the provided @@ -57,12 +57,12 @@ std::unique_ptr encode(column_view const& column, * * @param dictionary_column Existing dictionary column. * @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. + * @param mr Memory resources used for temporary allocations and the returned column. * @return New column with type matching the dictionary_column's keys. */ std::unique_ptr decode(dictionary_column_view const& dictionary_column, cuda::stream_ref stream, - rmm::device_async_resource_ref mr); + memory_resources mr); /** * @brief Return minimal integer type for the given number of elements. diff --git a/cpp/include/cudf/dictionary/encode.hpp b/cpp/include/cudf/dictionary/encode.hpp index d915927e7c0b..514782812e22 100644 --- a/cpp/include/cudf/dictionary/encode.hpp +++ b/cpp/include/cudf/dictionary/encode.hpp @@ -47,14 +47,13 @@ namespace dictionary { * @param column The column to dictionary encode * @param indices_type The integer type to use for the indices * @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 + * @param mr Memory resources used for temporary allocations and the returned column * @return Returns a dictionary column */ -std::unique_ptr encode( - column_view const& column, - data_type indices_type = data_type{type_id::INT32}, - cuda::stream_ref stream = cudf::get_default_stream(), - rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); +std::unique_ptr encode(column_view const& column, + data_type indices_type = data_type{type_id::INT32}, + cuda::stream_ref stream = cudf::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()); /** * @brief Create a column by gathering the keys from the provided @@ -68,13 +67,12 @@ std::unique_ptr encode( * * @param dictionary_column Existing dictionary column * @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 + * @param mr Memory resources used for temporary allocations and the returned column * @return New column with type matching the dictionary_column's keys */ -std::unique_ptr decode( - dictionary_column_view const& dictionary_column, - cuda::stream_ref stream = cudf::get_default_stream(), - rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref()); +std::unique_ptr decode(dictionary_column_view const& dictionary_column, + cuda::stream_ref stream = cudf::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()); /** @} */ // end of group } // namespace dictionary diff --git a/cpp/include/cudf/strings/detail/gather.cuh b/cpp/include/cudf/strings/detail/gather.cuh index 77df8f218ea4..5ca1f3375633 100644 --- a/cpp/include/cudf/strings/detail/gather.cuh +++ b/cpp/include/cudf/strings/detail/gather.cuh @@ -215,7 +215,7 @@ CUDF_KERNEL void gather_chars_fn_char_parallel(StringIterator strings_begin, * @param begin Start of index iterator. * @param end End of index iterator. * @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. + * @param mr Memory resources used for temporary allocations and the returned column. * @return New strings column containing the gathered strings. */ template @@ -223,13 +223,16 @@ std::unique_ptr gather(strings_column_view const& strings, MapIterator begin, MapIterator end, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + auto const temp_mr = mr.get_temporary_mr(); + auto const output_count = std::distance(begin, end); if (output_count == 0) return make_empty_column(type_id::STRING); // build offsets column - auto const d_strings = column_device_view::create(strings.parent(), stream); + auto const d_strings = column_device_view::create(strings.parent(), stream, temp_mr); auto const d_in_offsets = cudf::detail::offsetalator_factory::make_input_iterator( strings.is_empty() ? make_empty_column(type_id::INT32)->view() : strings.offsets(), strings.offset()); @@ -252,7 +255,7 @@ std::unique_ptr gather(strings_column_view const& strings, cudf::prefetch::detail::prefetch(strings.chars_begin(stream), strings.chars_size(stream), stream); // build output char column - auto out_chars_data = rmm::device_uvector(out_char_bytes, stream, mr); + auto out_chars_data = rmm::device_uvector(out_char_bytes, stream, output_mr); cudf::prefetch::detail::prefetch(out_chars_data, stream); auto d_out_chars = out_chars_data.data(); @@ -318,7 +321,7 @@ std::unique_ptr gather(strings_column_view const& strings, stream.get()); // Allocate temporary storage - auto d_temp_storage = rmm::device_buffer(temp_storage_bytes, stream, mr); + auto d_temp_storage = rmm::device_buffer(temp_storage_bytes, stream, temp_mr); // Run batched copy algorithm cub::DeviceMemcpy::Batched(d_temp_storage.data(), @@ -358,7 +361,7 @@ std::unique_ptr gather(strings_column_view const& strings, * @param end End of index iterator. * @param nullify_out_of_bounds If true, indices outside the column's range are nullified. * @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. + * @param mr Memory resources used for temporary allocations and the returned column. * @return New strings column containing the gathered strings. */ template @@ -367,7 +370,7 @@ std::unique_ptr gather(strings_column_view const& strings, MapIterator end, bool nullify_out_of_bounds, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { if (nullify_out_of_bounds) return gather(strings, begin, end, stream, mr); return gather(strings, begin, end, stream, mr); diff --git a/cpp/include/cudf/strings/detail/strings_children.cuh b/cpp/include/cudf/strings/detail/strings_children.cuh index 1f031099c235..d1109f4ee4c7 100644 --- a/cpp/include/cudf/strings/detail/strings_children.cuh +++ b/cpp/include/cudf/strings/detail/strings_children.cuh @@ -115,23 +115,24 @@ rmm::device_uvector make_chars_buffer(column_view const& offsets, * @param begin The beginning of the input sequence * @param end The end of the input sequence * @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 + * @param mr Memory resources used for temporary allocations and the returned column * @return Offsets column and total elements */ template -std::pair, int64_t> make_offsets_child_column( - InputIterator begin, - InputIterator end, - cuda::stream_ref stream, - rmm::device_async_resource_ref mr) +std::pair, int64_t> make_offsets_child_column(InputIterator begin, + InputIterator end, + cuda::stream_ref stream, + cudf::memory_resources mr) { + auto const output_mr = mr.get_output_mr(); + auto constexpr size_type_max = static_cast(std::numeric_limits::max()); auto const lcount = static_cast(std::distance(begin, end)); CUDF_EXPECTS( lcount <= size_type_max, "Size of output exceeds the column size limit", std::overflow_error); auto const strings_count = static_cast(lcount); auto offsets_column = make_numeric_column( - data_type{type_id::INT32}, strings_count + 1, mask_state::UNALLOCATED, stream, mr); + data_type{type_id::INT32}, strings_count + 1, mask_state::UNALLOCATED, stream, output_mr); auto d_offsets = offsets_column->mutable_view().template data(); // The number of offsets is strings_count+1 so to build the offsets from the sizes @@ -141,8 +142,8 @@ std::pair, int64_t> make_offsets_child_column( auto input_itr = cudf::detail::make_counting_transform_iterator(0, string_offsets_fn{begin, strings_count}); // Use the sizes-to-offsets iterator to compute the total number of elements - auto const total_bytes = - cudf::detail::sizes_to_offsets(input_itr, input_itr + strings_count + 1, d_offsets, 0, stream); + auto const total_bytes = cudf::detail::sizes_to_offsets( + input_itr, input_itr + strings_count + 1, d_offsets, 0, stream, mr); auto const threshold = cudf::strings::get_offset64_threshold(); CUDF_EXPECTS(cudf::strings::is_large_strings_enabled() || (total_bytes < threshold), @@ -151,10 +152,10 @@ std::pair, int64_t> make_offsets_child_column( if (total_bytes >= cudf::strings::get_offset64_threshold()) { // recompute as int64 offsets when above the threshold offsets_column = make_numeric_column( - data_type{type_id::INT64}, strings_count + 1, mask_state::UNALLOCATED, stream, mr); + data_type{type_id::INT64}, strings_count + 1, mask_state::UNALLOCATED, stream, output_mr); auto d_offsets64 = offsets_column->mutable_view().template data(); cudf::detail::sizes_to_offsets( - input_itr, input_itr + strings_count + 1, d_offsets64, 0, stream); + input_itr, input_itr + strings_count + 1, d_offsets64, 0, stream, mr); } return std::pair(std::move(offsets_column), total_bytes); diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index e749a086cd6b..abb783e83438 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -1081,7 +1081,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { begin, end, stream, mr.get_temporary_mr()), cudf::data_type{type_id::INT32}, stream, - mr.get_output_mr()); + mr); } /** @@ -1123,7 +1123,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { begin, end, v, stream, mr.get_temporary_mr()), cudf::data_type{type_id::INT32}, stream, - mr.get_output_mr()); + mr); } /** @@ -1313,7 +1313,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { cudf::dictionary::encode(strings_column_wrapper(begin, end, stream, mr.get_temporary_mr()), cudf::data_type{type_id::INT32}, stream, - mr.get_output_mr()); + mr); } /** @@ -1358,7 +1358,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { cudf::dictionary::encode(strings_column_wrapper(begin, end, v, stream, mr.get_temporary_mr()), cudf::data_type{type_id::INT32}, stream, - mr.get_output_mr()); + mr); } /** diff --git a/cpp/src/copying/gather.cu b/cpp/src/copying/gather.cu index 055003e01808..48ae8a77e6b1 100644 --- a/cpp/src/copying/gather.cu +++ b/cpp/src/copying/gather.cu @@ -28,7 +28,7 @@ std::unique_ptr
gather(table_view const& source_table, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { CUDF_EXPECTS(not gather_map.has_nulls(), "gather_map contains nulls", std::invalid_argument); @@ -55,7 +55,7 @@ std::unique_ptr
gather(table_view const& source_table, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { CUDF_EXPECTS(gather_map.size() <= static_cast(std::numeric_limits::max()), "gather map size exceeds the column size limit", @@ -74,7 +74,7 @@ std::unique_ptr
gather(table_view const& source_table, column_view const& gather_map, out_of_bounds_policy bounds_policy, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { CUDF_FUNC_RANGE(); @@ -89,7 +89,7 @@ std::unique_ptr
gather(table_view const& source_table, out_of_bounds_policy bounds_policy, negative_index_policy neg_indices, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + cudf::memory_resources mr) { CUDF_FUNC_RANGE(); return detail::gather(source_table, gather_map, bounds_policy, neg_indices, stream, mr); diff --git a/cpp/src/dictionary/decode.cu b/cpp/src/dictionary/decode.cu index 1f54b62843ff..3d601db0701d 100644 --- a/cpp/src/dictionary/decode.cu +++ b/cpp/src/dictionary/decode.cu @@ -36,13 +36,13 @@ struct indices_handler_fn { */ std::unique_ptr decode(dictionary_column_view const& source, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + memory_resources mr) { if (source.is_empty()) return make_empty_column(type_id::EMPTY); // annotated indices include the offset, size and bitmask from it's parent auto const indices = source.get_indices_annotated(); - auto const d_indices = column_device_view::create(indices, stream); + auto const d_indices = column_device_view::create(indices, stream, mr.get_temporary_mr()); auto const d_iterator = cudf::detail::indexalator_factory::make_input_iterator(indices); auto const indices_begin = cudf::detail::make_counting_transform_iterator( 0, indices_handler_fn{d_iterator, *d_indices, source.keys().size()}); @@ -57,8 +57,8 @@ std::unique_ptr decode(dictionary_column_view const& source, auto output_column = std::unique_ptr(std::move(table_column.front())); // apply any nulls to the output column - output_column->set_null_mask(cudf::detail::copy_bitmask(source.parent(), stream, mr), - source.null_count()); + output_column->set_null_mask( + cudf::detail::copy_bitmask(source.parent(), stream, mr.get_output_mr()), source.null_count()); return output_column; } @@ -67,7 +67,7 @@ std::unique_ptr decode(dictionary_column_view const& source, std::unique_ptr decode(dictionary_column_view const& source, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + memory_resources mr) { CUDF_FUNC_RANGE(); return detail::decode(source, stream, mr); diff --git a/cpp/src/dictionary/encode.cu b/cpp/src/dictionary/encode.cu index a46943d83cdb..5ced742b8df3 100644 --- a/cpp/src/dictionary/encode.cu +++ b/cpp/src/dictionary/encode.cu @@ -56,7 +56,7 @@ struct encode_fn { std::unique_ptr encode(column_view const& input, data_type indices_type, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + memory_resources mr) { CUDF_EXPECTS(is_signed(indices_type) && is_index_type(indices_type), "indices must be type signed integer", @@ -68,8 +68,11 @@ std::unique_ptr encode(column_view const& input, "encoding nested types not supported", std::invalid_argument); + auto const output_mr = mr.get_output_mr(); + auto const temp_mr = mr.get_temporary_mr(); + auto indices_column = cudf::make_numeric_column( - indices_type, input.size(), cudf::mask_state::UNALLOCATED, stream, mr); + indices_type, input.size(), cudf::mask_state::UNALLOCATED, stream, output_mr); if (input.is_empty()) { return make_dictionary_column( make_empty_column(input.type()), std::move(indices_column), rmm::device_buffer{}, 0); @@ -82,7 +85,6 @@ std::unique_ptr encode(column_view const& input, auto const has_nulls = nullate::DYNAMIC{input.has_nulls()}; auto const tv = cudf::table_view({input}); - auto const temp_mr = cudf::get_current_device_resource_ref(); auto const row_hash = cudf::detail::row::hash::row_hasher(tv, stream, temp_mr); auto const row_equal = cudf::detail::row::equality::self_comparator(tv, stream, temp_mr); auto const comparator = cudf::detail::row::equality::nan_equal_physical_equality_comparator{}; @@ -133,7 +135,7 @@ std::unique_ptr encode(column_view const& input, // create column with keys_column and indices_column return make_dictionary_column(std::move(keys_column), std::move(indices_column), - cudf::detail::copy_bitmask(input, stream, mr), + cudf::detail::copy_bitmask(input, stream, output_mr), input.null_count()); } @@ -154,7 +156,7 @@ data_type get_indices_type_for_size(size_type keys_size) std::unique_ptr encode(column_view const& input_column, data_type indices_type, cuda::stream_ref stream, - rmm::device_async_resource_ref mr) + memory_resources mr) { CUDF_FUNC_RANGE(); return detail::encode(input_column, indices_type, stream, mr); diff --git a/cpp/src/io/utilities/column_buffer_strings.cu b/cpp/src/io/utilities/column_buffer_strings.cu index 49aecacfa7d9..40c088966e3c 100644 --- a/cpp/src/io/utilities/column_buffer_strings.cu +++ b/cpp/src/io/utilities/column_buffer_strings.cu @@ -27,7 +27,7 @@ std::unique_ptr cudf::io::detail::inline_column_buffer::make_string_colu auto d_offsets64 = offsets_col->mutable_view().template data(); // it's safe to call with size + 1 because _data is also sized that large cudf::detail::sizes_to_offsets( - offsets_ptr, offsets_ptr + size + 1, d_offsets64, initial_string_offset, stream); + offsets_ptr, offsets_ptr + size + 1, d_offsets64, initial_string_offset, stream, _mr); return make_strings_column( size, std::move(offsets_col), std::move(_string_data), null_count(), std::move(_null_mask)); } else { diff --git a/cpp/src/text/edit_distance.cu b/cpp/src/text/edit_distance.cu index 7df6e91b0f71..12b5a5b1a1e4 100644 --- a/cpp/src/text/edit_distance.cu +++ b/cpp/src/text/edit_distance.cu @@ -261,7 +261,7 @@ std::unique_ptr edit_distance(cudf::strings_column_view const& inp // get the total size of the temporary compute buffer // and convert sizes to offsets in-place auto const compute_size = - cudf::detail::sizes_to_offsets(offsets.begin(), offsets.end(), offsets.begin(), 0, stream); + cudf::detail::sizes_to_offsets(offsets.begin(), offsets.end(), offsets.begin(), 0, stream, mr); rmm::device_uvector compute_buffer(compute_size, stream); auto d_buffer = compute_buffer.data(); diff --git a/cpp/src/text/jaccard.cu b/cpp/src/text/jaccard.cu index 5e6f215d6a57..816cd62fb8ef 100644 --- a/cpp/src/text/jaccard.cu +++ b/cpp/src/text/jaccard.cu @@ -339,8 +339,12 @@ std::pair, rmm::device_uvector> hash_subs count_substrings_kernel<<>>( *d_strings, width, offsets.data()); CUDF_CUDA_TRY(cudaGetLastError()); - auto const total_hashes = - cudf::detail::sizes_to_offsets(offsets.begin(), offsets.end(), offsets.begin(), 0, stream); + auto const total_hashes = cudf::detail::sizes_to_offsets(offsets.begin(), + offsets.end(), + offsets.begin(), + 0, + stream, + cudf::get_current_device_resource_ref()); // hash substrings rmm::device_uvector hashes(total_hashes, stream); diff --git a/cpp/src/text/wordpiece_tokenize.cu b/cpp/src/text/wordpiece_tokenize.cu index cf04825144bf..be148ed19c1b 100644 --- a/cpp/src/text/wordpiece_tokenize.cu +++ b/cpp/src/text/wordpiece_tokenize.cu @@ -780,8 +780,12 @@ rmm::device_uvector compute_some_tokens( return cuda::std::min(max_words_per_row, d_str.size_bytes() / 2); })); - auto const max_size = cudf::detail::sizes_to_offsets( - max_word_offsets.begin(), max_word_offsets.end(), max_word_offsets.begin(), 0, stream); + auto const max_size = cudf::detail::sizes_to_offsets(max_word_offsets.begin(), + max_word_offsets.end(), + max_word_offsets.begin(), + 0, + stream, + cudf::get_current_device_resource_ref()); auto start_words = rmm::device_uvector(max_size, stream); auto word_sizes = rmm::device_uvector(max_size, stream); diff --git a/cpp/tests/dictionary/decode_test.cpp b/cpp/tests/dictionary/decode_test.cpp index 778affa05de8..8c46c9a77df5 100644 --- a/cpp/tests/dictionary/decode_test.cpp +++ b/cpp/tests/dictionary/decode_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -12,46 +12,72 @@ #include -struct DictionaryDecodeTest : public cudf::test::BaseFixture {}; +struct DictionaryDecodeTest : public cudf::test::BaseFixtureWithHarness {}; TEST_F(DictionaryDecodeTest, StringColumn) { + auto const stream = this->stream(); + auto const mr = this->resources(); + std::vector h_strings{"eee", "aaa", "ddd", "bbb", "ccc", "ccc", "ccc", "eee", "aaa"}; - cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end()); + cudf::test::strings_column_wrapper strings(h_strings.begin(), h_strings.end(), stream, mr); - auto dictionary = cudf::dictionary::encode(strings); - auto output = cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view())); + auto dictionary = + cudf::dictionary::encode(strings, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto output = + cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view()), stream, mr); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(strings, *output); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + strings, *output, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TEST_F(DictionaryDecodeTest, FloatColumn) { - cudf::test::fixed_width_column_wrapper input{4.25, 7.125, 0.5, -11.75, 7.125, 0.5}; + auto const stream = this->stream(); + auto const mr = this->resources(); + + cudf::test::fixed_width_column_wrapper input{ + {4.25, 7.125, 0.5, -11.75, 7.125, 0.5}, stream, mr}; - auto dictionary = cudf::dictionary::encode(input); - auto output = cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view())); + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto output = + cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view()), stream, mr); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(input, *output); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + input, *output, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TEST_F(DictionaryDecodeTest, ColumnWithNull) { + auto const stream = this->stream(); + auto const mr = this->resources(); + cudf::test::fixed_width_column_wrapper input{ {444, 0, 333, 111, 222, 222, 222, 444, 000}, - {true, true, true, true, true, false, true, true, true}}; + {true, true, true, true, true, false, true, true, true}, + stream, + mr}; - auto dictionary = cudf::dictionary::encode(input); - auto output = cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view())); + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto output = + cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view()), stream, mr); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(input, *output); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + input, *output, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TEST_F(DictionaryDecodeTest, EmptyColumn) { - cudf::test::fixed_width_column_wrapper input; - auto dictionary = cudf::dictionary::encode(input); - auto output = cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view())); + auto const stream = this->stream(); + auto const mr = this->resources(); + + cudf::test::fixed_width_column_wrapper input{}; + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto output = + cudf::dictionary::decode(cudf::dictionary_column_view(dictionary->view()), stream, mr); // check empty EXPECT_EQ(output->size(), 0); diff --git a/cpp/tests/dictionary/encode_test.cpp b/cpp/tests/dictionary/encode_test.cpp index ee82e3cf7175..90cdb71517af 100644 --- a/cpp/tests/dictionary/encode_test.cpp +++ b/cpp/tests/dictionary/encode_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -12,18 +12,23 @@ #include #include -struct DictionaryEncodeTest : public cudf::test::BaseFixture {}; +struct DictionaryEncodeTest : public cudf::test::BaseFixtureWithHarness {}; TEST_F(DictionaryEncodeTest, EncodeStringColumn) { + auto const stream = this->stream(); + auto const mr = this->resources(); + cudf::test::strings_column_wrapper input( - {"eee", "aaa", "ddd", "bbb", "ccc", "ccc", "ccc", "eee", "aaa"}); + {"eee", "aaa", "ddd", "bbb", "ccc", "ccc", "ccc", "eee", "aaa"}, stream, mr); - auto dictionary = cudf::dictionary::encode(input); - auto view = cudf::dictionary_column_view(dictionary->view()); + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto view = cudf::dictionary_column_view(dictionary->view()); - auto decoded = cudf::dictionary::decode(view); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(decoded->view(), input); + auto decoded = cudf::dictionary::decode(view, stream, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + decoded->view(), input, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } template @@ -34,26 +39,39 @@ TYPED_TEST_SUITE(DictionaryEncodeNumericTest, NumericTypes); TYPED_TEST(DictionaryEncodeNumericTest, Encode) { - auto input = cudf::test::fixed_width_column_wrapper{4, 7, 0, -11, 7, 0}; + auto const stream = this->stream(); + auto const mr = this->resources(); - auto dictionary = cudf::dictionary::encode(input); - auto view = cudf::dictionary_column_view(dictionary->view()); + auto input = + cudf::test::fixed_width_column_wrapper{{4, 7, 0, -11, 7, 0}, stream, mr}; + + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto view = cudf::dictionary_column_view(dictionary->view()); - auto decoded = cudf::dictionary::decode(view); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(decoded->view(), input); + auto decoded = cudf::dictionary::decode(view, stream, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + decoded->view(), input, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TEST_F(DictionaryEncodeTest, EncodeWithNull) { + auto const stream = this->stream(); + auto const mr = this->resources(); + cudf::test::fixed_width_column_wrapper input{ {444, 0, 333, 111, 222, 222, 222, 444, 000}, - {true, true, true, true, true, false, true, true, true}}; + {true, true, true, true, true, false, true, true, true}, + stream, + mr}; - auto dictionary = cudf::dictionary::encode(input); - auto view = cudf::dictionary_column_view(dictionary->view()); + auto dictionary = + cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + auto view = cudf::dictionary_column_view(dictionary->view()); - auto decoded = cudf::dictionary::decode(view); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(decoded->view(), input); + auto decoded = cudf::dictionary::decode(view, stream, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + decoded->view(), input, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } template @@ -63,20 +81,28 @@ TYPED_TEST_SUITE(DictionaryEncodeIndicesTest, IndexTypes); TYPED_TEST(DictionaryEncodeIndicesTest, IndexType) { - auto input = cudf::test::strings_column_wrapper({"aaa", "bbb", "bbb", "cccc"}); + auto const stream = this->stream(); + auto const mr = this->resources(); + + auto input = cudf::test::strings_column_wrapper({"aaa", "bbb", "bbb", "cccc"}, stream, mr); auto data_type = cudf::data_type{cudf::type_to_id()}; - auto dictionary = cudf::dictionary::encode(input, data_type); + auto dictionary = cudf::dictionary::encode(input, data_type, stream, mr); auto view = cudf::dictionary_column_view(dictionary->view()); EXPECT_EQ(view.indices().type(), data_type); } TEST_F(DictionaryEncodeTest, Errors) { - cudf::test::fixed_width_column_wrapper input{0, 1, 2, 3, -1, -2, -3}; + auto const stream = this->stream(); + auto const mr = this->resources(); + + cudf::test::fixed_width_column_wrapper input{{0, 1, 2, 3, -1, -2, -3}, stream, mr}; - EXPECT_THROW(cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::UINT16}), + EXPECT_THROW(cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::UINT16}, stream, mr), cudf::data_type_error); - auto encoded = cudf::dictionary::encode(input); - EXPECT_THROW(cudf::dictionary::encode(encoded->view()), std::invalid_argument); + auto encoded = cudf::dictionary::encode(input, cudf::data_type{cudf::type_id::INT32}, stream, mr); + EXPECT_THROW( + cudf::dictionary::encode(encoded->view(), cudf::data_type{cudf::type_id::INT32}, stream, mr), + std::invalid_argument); } diff --git a/cpp/tests/row_operator/row_operator_tests.cu b/cpp/tests/row_operator/row_operator_tests.cu index 073c2dd58989..c5e017d37307 100644 --- a/cpp/tests/row_operator/row_operator_tests.cu +++ b/cpp/tests/row_operator/row_operator_tests.cu @@ -484,9 +484,6 @@ TEST_F(RowOperatorTest, TestPrimitiveRowHasher64BitHash) TEST_F(RowOperatorTest, TestRowHasherDictionaryColumn) { - // TODO: dictionary encoding gathers the keys, and gather still allocates temporaries from the - // current device resource. - auto const stream = this->stream(); auto const mr = this->resources(); @@ -529,9 +526,6 @@ TEST_F(RowOperatorTest, TestRowHasherDictionaryColumn) TEST_F(RowOperatorTest, TestRowHasherDictionaryColumnWithNulls) { - // TODO: dictionary encoding gathers the keys, and gather still allocates temporaries from the - // current device resource. - auto const stream = this->stream(); auto const mr = this->resources();