Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default parameters for cudf::dictionary::detail functions #12006

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cpp/include/cudf/detail/scatter.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ struct column_scatterer_impl<dictionary32> {
// first combine keys so both dictionaries have the same set
auto target_matched = dictionary::detail::add_keys(target, source.keys(), stream, mr);
auto const target_view = dictionary_column_view(target_matched->view());
auto source_matched = dictionary::detail::set_keys(source, target_view.keys(), stream);
auto source_matched = dictionary::detail::set_keys(
source, target_view.keys(), stream, rmm::mr::get_current_device_resource());
auto const source_view = dictionary_column_view(source_matched->view());

// now build the new indices by doing a scatter on just the matched indices
Expand Down
7 changes: 3 additions & 4 deletions cpp/include/cudf/dictionary/detail/concatenate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ namespace detail {
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New column with concatenated results.
*/
std::unique_ptr<column> concatenate(
host_span<column_view const> columns,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> concatenate(host_span<column_view const> columns,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace dictionary
Expand Down
16 changes: 7 additions & 9 deletions cpp/include/cudf/dictionary/detail/encode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ namespace detail {
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return Returns a dictionary column.
*/
std::unique_ptr<column> encode(
column_view const& column,
data_type indices_type = data_type{type_id::UINT32},
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> encode(column_view const& column,
data_type indices_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Create a column by gathering the keys from the provided
Expand All @@ -72,10 +71,9 @@ std::unique_ptr<column> encode(
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New column with type matching the dictionary_column's keys.
*/
std::unique_ptr<column> decode(
dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> decode(dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Return minimal integer type for the given number of elements.
Expand Down
18 changes: 8 additions & 10 deletions cpp/include/cudf/dictionary/detail/replace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ namespace detail {
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New dictionary column with null rows replaced.
*/
std::unique_ptr<column> replace_nulls(
dictionary_column_view const& input,
dictionary_column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> replace_nulls(dictionary_column_view const& input,
dictionary_column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Create a new dictionary column by replacing nulls with a
Expand All @@ -57,11 +56,10 @@ std::unique_ptr<column> replace_nulls(
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New dictionary column with null rows replaced.
*/
std::unique_ptr<column> replace_nulls(
dictionary_column_view const& input,
scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> replace_nulls(dictionary_column_view const& input,
scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace dictionary
Expand Down
18 changes: 8 additions & 10 deletions cpp/include/cudf/dictionary/detail/search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ namespace detail {
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<scalar> get_index(
dictionary_column_view const& dictionary,
scalar const& key,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<scalar> get_index(dictionary_column_view const& dictionary,
scalar const& key,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Get the index for a key if it were added to the given dictionary.
Expand All @@ -56,11 +55,10 @@ std::unique_ptr<scalar> get_index(
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return Numeric scalar index value of the key within the dictionary
*/
std::unique_ptr<scalar> get_insert_index(
dictionary_column_view const& dictionary,
scalar const& key,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<scalar> get_insert_index(dictionary_column_view const& dictionary,
scalar const& key,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace dictionary
Expand Down
38 changes: 17 additions & 21 deletions cpp/include/cudf/dictionary/detail/update_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,42 @@ namespace detail {
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> add_keys(
dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> add_keys(dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::dictionary::remove_keys(dictionary_column_view const&,column_view
* const&,mm::mr::device_memory_resource*)
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> remove_keys(
dictionary_column_view const& dictionary_column,
column_view const& keys_to_remove,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> remove_keys(dictionary_column_view const& dictionary_column,
column_view const& keys_to_remove,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::dictionary::remove_unused_keys(dictionary_column_view
* const&,mm::mr::device_memory_resource*)
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> remove_unused_keys(
dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> remove_unused_keys(dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::dictionary::set_keys(dictionary_column_view
* const&,mm::mr::device_memory_resource*)
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> set_keys(
dictionary_column_view const& dictionary_column,
column_view const& keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> set_keys(dictionary_column_view const& dictionary_column,
column_view const& keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc
Expand All @@ -82,7 +78,7 @@ std::unique_ptr<column> set_keys(
std::vector<std::unique_ptr<column>> match_dictionaries(
cudf::host_span<dictionary_column_view const> input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::mr::device_memory_resource* mr);

/**
* @brief Create new dictionaries that have keys merged from dictionary columns
Expand All @@ -106,7 +102,7 @@ std::vector<std::unique_ptr<column>> match_dictionaries(
std::pair<std::vector<std::unique_ptr<column>>, std::vector<table_view>> match_dictionaries(
std::vector<table_view> tables,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace dictionary
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/copying/copy_range.cu
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ std::unique_ptr<cudf::column> out_of_place_copy_range_dispatch::operator()<cudf:
auto target_matched =
cudf::dictionary::detail::add_keys(dict_target, dict_source.keys(), stream, mr);
auto const target_view = cudf::dictionary_column_view(target_matched->view());
auto source_matched = cudf::dictionary::detail::set_keys(dict_source, target_view.keys(), stream);
auto source_matched = cudf::dictionary::detail::set_keys(
dict_source, target_view.keys(), stream, rmm::mr::get_current_device_resource());
auto const source_view = cudf::dictionary_column_view(source_matched->view());

// build the new indices by calling in_place_copy_range on just the indices
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/copying/scatter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ struct column_scalar_scatterer_impl<dictionary32, MapIterator> {
stream,
mr);
auto dict_view = dictionary_column_view(dict_target->view());
auto scalar_index = dictionary::detail::get_index(dict_view, source.get(), stream);
auto scalar_iter = thrust::make_permutation_iterator(
auto scalar_index = dictionary::detail::get_index(
dict_view, source.get(), stream, rmm::mr::get_current_device_resource());
auto scalar_iter = thrust::make_permutation_iterator(
indexalator_factory::make_input_iterator(*scalar_index), thrust::make_constant_iterator(0));
auto new_indices = std::make_unique<column>(dict_view.get_indices_annotated(), stream, mr);
auto target_iter = indexalator_factory::make_output_iterator(new_indices->mutable_view());
Expand Down
9 changes: 4 additions & 5 deletions cpp/src/dictionary/add_keys.cu
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ namespace detail {
* d2 is now {[a, b, c, d, e, f], [5, 0, 3, 1, 2, 2, 2, 5, 0]}
* ```
*/
std::unique_ptr<column> add_keys(
dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<column> add_keys(dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(!new_keys.has_nulls(), "Keys must not have nulls");
auto old_keys = dictionary_column.keys(); // [a,b,c,d,f]
Expand Down
25 changes: 11 additions & 14 deletions cpp/src/dictionary/remove_keys.cu
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ namespace {
* @param mr Device memory resource used to allocate the returned column's device memory.
*/
template <typename KeysKeeper>
std::unique_ptr<column> remove_keys_fn(
dictionary_column_view const& dictionary_column,
KeysKeeper keys_to_keep_fn,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<column> remove_keys_fn(dictionary_column_view const& dictionary_column,
KeysKeeper keys_to_keep_fn,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const keys_view = dictionary_column.keys();
auto const indices_type = dictionary_column.indices().type();
Expand Down Expand Up @@ -148,11 +147,10 @@ std::unique_ptr<column> remove_keys_fn(

} // namespace

std::unique_ptr<column> remove_keys(
dictionary_column_view const& dictionary_column,
column_view const& keys_to_remove,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<column> remove_keys(dictionary_column_view const& dictionary_column,
column_view const& keys_to_remove,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(!keys_to_remove.has_nulls(), "keys_to_remove must not have nulls");
auto const keys_view = dictionary_column.keys();
Expand All @@ -166,10 +164,9 @@ std::unique_ptr<column> remove_keys(
return remove_keys_fn(dictionary_column, key_matcher, stream, mr);
}

std::unique_ptr<column> remove_unused_keys(
dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<column> remove_unused_keys(dictionary_column_view const& dictionary_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// locate the keys to remove
auto const keys_size = dictionary_column.keys_size();
Expand Down
7 changes: 4 additions & 3 deletions cpp/src/dictionary/replace.cu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -123,8 +123,9 @@ std::unique_ptr<column> replace_nulls(dictionary_column_view const& input,
// first add the replacement to the keys so only the indices need to be processed
auto input_matched = dictionary::detail::add_keys(
input, make_column_from_scalar(replacement, 1, stream)->view(), stream, mr);
auto const input_view = dictionary_column_view(input_matched->view());
auto const scalar_index = get_index(input_view, replacement, stream);
auto const input_view = dictionary_column_view(input_matched->view());
auto const scalar_index =
get_index(input_view, replacement, stream, rmm::mr::get_current_device_resource());

// now build the new indices by doing replace-null on the updated indices
auto const input_indices = input_view.get_indices_annotated();
Expand Down
9 changes: 4 additions & 5 deletions cpp/src/dictionary/set_keys.cu
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,10 @@ struct dispatch_compute_indices {
} // namespace

//
std::unique_ptr<column> set_keys(
dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<column> set_keys(dictionary_column_view const& dictionary_column,
column_view const& new_keys,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(!new_keys.has_nulls(), "keys parameter must not have nulls");
auto keys = dictionary_column.keys();
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/filling/fill.cu
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ std::unique_ptr<cudf::column> out_of_place_fill_range_dispatch::operator()<cudf:
cudf::dictionary_column_view(target_matched->view()).get_indices_annotated();

// get the index of the key just added
auto index_of_value = cudf::dictionary::detail::get_index(target_matched->view(), value, stream);
auto index_of_value = cudf::dictionary::detail::get_index(
target_matched->view(), value, stream, rmm::mr::get_current_device_resource());
// now call fill using just the indices column and the new index
auto new_indices =
cudf::type_dispatcher(target_indices.type(),
Expand Down
11 changes: 7 additions & 4 deletions cpp/src/replace/clamp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,17 @@ std::unique_ptr<column> dispatch_clamp::operator()<cudf::dictionary32>(
return result;
}();
auto matched_view = dictionary_column_view(matched_column->view());
auto default_mr = rmm::mr::get_current_device_resource();

// get the indexes for lo_replace and for hi_replace
auto lo_replace_index = dictionary::detail::get_index(matched_view, lo_replace, stream);
auto hi_replace_index = dictionary::detail::get_index(matched_view, hi_replace, stream);
auto lo_replace_index =
dictionary::detail::get_index(matched_view, lo_replace, stream, default_mr);
auto hi_replace_index =
dictionary::detail::get_index(matched_view, hi_replace, stream, default_mr);

// get the closest indexes for lo and for hi
auto lo_index = dictionary::detail::get_insert_index(matched_view, lo, stream);
auto hi_index = dictionary::detail::get_insert_index(matched_view, hi, stream);
auto lo_index = dictionary::detail::get_insert_index(matched_view, lo, stream, default_mr);
auto hi_index = dictionary::detail::get_insert_index(matched_view, hi, stream, default_mr);

// call clamp with the scalar indexes and the matched indices
auto matched_indices = matched_view.get_indices_annotated();
Expand Down
7 changes: 4 additions & 3 deletions cpp/src/replace/replace.cu
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,10 @@ std::unique_ptr<cudf::column> replace_kernel_forwarder::operator()<cudf::diction
return cudf::dictionary::detail::add_keys(input, new_keys->view(), stream, mr);
}();
auto matched_view = cudf::dictionary_column_view(matched_input->view());
auto matched_values = cudf::dictionary::detail::set_keys(values, matched_view.keys(), stream);
auto matched_replacements =
cudf::dictionary::detail::set_keys(replacements, matched_view.keys(), stream);
auto matched_values = cudf::dictionary::detail::set_keys(
values, matched_view.keys(), stream, rmm::mr::get_current_device_resource());
auto matched_replacements = cudf::dictionary::detail::set_keys(
replacements, matched_view.keys(), stream, rmm::mr::get_current_device_resource());

auto indices_type = matched_view.indices().type();
auto new_indices = cudf::type_dispatcher<cudf::dispatch_storage_type>(
Expand Down
8 changes: 5 additions & 3 deletions cpp/src/search/contains_column.cu
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ std::unique_ptr<column> contains_column_dispatch::operator()<dictionary32>(
dictionary_column_view const haystack(haystack_in);
dictionary_column_view const needles(needles_in);
// first combine keys so both dictionaries have the same set
auto needles_matched = dictionary::detail::add_keys(needles, haystack.keys(), stream);
auto const needles_view = dictionary_column_view(needles_matched->view());
auto haystack_matched = dictionary::detail::set_keys(haystack, needles_view.keys(), stream);
auto needles_matched = dictionary::detail::add_keys(
needles, haystack.keys(), stream, rmm::mr::get_current_device_resource());
auto const needles_view = dictionary_column_view(needles_matched->view());
auto haystack_matched = dictionary::detail::set_keys(
haystack, needles_view.keys(), stream, rmm::mr::get_current_device_resource());
auto const haystack_view = dictionary_column_view(haystack_matched->view());

// now just use the indices for the contains
Expand Down
Loading