Skip to content

Commit

Permalink
Remove default detail mrs: part3 (#12966)
Browse files Browse the repository at this point in the history
This is the third PR in a sequence removing default mr parameters in detail APIs. Contributes to #12944.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)

URL: #12966
  • Loading branch information
vyasr authored Mar 22, 2023
1 parent f567cf5 commit b2a65e8
Show file tree
Hide file tree
Showing 25 changed files with 222 additions and 217 deletions.
35 changes: 25 additions & 10 deletions cpp/benchmarks/common/generate_input.cu
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,12 @@ std::unique_ptr<cudf::column> create_random_column(data_profile const& profile,
null_mask.begin());
}

auto [result_bitmask, null_count] = cudf::detail::valid_if(
null_mask.begin(), null_mask.end(), thrust::identity<bool>{}, cudf::get_default_stream());
auto [result_bitmask, null_count] =
cudf::detail::valid_if(null_mask.begin(),
null_mask.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());

return std::make_unique<cudf::column>(
dtype,
Expand Down Expand Up @@ -509,8 +513,12 @@ std::unique_ptr<cudf::column> create_random_utf8_string_column(data_profile cons
thrust::make_zip_iterator(offsets.begin(), offsets.begin() + 1),
num_rows,
string_generator{chars.data(), engine});
auto [result_bitmask, null_count] = cudf::detail::valid_if(
null_mask.begin(), null_mask.end() - 1, thrust::identity<bool>{}, cudf::get_default_stream());
auto [result_bitmask, null_count] =
cudf::detail::valid_if(null_mask.begin(),
null_mask.end() - 1,
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
return cudf::make_strings_column(
num_rows,
std::move(offsets),
Expand Down Expand Up @@ -628,8 +636,11 @@ std::unique_ptr<cudf::column> create_random_column<cudf::struct_view>(data_profi
auto [null_mask, null_count] = [&]() {
if (profile.get_null_probability().has_value()) {
auto valids = valid_dist(engine, num_rows);
return cudf::detail::valid_if(
valids.begin(), valids.end(), thrust::identity<bool>{}, cudf::get_default_stream());
return cudf::detail::valid_if(valids.begin(),
valids.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
}
return std::pair<rmm::device_buffer, cudf::size_type>{};
}();
Expand Down Expand Up @@ -712,9 +723,12 @@ std::unique_ptr<cudf::column> create_random_column<cudf::list_view>(data_profile
auto offsets_column = std::make_unique<cudf::column>(
cudf::data_type{cudf::type_id::INT32}, num_rows + 1, offsets.release());

auto [null_mask, null_count] = cudf::detail::valid_if(
valids.begin(), valids.end(), thrust::identity<bool>{}, cudf::get_default_stream());
list_column = cudf::make_lists_column(
auto [null_mask, null_count] = cudf::detail::valid_if(valids.begin(),
valids.end(),
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
list_column = cudf::make_lists_column(
num_rows,
std::move(offsets_column),
std::move(current_child_column),
Expand Down Expand Up @@ -840,7 +854,8 @@ std::pair<rmm::device_buffer, cudf::size_type> create_random_null_mask(
return cudf::detail::valid_if(thrust::make_counting_iterator<cudf::size_type>(0),
thrust::make_counting_iterator<cudf::size_type>(size),
bool_generator{seed, 1.0 - *null_probability},
cudf::get_default_stream());
cudf::get_default_stream(),
rmm::mr::get_current_device_resource());
}
}

Expand Down
7 changes: 5 additions & 2 deletions cpp/benchmarks/join/join_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ void BM_join(state_type& state, Join JoinFunc)
// roughly 75% nulls
auto validity =
thrust::make_transform_iterator(thrust::make_counting_iterator(0), null75_generator{});
return cudf::detail::valid_if(
validity, validity + size, thrust::identity<bool>{}, cudf::get_default_stream())
return cudf::detail::valid_if(validity,
validity + size,
thrust::identity<bool>{},
cudf::get_default_stream(),
rmm::mr::get_current_device_resource())
.first;
};

Expand Down
13 changes: 6 additions & 7 deletions cpp/include/cudf/detail/round.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-2023, 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 @@ -31,12 +31,11 @@ namespace detail {
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> round(
column_view const& input,
int32_t decimal_places,
rounding_method method,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> round(column_view const& input,
int32_t decimal_places,
rounding_method method,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace cudf
15 changes: 7 additions & 8 deletions cpp/include/cudf/detail/scatter.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-2023, 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 @@ -386,13 +386,12 @@ struct column_scatterer_impl<struct_view> {
* @return Result of scattering values from source to target
*/
template <typename MapIterator>
std::unique_ptr<table> scatter(
table_view const& source,
MapIterator scatter_map_begin,
MapIterator scatter_map_end,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource())
std::unique_ptr<table> scatter(table_view const& source,
MapIterator scatter_map_begin,
MapIterator scatter_map_end,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();

Expand Down
48 changes: 22 additions & 26 deletions cpp/include/cudf/detail/scatter.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
* Copyright (c) 2019-2023, 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 @@ -59,25 +59,23 @@ namespace detail {
* @param mr Device memory resource used to allocate the returned table's device memory
* @return Result of scattering values from source to target
*/
std::unique_ptr<table> scatter(
table_view const& source,
column_view const& scatter_map,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<table> scatter(table_view const& source,
column_view const& scatter_map,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::detail::scatter(table_view const&,column_view const&,table_view
* const&,bool,rmm::cuda_stream_view,rmm::mr::device_memory_resource*)
*
* @throws cudf::logic_error if `scatter_map` span size is larger than max of `size_type`.
*/
std::unique_ptr<table> scatter(
table_view const& source,
device_span<size_type const> const scatter_map,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<table> scatter(table_view const& source,
device_span<size_type const> const scatter_map,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @brief Scatters a row of scalar values into a copy of the target table
Expand Down Expand Up @@ -108,12 +106,11 @@ std::unique_ptr<table> scatter(
* @param mr Device memory resource used to allocate the returned table's device memory
* @return Result of scattering values from source to target
*/
std::unique_ptr<table> scatter(
std::vector<std::reference_wrapper<const scalar>> const& source,
column_view const& indices,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<table> scatter(std::vector<std::reference_wrapper<const scalar>> const& source,
column_view const& indices,
table_view const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::boolean_mask_scatter(
Expand All @@ -123,12 +120,11 @@ std::unique_ptr<table> scatter(
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<table> boolean_mask_scatter(
table_view const& source,
table_view const& target,
column_view const& boolean_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<table> boolean_mask_scatter(table_view const& source,
table_view const& target,
column_view const& boolean_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::boolean_mask_scatter(
Expand All @@ -144,7 +140,7 @@ std::unique_ptr<table> boolean_mask_scatter(
table_view const& target,
column_view const& boolean_mask,
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 cudf
15 changes: 7 additions & 8 deletions cpp/include/cudf/detail/search.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-2023, 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 @@ -89,12 +89,11 @@ std::unique_ptr<column> contains(column_view const& haystack,
* @param mr Device memory resource used to allocate the returned vector
* @return A vector of bools indicating if each row in `needles` has matching rows in `haystack`
*/
rmm::device_uvector<bool> contains(
table_view const& haystack,
table_view const& needles,
null_equality compare_nulls,
nan_equality compare_nans,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
rmm::device_uvector<bool> contains(table_view const& haystack,
table_view const& needles,
null_equality compare_nulls,
nan_equality compare_nans,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace cudf::detail
33 changes: 15 additions & 18 deletions cpp/include/cudf/detail/sequence.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-2023, 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 @@ -32,12 +32,11 @@ namespace detail {
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> sequence(
size_type size,
scalar const& init,
scalar const& step,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> sequence(size_type size,
scalar const& init,
scalar const& step,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::sequence(size_type size, scalar const& init,
Expand All @@ -46,11 +45,10 @@ std::unique_ptr<column> sequence(
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> sequence(
size_type size,
scalar const& init,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<column> sequence(size_type size,
scalar const& init,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

/**
* @copydoc cudf::calendrical_month_sequence(size_type size,
Expand All @@ -60,12 +58,11 @@ std::unique_ptr<column> sequence(
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<cudf::column> calendrical_month_sequence(
size_type size,
scalar const& init,
size_type months,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());
std::unique_ptr<cudf::column> calendrical_month_sequence(size_type size,
scalar const& init,
size_type months,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace cudf
Loading

0 comments on commit b2a65e8

Please sign in to comment.