From 6547d962acde9c7f4091d89ac44da04b7ab5c409 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 21 Mar 2023 14:38:30 -0400 Subject: [PATCH] Remove default detail mrs: part5 (#12968) This is the fifth PR in a sequence removing default mr parameters in detail APIs. Contributes to https://github.com/rapidsai/cudf/issues/12944. Authors: - Vyas Ramasubramani (https://github.com/vyasr) Approvers: - MithunR (https://github.com/mythrocks) URL: https://github.com/rapidsai/cudf/pull/12968 --- cpp/include/cudf/detail/reshape.hpp | 18 +++--- cpp/include/cudf/io/detail/csv.hpp | 4 +- cpp/include/cudf/io/detail/tokenize_json.hpp | 2 +- cpp/include/cudf/lists/detail/combine.hpp | 20 +++---- .../cudf/lists/detail/set_operations.hpp | 54 +++++++++--------- cpp/src/copying/get_element.cu | 56 +++++++++---------- cpp/src/filling/fill.cu | 11 ++-- cpp/src/filling/sequence.cu | 11 ++-- cpp/src/io/csv/durations.hpp | 9 ++- cpp/src/io/json/json_column.cu | 3 +- cpp/src/lists/set_operations.cu | 7 ++- cpp/tests/io/json_tree.cpp | 20 +++---- cpp/tests/io/nested_json_test.cpp | 8 +-- 13 files changed, 105 insertions(+), 118 deletions(-) diff --git a/cpp/include/cudf/detail/reshape.hpp b/cpp/include/cudf/detail/reshape.hpp index ccffcbc61df..5ab53690a23 100644 --- a/cpp/include/cudf/detail/reshape.hpp +++ b/cpp/include/cudf/detail/reshape.hpp @@ -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. @@ -30,21 +30,19 @@ namespace detail { * * @param stream CUDA stream used for device memory operations and kernel launches */ -std::unique_ptr tile( - table_view const& input, - size_type count, - rmm::cuda_stream_view, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr
tile(table_view const& input, + size_type count, + rmm::cuda_stream_view, + rmm::mr::device_memory_resource* mr); /** * @copydoc cudf::interleave_columns * * @param stream CUDA stream used for device memory operations and kernel launches */ -std::unique_ptr interleave_columns( - table_view const& input, - rmm::cuda_stream_view, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr interleave_columns(table_view const& input, + rmm::cuda_stream_view, + rmm::mr::device_memory_resource* mr); } // namespace detail } // namespace cudf diff --git a/cpp/include/cudf/io/detail/csv.hpp b/cpp/include/cudf/io/detail/csv.hpp index 90d730338fc..9fdc7a47fb9 100644 --- a/cpp/include/cudf/io/detail/csv.hpp +++ b/cpp/include/cudf/io/detail/csv.hpp @@ -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. @@ -56,7 +56,7 @@ void write_csv(data_sink* sink, host_span column_names, csv_writer_options const& options, rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); + rmm::mr::device_memory_resource* mr); } // namespace csv } // namespace detail diff --git a/cpp/include/cudf/io/detail/tokenize_json.hpp b/cpp/include/cudf/io/detail/tokenize_json.hpp index b03dbd4fb70..4914f434c98 100644 --- a/cpp/include/cudf/io/detail/tokenize_json.hpp +++ b/cpp/include/cudf/io/detail/tokenize_json.hpp @@ -131,7 +131,7 @@ std::pair, rmm::device_uvector> ge device_span json_in, cudf::io::json_reader_options const& options, 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 diff --git a/cpp/include/cudf/lists/detail/combine.hpp b/cpp/include/cudf/lists/detail/combine.hpp index 9f28074173a..4bc45e48a9f 100644 --- a/cpp/include/cudf/lists/detail/combine.hpp +++ b/cpp/include/cudf/lists/detail/combine.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -27,22 +27,20 @@ namespace detail { * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr concatenate_rows( - table_view const& input, - concatenate_null_policy null_policy, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr concatenate_rows(table_view const& input, + concatenate_null_policy null_policy, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** * @copydoc cudf::lists::concatenate_list_elements * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr concatenate_list_elements( - column_view const& input, - concatenate_null_policy null_policy, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr concatenate_list_elements(column_view const& input, + concatenate_null_policy null_policy, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); } // namespace detail } // namespace lists diff --git a/cpp/include/cudf/lists/detail/set_operations.hpp b/cpp/include/cudf/lists/detail/set_operations.hpp index ef4255de430..1411c65448e 100644 --- a/cpp/include/cudf/lists/detail/set_operations.hpp +++ b/cpp/include/cudf/lists/detail/set_operations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-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. @@ -30,52 +30,48 @@ namespace cudf::lists::detail { * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr have_overlap( - lists_column_view const& lhs, - lists_column_view const& rhs, - null_equality nulls_equal, - nan_equality nans_equal, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr have_overlap(lists_column_view const& lhs, + lists_column_view const& rhs, + null_equality nulls_equal, + nan_equality nans_equal, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** * @copydoc cudf::list::intersect_distinct * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr intersect_distinct( - lists_column_view const& lhs, - lists_column_view const& rhs, - null_equality nulls_equal, - nan_equality nans_equal, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr intersect_distinct(lists_column_view const& lhs, + lists_column_view const& rhs, + null_equality nulls_equal, + nan_equality nans_equal, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** * @copydoc cudf::list::union_distinct * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr union_distinct( - lists_column_view const& lhs, - lists_column_view const& rhs, - null_equality nulls_equal, - nan_equality nans_equal, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr union_distinct(lists_column_view const& lhs, + lists_column_view const& rhs, + null_equality nulls_equal, + nan_equality nans_equal, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** * @copydoc cudf::list::difference_distinct * * @param stream CUDA stream used for device memory operations and kernel launches. */ -std::unique_ptr difference_distinct( - lists_column_view const& lhs, - lists_column_view const& rhs, - null_equality nulls_equal, - nan_equality nans_equal, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr difference_distinct(lists_column_view const& lhs, + lists_column_view const& rhs, + null_equality nulls_equal, + nan_equality nans_equal, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); /** @} */ // end of group } // namespace cudf::lists::detail diff --git a/cpp/src/copying/get_element.cu b/cpp/src/copying/get_element.cu index 5e76b4adbbe..cc12aaa1382 100644 --- a/cpp/src/copying/get_element.cu +++ b/cpp/src/copying/get_element.cu @@ -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. @@ -37,11 +37,10 @@ namespace { struct get_element_functor { template () && !is_fixed_point()>* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { auto s = make_fixed_width_scalar(data_type(type_to_id()), stream, mr); @@ -61,11 +60,10 @@ struct get_element_functor { } template >* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { auto device_col = column_device_view::create(input, stream); @@ -86,11 +84,10 @@ struct get_element_functor { } template >* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { auto dict_view = dictionary_column_view(input); auto indices_iter = detail::indexalator_factory::make_input_iterator(dict_view.indices()); @@ -122,11 +119,10 @@ struct get_element_functor { } template >* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { bool valid = is_element_valid_sync(input, index, stream); auto const child_col_idx = lists_column_view::child_column_index; @@ -147,11 +143,10 @@ struct get_element_functor { } template ()>* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { using Type = typename T::rep; @@ -178,11 +173,10 @@ struct get_element_functor { } template >* p = nullptr> - std::unique_ptr operator()( - column_view const& input, - size_type index, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(column_view const& input, + size_type index, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { bool valid = is_element_valid_sync(input, index, stream); auto row_contents = diff --git a/cpp/src/filling/fill.cu b/cpp/src/filling/fill.cu index ecd66f1b0c9..a747cc195ae 100644 --- a/cpp/src/filling/fill.cu +++ b/cpp/src/filling/fill.cu @@ -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. @@ -104,11 +104,10 @@ struct out_of_place_fill_range_dispatch { template () or cudf::is_fixed_point())> - std::unique_ptr operator()( - cudf::size_type begin, - cudf::size_type end, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()) + std::unique_ptr operator()(cudf::size_type begin, + cudf::size_type end, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { CUDF_EXPECTS(input.type() == value.type(), "Data type mismatch."); auto p_ret = std::make_unique(input, stream, mr); diff --git a/cpp/src/filling/sequence.cu b/cpp/src/filling/sequence.cu index 284e7c46347..b4bab369c61 100644 --- a/cpp/src/filling/sequence.cu +++ b/cpp/src/filling/sequence.cu @@ -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. @@ -134,11 +134,10 @@ std::unique_ptr sequence(size_type size, return type_dispatcher(init.type(), sequence_functor{}, size, init, step, stream, mr); } -std::unique_ptr 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 sequence(size_type size, + scalar const& init, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr) { CUDF_EXPECTS(size >= 0, "size must be >= 0"); CUDF_EXPECTS(is_numeric(init.type()), "init scalar type must be numeric"); diff --git a/cpp/src/io/csv/durations.hpp b/cpp/src/io/csv/durations.hpp index d42ddf3817c..ac925011c58 100644 --- a/cpp/src/io/csv/durations.hpp +++ b/cpp/src/io/csv/durations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, NVIDIA CORPORATION. + * Copyright (c) 2021-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. @@ -28,10 +28,9 @@ namespace io { namespace detail { namespace csv { -std::unique_ptr pandas_format_durations( - column_view const& durations, - rmm::cuda_stream_view stream, - rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); +std::unique_ptr pandas_format_durations(column_view const& durations, + rmm::cuda_stream_view stream, + rmm::mr::device_memory_resource* mr); } // namespace csv } // namespace detail diff --git a/cpp/src/io/json/json_column.cu b/cpp/src/io/json/json_column.cu index f4d65f37cdb..c937315969c 100644 --- a/cpp/src/io/json/json_column.cu +++ b/cpp/src/io/json/json_column.cu @@ -893,7 +893,8 @@ table_with_metadata device_parse_nested_json(device_span d_input, auto gpu_tree = [&]() { // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = + get_token_stream(d_input, options, stream, rmm::mr::get_current_device_resource()); // gpu tree generation return get_tree_representation( tokens_gpu, token_indices_gpu, stream, rmm::mr::get_current_device_resource()); diff --git a/cpp/src/lists/set_operations.cu b/cpp/src/lists/set_operations.cu index 8df99153d74..eb3ec5a8236 100644 --- a/cpp/src/lists/set_operations.cu +++ b/cpp/src/lists/set_operations.cu @@ -195,8 +195,11 @@ std::unique_ptr union_distinct(lists_column_view const& lhs, // Algorithm: `return distinct(concatenate_rows(lhs, rhs))`. - auto const union_col = lists::detail::concatenate_rows( - table_view{{lhs.parent(), rhs.parent()}}, concatenate_null_policy::NULLIFY_OUTPUT_ROW, stream); + auto const union_col = + lists::detail::concatenate_rows(table_view{{lhs.parent(), rhs.parent()}}, + concatenate_null_policy::NULLIFY_OUTPUT_ROW, + stream, + rmm::mr::get_current_device_resource()); return cudf::lists::detail::distinct( lists_column_view{union_col->view()}, nulls_equal, nans_equal, stream, mr); diff --git a/cpp/tests/io/json_tree.cpp b/cpp/tests/io/json_tree.cpp index 94a7c8edcf9..0ae0360c4d9 100644 --- a/cpp/tests/io/json_tree.cpp +++ b/cpp/tests/io/json_tree.cpp @@ -586,8 +586,8 @@ TEST_F(JsonTest, TreeRepresentation) cudf::io::json_reader_options const options{}; // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = - cudf::io::json::detail::get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream( + d_input, options, stream, rmm::mr::get_current_device_resource()); // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation( @@ -673,8 +673,8 @@ TEST_F(JsonTest, TreeRepresentation2) cudf::io::json_reader_options const options{}; // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = - cudf::io::json::detail::get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream( + d_input, options, stream, rmm::mr::get_current_device_resource()); // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation( @@ -747,8 +747,8 @@ TEST_F(JsonTest, TreeRepresentation3) options.enable_lines(true); // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = - cudf::io::json::detail::get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream( + d_input, options, stream, rmm::mr::get_current_device_resource()); // Get the JSON's tree representation auto gpu_tree = cuio_json::detail::get_tree_representation( @@ -772,8 +772,8 @@ TEST_F(JsonTest, TreeRepresentationError) cudf::io::json_reader_options const options{}; // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = - cudf::io::json::detail::get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream( + d_input, options, stream, rmm::mr::get_current_device_resource()); // Get the JSON's tree representation // This JSON is invalid and will raise an exception. @@ -855,8 +855,8 @@ TEST_P(JsonTreeTraversalTest, CPUvsGPUTraversal) static_cast(d_scalar.size())}; // Parse the JSON and get the token stream - const auto [tokens_gpu, token_indices_gpu] = - cudf::io::json::detail::get_token_stream(d_input, options, stream); + const auto [tokens_gpu, token_indices_gpu] = cudf::io::json::detail::get_token_stream( + d_input, options, stream, rmm::mr::get_current_device_resource()); // host tree generation auto cpu_tree = get_tree_representation_cpu(tokens_gpu, token_indices_gpu, options, stream); bool const is_array_of_arrays = diff --git a/cpp/tests/io/nested_json_test.cpp b/cpp/tests/io/nested_json_test.cpp index 8af530b0002..5b797a00ca1 100644 --- a/cpp/tests/io/nested_json_test.cpp +++ b/cpp/tests/io/nested_json_test.cpp @@ -262,8 +262,8 @@ TEST_F(JsonTest, TokenStream) cudf::device_span{d_scalar.data(), static_cast(d_scalar.size())}; // Parse the JSON and get the token stream - auto [d_tokens_gpu, d_token_indices_gpu] = - cuio_json::detail::get_token_stream(d_input, default_options, stream); + auto [d_tokens_gpu, d_token_indices_gpu] = cuio_json::detail::get_token_stream( + d_input, default_options, stream, rmm::mr::get_current_device_resource()); // Copy back the number of tokens that were written thrust::host_vector const tokens_gpu = cudf::detail::make_host_vector_async(d_tokens_gpu, stream); @@ -398,8 +398,8 @@ TEST_F(JsonTest, TokenStream2) cudf::device_span{d_scalar.data(), static_cast(d_scalar.size())}; // Parse the JSON and get the token stream - auto [d_tokens_gpu, d_token_indices_gpu] = - cuio_json::detail::get_token_stream(d_input, default_options, stream); + auto [d_tokens_gpu, d_token_indices_gpu] = cuio_json::detail::get_token_stream( + d_input, default_options, stream, rmm::mr::get_current_device_resource()); // Copy back the number of tokens that were written thrust::host_vector const tokens_gpu = cudf::detail::make_host_vector_async(d_tokens_gpu, stream);