From d11a8bb3d34101fabc32f469ea8331f6e644628b Mon Sep 17 00:00:00 2001 From: niranda perera Date: Thu, 6 Aug 2026 17:44:06 -0700 Subject: [PATCH 01/17] Port column wrappers to accept memory_resources and stream Adds defaulted stream and memory_resources parameters to cudftestutil column wrappers and helpers so tests can control allocation and stream routing. Includes MR tests for wrappers and timestamp generators. Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 825 +++++++++++++----- .../cudf_test/memory_resource_utilities.hpp | 24 +- cpp/include/cudf_test/timestamp_utilities.cuh | 18 +- cpp/tests/utilities/column_utilities.cu | 5 +- .../utilities_tests/column_wrapper_tests.cpp | 261 +++++- cpp/tests/wrappers/timestamps_test.cu | 22 + 6 files changed, 922 insertions(+), 233 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index f0a7a64e3d29..7a18a8058720 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -147,21 +148,26 @@ struct fixed_width_type_converter { * @tparam InputIterator Iterator type for `begin` and `end` * @param begin Beginning of the sequence of elements * @param end End of the sequence of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned buffer * @return rmm::device_buffer Buffer containing all elements in the range `[begin,end)` */ template ()>* = nullptr> -rmm::device_buffer make_elements(InputIterator begin, InputIterator end) +rmm::device_buffer make_elements( + InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { static_assert(cudf::is_fixed_width(), "Unexpected non-fixed width type."); auto transformer = fixed_width_type_converter{}; auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{ - elements.data(), size * sizeof(ElementTo), cudf::test::get_default_stream()}; + return rmm::device_buffer{elements.data(), size * sizeof(ElementTo), stream, mr.get_output_mr()}; } // The two signatures below are identical to the above overload apart from @@ -176,6 +182,8 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) * @tparam InputIterator Iterator type for `begin` and `end` * @param begin Beginning of the sequence of elements * @param end End of the sequence of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned buffer * @return rmm::device_buffer Buffer containing all elements in the range `[begin,end)` */ template () and cudf::is_fixed_point()>* = nullptr> -rmm::device_buffer make_elements(InputIterator begin, InputIterator end) +rmm::device_buffer make_elements( + InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { using RepType = typename ElementTo::rep; auto transformer = fixed_width_type_converter{}; auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{ - elements.data(), size * sizeof(RepType), cudf::test::get_default_stream()}; + return rmm::device_buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; } /** @@ -202,6 +213,8 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) * @tparam InputIterator Iterator type for `begin` and `end` * @param begin Beginning of the sequence of elements * @param end End of the sequence of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned buffer * @return rmm::device_buffer Buffer containing all elements in the range `[begin,end)` */ template () and cudf::is_fixed_point()>* = nullptr> -rmm::device_buffer make_elements(InputIterator begin, InputIterator end) +rmm::device_buffer make_elements( + InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { using namespace numeric; using RepType = typename ElementTo::rep; @@ -221,8 +238,7 @@ rmm::device_buffer make_elements(InputIterator begin, InputIterator end) auto transformer_begin = thrust::make_transform_iterator(begin, to_rep); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transformer_begin, transformer_begin + size); - return rmm::device_buffer{ - elements.data(), size * sizeof(RepType), cudf::test::get_default_stream()}; + return rmm::device_buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; } //! @endcond @@ -269,17 +285,23 @@ std::pair, cudf::size_type> make_null_mask_vector(Vali * @tparam ValidityIterator * @param begin The beginning of the validity indicator sequence * @param end The end of the validity indicator sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned buffer * @return rmm::device_buffer Contains a bitmask where bits are set for every * element in `[begin,end)` that evaluated to `true`. */ template -std::pair make_null_mask(ValidityIterator begin, - ValidityIterator end) +std::pair make_null_mask( + ValidityIterator begin, + ValidityIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { auto [null_mask, null_count] = make_null_mask_vector(begin, end); auto d_mask = rmm::device_buffer{null_mask.data(), cudf::bitmask_allocation_size_bytes(cudf::distance(begin, end)), - cudf::test::get_default_stream()}; + stream, + mr.get_output_mr()}; return {std::move(d_mask), null_count}; } @@ -328,17 +350,23 @@ template class fixed_width_column_wrapper : public detail::column_wrapper { public: /** - * @brief Default constructor initializes an empty column with proper dtype + * @brief Initializes an empty column with proper dtype + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - fixed_width_column_wrapper() : column_wrapper{} + explicit fixed_width_column_wrapper( + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { std::vector empty; - wrapped.reset( - new cudf::column{cudf::data_type{cudf::type_to_id()}, - 0, - detail::make_elements(empty.begin(), empty.end()), - rmm::device_buffer{}, - 0}); + wrapped.reset(new cudf::column{ + cudf::data_type{cudf::type_to_id()}, + 0, + detail::make_elements(empty.begin(), empty.end(), stream, mr), + rmm::device_buffer{}, + 0}); } /** @@ -358,16 +386,23 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - fixed_width_column_wrapper(InputIterator begin, InputIterator end) : column_wrapper{} + fixed_width_column_wrapper(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { auto const size = cudf::distance(begin, end); - wrapped.reset(new cudf::column{cudf::data_type{cudf::type_to_id()}, - size, - detail::make_elements(begin, end), - rmm::device_buffer{}, - 0}); + wrapped.reset( + new cudf::column{cudf::data_type{cudf::type_to_id()}, + size, + detail::make_elements(begin, end, stream, mr), + rmm::device_buffer{}, + 0}); } /** @@ -392,18 +427,28 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - fixed_width_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v) + template < + typename InputIterator, + typename ValidityIterator, + std::enable_if_t>* = nullptr> + fixed_width_column_wrapper(InputIterator begin, + InputIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { auto const size = cudf::distance(begin, end); - auto [null_mask, null_count] = detail::make_null_mask(v, v + size); - wrapped.reset(new cudf::column{cudf::data_type{cudf::type_to_id()}, - size, - detail::make_elements(begin, end), - std::move(null_mask), - null_count}); + auto [null_mask, null_count] = detail::make_null_mask(v, v + size, stream, mr); + wrapped.reset( + new cudf::column{cudf::data_type{cudf::type_to_id()}, + size, + detail::make_elements(begin, end, stream, mr), + std::move(null_mask), + null_count}); } /** @@ -417,10 +462,14 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - fixed_width_column_wrapper(std::initializer_list elements) - : fixed_width_column_wrapper(std::cbegin(elements), std::cend(elements)) + fixed_width_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_width_column_wrapper(std::cbegin(elements), std::cend(elements), stream, mr) { } @@ -440,11 +489,16 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * * @param elements The list of elements * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_width_column_wrapper(std::initializer_list elements, - std::initializer_list validity) - : fixed_width_column_wrapper(std::cbegin(elements), std::cend(elements), std::cbegin(validity)) + std::initializer_list validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_width_column_wrapper( + std::cbegin(elements), std::cend(elements), std::cbegin(validity), stream, mr) { } @@ -464,10 +518,18 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * convertible to `bool` * @param element_list The list of elements * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - fixed_width_column_wrapper(std::initializer_list element_list, ValidityIterator v) - : fixed_width_column_wrapper(std::cbegin(element_list), std::cend(element_list), v) + template < + typename ValidityIterator, + typename ElementFrom, + std::enable_if_t>* = nullptr> + fixed_width_column_wrapper(std::initializer_list element_list, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_width_column_wrapper(std::cbegin(element_list), std::cend(element_list), v, stream, mr) { } @@ -488,12 +550,16 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_width_column_wrapper(InputIterator begin, InputIterator end, - std::initializer_list const& validity) - : fixed_width_column_wrapper(begin, end, std::cbegin(validity)) + std::initializer_list const& validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_width_column_wrapper(begin, end, std::cbegin(validity), stream, mr) { } @@ -513,16 +579,21 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of pairs of element and validity booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - fixed_width_column_wrapper(std::initializer_list> elements) + fixed_width_column_wrapper(std::initializer_list> elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { auto begin = thrust::make_transform_iterator(elements.begin(), [](auto const& e) { return e.first; }); auto end = begin + elements.size(); auto v = thrust::make_transform_iterator(elements.begin(), [](auto const& e) { return e.second; }); - wrapped = fixed_width_column_wrapper(begin, end, v).release(); + wrapped = + fixed_width_column_wrapper(begin, end, v, stream, mr).release(); } }; @@ -549,11 +620,15 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_point_column_wrapper(FixedPointRepIterator begin, FixedPointRepIterator end, - numeric::scale_type scale) + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { CUDF_EXPECTS(numeric::is_supported_representation_type(), "not valid representation type"); @@ -566,7 +641,7 @@ class fixed_point_column_wrapper : public detail::column_wrapper { wrapped.reset(new cudf::column{ data_type, size, - rmm::device_buffer{elements.data(), size * sizeof(Rep), cudf::test::get_default_stream()}, + rmm::device_buffer{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}, rmm::device_buffer{}, 0}); } @@ -582,9 +657,14 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * * @param values The initializer list of already shifted values * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - fixed_point_column_wrapper(std::initializer_list values, numeric::scale_type scale) - : fixed_point_column_wrapper(std::cbegin(values), std::cend(values), scale) + fixed_point_column_wrapper(std::initializer_list values, + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_point_column_wrapper(std::cbegin(values), std::cend(values), scale, stream, mr) { } @@ -614,12 +694,16 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * @param end The end of the sequence of elements * @param v The beginning of the sequence of validity indicators * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_point_column_wrapper(FixedPointRepIterator begin, FixedPointRepIterator end, ValidityIterator v, - numeric::scale_type scale) + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { CUDF_EXPECTS(numeric::is_supported_representation_type(), "not valid representation type"); @@ -628,11 +712,11 @@ class fixed_point_column_wrapper : public detail::column_wrapper { auto const elements = thrust::host_vector(begin, end); auto const id = type_to_id>(); auto const data_type = cudf::data_type{id, static_cast(scale)}; - auto [null_mask, null_count] = detail::make_null_mask(v, v + size); + auto [null_mask, null_count] = detail::make_null_mask(v, v + size, stream, mr); wrapped.reset(new cudf::column{ data_type, size, - rmm::device_buffer{elements.data(), size * sizeof(Rep), cudf::test::get_default_stream()}, + rmm::device_buffer{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}, std::move(null_mask), null_count}); } @@ -653,12 +737,16 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * @param elements The initializer list of elements * @param validity The initializer list of validity indicator booleans * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ fixed_point_column_wrapper(std::initializer_list elements, std::initializer_list validity, - numeric::scale_type scale) + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : fixed_point_column_wrapper( - std::cbegin(elements), std::cend(elements), std::cbegin(validity), scale) + std::cbegin(elements), std::cend(elements), std::cbegin(validity), scale, stream, mr) { } @@ -679,12 +767,17 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * @param element_list The initializer list of elements * @param v The beginning of the sequence of validity indicators * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_point_column_wrapper(std::initializer_list element_list, ValidityIterator v, - numeric::scale_type scale) - : fixed_point_column_wrapper(std::cbegin(element_list), std::cend(element_list), v, scale) + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_point_column_wrapper( + std::cbegin(element_list), std::cend(element_list), v, scale, stream, mr) { } @@ -707,13 +800,17 @@ class fixed_point_column_wrapper : public detail::column_wrapper { * @param end The end of the sequence of elements * @param validity The initializer list of validity indicator booleans * @param scale The scale of the elements in the column + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template fixed_point_column_wrapper(FixedPointRepIterator begin, FixedPointRepIterator end, std::initializer_list const& validity, - numeric::scale_type scale) - : fixed_point_column_wrapper(begin, end, std::cbegin(validity), scale) + numeric::scale_type scale, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : fixed_point_column_wrapper(begin, end, std::cbegin(validity), scale, stream, mr) { } }; @@ -726,7 +823,18 @@ class strings_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty column of strings */ - strings_column_wrapper() : strings_column_wrapper(std::initializer_list{}) {} + /** + * @brief Initializes an empty strings column on the specified resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + explicit strings_column_wrapper( + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : strings_column_wrapper(std::initializer_list{}, stream, mr) + { + } /** * @brief Construct a non-nullable column of strings from the range @@ -747,9 +855,15 @@ class strings_column_wrapper : public detail::column_wrapper { * dereferencing a `StringsIterator`. * @param begin The beginning of the sequence * @param end The end of the sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - strings_column_wrapper(StringsIterator begin, StringsIterator end) : column_wrapper{} + strings_column_wrapper(StringsIterator begin, + StringsIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { size_type num_strings = std::distance(begin, end); if (num_strings == 0) { @@ -758,11 +872,9 @@ class strings_column_wrapper : public detail::column_wrapper { } auto all_valid = cuda::make_constant_iterator(true); auto [chars, offsets] = detail::make_chars_and_offsets(begin, end, all_valid); - auto d_chars = cudf::detail::make_device_uvector_async( - chars, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref()); + auto d_chars = cudf::detail::make_device_uvector_async(chars, stream, mr.get_output_mr()); auto d_offsets = std::make_unique( - cudf::detail::make_device_uvector( - offsets, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref()), + cudf::detail::make_device_uvector(offsets, stream, mr.get_output_mr()), rmm::device_buffer{}, 0); wrapped = @@ -796,9 +908,18 @@ class strings_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence * @param end The end of the sequence * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - strings_column_wrapper(StringsIterator begin, StringsIterator end, ValidityIterator v) + template < + typename StringsIterator, + typename ValidityIterator, + std::enable_if_t>* = nullptr> + strings_column_wrapper(StringsIterator begin, + StringsIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { size_type num_strings = std::distance(begin, end); @@ -808,16 +929,13 @@ class strings_column_wrapper : public detail::column_wrapper { } auto [chars, offsets] = detail::make_chars_and_offsets(begin, end, v); auto [null_mask, null_count] = detail::make_null_mask_vector(v, v + num_strings); - auto d_chars = cudf::detail::make_device_uvector_async( - chars, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref()); + auto d_chars = cudf::detail::make_device_uvector_async(chars, stream, mr.get_output_mr()); auto d_offsets = std::make_unique( - cudf::detail::make_device_uvector_async( - offsets, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref()), + cudf::detail::make_device_uvector_async(offsets, stream, mr.get_output_mr()), rmm::device_buffer{}, 0); - auto d_bitmask = cudf::detail::make_device_uvector( - null_mask, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref()); - wrapped = cudf::make_strings_column( + auto d_bitmask = cudf::detail::make_device_uvector(null_mask, stream, mr.get_output_mr()); + wrapped = cudf::make_strings_column( num_strings, std::move(d_offsets), d_chars.release(), null_count, d_bitmask.release()); } @@ -832,9 +950,13 @@ class strings_column_wrapper : public detail::column_wrapper { * @endcode * * @param strings The list of strings + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - strings_column_wrapper(std::initializer_list strings) - : strings_column_wrapper(std::cbegin(strings), std::cend(strings)) + strings_column_wrapper(std::initializer_list strings, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : strings_column_wrapper(std::cbegin(strings), std::cend(strings), stream, mr) { } @@ -855,10 +977,17 @@ class strings_column_wrapper : public detail::column_wrapper { * convertible to `bool` * @param strings The list of strings * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - strings_column_wrapper(std::initializer_list strings, ValidityIterator v) - : strings_column_wrapper(std::cbegin(strings), std::cend(strings), v) + template < + typename ValidityIterator, + std::enable_if_t>* = nullptr> + strings_column_wrapper(std::initializer_list strings, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : strings_column_wrapper(std::cbegin(strings), std::cend(strings), v, stream, mr) { } @@ -876,10 +1005,15 @@ class strings_column_wrapper : public detail::column_wrapper { * * @param strings The list of strings * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ strings_column_wrapper(std::initializer_list strings, - std::initializer_list validity) - : strings_column_wrapper(std::cbegin(strings), std::cend(strings), std::cbegin(validity)) + std::initializer_list validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : strings_column_wrapper( + std::cbegin(strings), std::cend(strings), std::cbegin(validity), stream, mr) { } @@ -902,15 +1036,19 @@ class strings_column_wrapper : public detail::column_wrapper { * @endcode * * @param strings The list of pairs of strings and validity booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - strings_column_wrapper(std::initializer_list> strings) + strings_column_wrapper(std::initializer_list> strings, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { auto begin = thrust::make_transform_iterator(strings.begin(), [](auto const& s) { return s.first; }); auto end = begin + strings.size(); auto v = thrust::make_transform_iterator(strings.begin(), [](auto const& s) { return s.second; }); - wrapped = strings_column_wrapper(begin, end, v).release(); + wrapped = strings_column_wrapper(begin, end, v, stream, mr).release(); } }; @@ -933,8 +1071,18 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty column with dictionary type. */ - dictionary_column_wrapper() : column_wrapper{} + /** + * @brief Initializes an empty dictionary column on the specified resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + explicit dictionary_column_wrapper( + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { + static_cast(mr); wrapped = cudf::make_empty_column(cudf::type_id::DICTIONARY32); } @@ -956,15 +1104,21 @@ class dictionary_column_wrapper : public detail::column_wrapper { * * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - dictionary_column_wrapper(InputIterator begin, InputIterator end) : column_wrapper{} + dictionary_column_wrapper(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { - wrapped = - cudf::dictionary::encode(fixed_width_column_wrapper(begin, end), - cudf::data_type{type_id::INT32}, - cudf::test::get_default_stream(), - cudf::get_current_device_resource_ref()); + wrapped = cudf::dictionary::encode(fixed_width_column_wrapper( + begin, end, stream, mr.get_temporary_mr()), + cudf::data_type{type_id::INT32}, + stream, + mr.get_output_mr()); } /** @@ -991,15 +1145,25 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - dictionary_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v) + template < + typename InputIterator, + typename ValidityIterator, + std::enable_if_t>* = nullptr> + dictionary_column_wrapper(InputIterator begin, + InputIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { - wrapped = cudf::dictionary::encode( - fixed_width_column_wrapper(begin, end, v), - cudf::data_type{type_id::INT32}, - cudf::test::get_default_stream()); + wrapped = cudf::dictionary::encode(fixed_width_column_wrapper( + begin, end, v, stream, mr.get_temporary_mr()), + cudf::data_type{type_id::INT32}, + stream, + mr.get_output_mr()); } /** @@ -1014,10 +1178,14 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - dictionary_column_wrapper(std::initializer_list elements) - : dictionary_column_wrapper(std::cbegin(elements), std::cend(elements)) + dictionary_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(std::cbegin(elements), std::cend(elements), stream, mr) { } @@ -1038,11 +1206,16 @@ class dictionary_column_wrapper : public detail::column_wrapper { * * @param elements The list of elements * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template dictionary_column_wrapper(std::initializer_list elements, - std::initializer_list validity) - : dictionary_column_wrapper(std::cbegin(elements), std::cend(elements), std::cbegin(validity)) + std::initializer_list validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper( + std::cbegin(elements), std::cend(elements), std::cbegin(validity), stream, mr) { } @@ -1063,10 +1236,18 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @tparam ValidityIterator Dereferencing a ValidityIterator must be convertible to `bool` * @param element_list The list of elements * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - dictionary_column_wrapper(std::initializer_list element_list, ValidityIterator v) - : dictionary_column_wrapper(std::cbegin(element_list), std::cend(element_list), v) + template < + typename ValidityIterator, + typename ElementFrom, + std::enable_if_t>* = nullptr> + dictionary_column_wrapper(std::initializer_list element_list, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(std::cbegin(element_list), std::cend(element_list), v, stream, mr) { } @@ -1089,12 +1270,16 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence of elements * @param end The end of the sequence of elements * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template dictionary_column_wrapper(InputIterator begin, InputIterator end, - std::initializer_list const& validity) - : dictionary_column_wrapper(begin, end, std::cbegin(validity)) + std::initializer_list const& validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(begin, end, std::cbegin(validity), stream, mr) { } }; @@ -1136,7 +1321,18 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty dictionary column of strings */ - dictionary_column_wrapper() : dictionary_column_wrapper(std::initializer_list{}) {} + /** + * @brief Initializes an empty string dictionary column on the specified resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + explicit dictionary_column_wrapper( + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(std::initializer_list{}, stream, mr) + { + } /** * @brief Construct a non-nullable dictionary column of strings from the range @@ -1157,14 +1353,21 @@ class dictionary_column_wrapper : public detail::column_wrapper { * dereferencing a `StringsIterator`. * @param begin The beginning of the sequence * @param end The end of the sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template - dictionary_column_wrapper(StringsIterator begin, StringsIterator end) : column_wrapper{} + dictionary_column_wrapper(StringsIterator begin, + StringsIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { - wrapped = cudf::dictionary::encode(strings_column_wrapper(begin, end), - cudf::data_type{type_id::INT32}, - cudf::test::get_default_stream(), - cudf::get_current_device_resource_ref()); + wrapped = + cudf::dictionary::encode(strings_column_wrapper(begin, end, stream, mr.get_temporary_mr()), + cudf::data_type{type_id::INT32}, + stream, + mr.get_output_mr()); } /** @@ -1194,14 +1397,25 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param begin The beginning of the sequence * @param end The end of the sequence * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - dictionary_column_wrapper(StringsIterator begin, StringsIterator end, ValidityIterator v) + template < + typename StringsIterator, + typename ValidityIterator, + std::enable_if_t>* = nullptr> + dictionary_column_wrapper(StringsIterator begin, + StringsIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { - wrapped = cudf::dictionary::encode(strings_column_wrapper(begin, end, v), - cudf::data_type{type_id::INT32}, - cudf::test::get_default_stream()); + wrapped = + 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()); } /** @@ -1215,9 +1429,13 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @endcode * * @param strings The list of strings + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - dictionary_column_wrapper(std::initializer_list strings) - : dictionary_column_wrapper(std::cbegin(strings), std::cend(strings)) + dictionary_column_wrapper(std::initializer_list strings, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(std::cbegin(strings), std::cend(strings), stream, mr) { } @@ -1238,10 +1456,17 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @tparam ValidityIterator Dereferencing a ValidityIterator must be convertible to `bool` * @param strings The list of strings * @param v The beginning of the sequence of validity indicators + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template - dictionary_column_wrapper(std::initializer_list strings, ValidityIterator v) - : dictionary_column_wrapper(std::cbegin(strings), std::cend(strings), v) + template < + typename ValidityIterator, + std::enable_if_t>* = nullptr> + dictionary_column_wrapper(std::initializer_list strings, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper(std::cbegin(strings), std::cend(strings), v, stream, mr) { } @@ -1259,10 +1484,15 @@ class dictionary_column_wrapper : public detail::column_wrapper { * * @param strings The list of strings * @param validity The list of validity indicator booleans + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ dictionary_column_wrapper(std::initializer_list strings, - std::initializer_list validity) - : dictionary_column_wrapper(std::cbegin(strings), std::cend(strings), std::cbegin(validity)) + std::initializer_list validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : dictionary_column_wrapper( + std::cbegin(strings), std::cend(strings), std::cbegin(validity), stream, mr) { } }; @@ -1322,12 +1552,19 @@ class lists_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template ()>* = nullptr> - lists_column_wrapper(std::initializer_list elements) : column_wrapper{} + lists_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(elements).release()); + cudf::test::fixed_width_column_wrapper(elements, stream, mr).release(), + stream, + mr); } /** @@ -1344,14 +1581,22 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param begin Beginning of the sequence * @param end End of the sequence + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template ()>* = nullptr> - lists_column_wrapper(InputIterator begin, InputIterator end) : column_wrapper{} + lists_column_wrapper(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(begin, end).release()); + cudf::test::fixed_width_column_wrapper(begin, end, stream, mr).release(), + stream, + mr); } /** @@ -1368,15 +1613,24 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param elements The list of elements * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> - lists_column_wrapper(std::initializer_list elements, ValidityIterator v) + template < + typename Element = T, + typename ValidityIterator, + std::enable_if_t() && + !std::is_convertible_v>* = nullptr> + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(elements, v).release()); + cudf::test::fixed_width_column_wrapper(elements, v, stream, mr).release(), + stream, + mr); } /** @@ -1395,16 +1649,27 @@ class lists_column_wrapper : public detail::column_wrapper { * @param begin Beginning of the sequence * @param end End of the sequence * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template ()>* = nullptr> - lists_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v) + template < + typename Element = T, + typename InputIterator, + typename ValidityIterator, + std::enable_if_t() && + !std::is_convertible_v>* = nullptr> + lists_column_wrapper(InputIterator begin, + InputIterator end, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { build_from_non_nested( - cudf::test::fixed_width_column_wrapper(begin, end, v).release()); + cudf::test::fixed_width_column_wrapper(begin, end, v, stream, mr) + .release(), + stream, + mr); } /** @@ -1419,13 +1684,20 @@ class lists_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template >* = nullptr> - lists_column_wrapper(std::initializer_list elements) : column_wrapper{} + lists_column_wrapper(std::initializer_list elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { build_from_non_nested( - cudf::test::strings_column_wrapper(elements.begin(), elements.end()).release()); + cudf::test::strings_column_wrapper(elements.begin(), elements.end(), stream, mr).release(), + stream, + mr); } /** @@ -1442,15 +1714,24 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param elements The list of elements * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template >* = nullptr> - lists_column_wrapper(std::initializer_list elements, ValidityIterator v) + template < + typename Element = T, + typename ValidityIterator, + std::enable_if_t && + !std::is_convertible_v>* = nullptr> + lists_column_wrapper(std::initializer_list elements, + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { build_from_non_nested( - cudf::test::strings_column_wrapper(elements.begin(), elements.end(), v).release()); + cudf::test::strings_column_wrapper(elements.begin(), elements.end(), v, stream, mr).release(), + stream, + mr); } /** @@ -1473,12 +1754,16 @@ class lists_column_wrapper : public detail::column_wrapper { * @endcode * * @param elements The list of elements + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - lists_column_wrapper(std::initializer_list> elements) + lists_column_wrapper(std::initializer_list> elements, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { std::vector valids; - build_from_nested(elements, valids); + build_from_nested(elements, valids, stream, mr); } /** @@ -1492,9 +1777,17 @@ class lists_column_wrapper : public detail::column_wrapper { * @endcode * */ - lists_column_wrapper() : column_wrapper{} + /** + * @brief Construct an empty lists column on the specified resource + * + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + explicit lists_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : column_wrapper{} { - build_from_non_nested(make_empty_column(cudf::type_to_id())); + build_from_non_nested(make_empty_column(cudf::type_to_id()), stream, mr); } /** @@ -1521,10 +1814,16 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param elements The list of elements * @param v The validity iterator + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template + template < + typename ValidityIterator, + std::enable_if_t>* = nullptr> lists_column_wrapper(std::initializer_list> elements, - ValidityIterator v) + ValidityIterator v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { std::vector validity; @@ -1533,25 +1832,32 @@ class lists_column_wrapper : public detail::column_wrapper { v, std::back_inserter(validity), [](lists_column_wrapper const& l, bool valid) { return valid; }); - build_from_nested(elements, validity); + build_from_nested(elements, validity, stream, mr); } /** * @brief Construct a list column containing a single empty, optionally null row. * * @param valid Whether or not the empty row is also null + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column * @return A list column containing a single empty row */ - static lists_column_wrapper make_one_empty_row_column(bool valid = true) + static lists_column_wrapper make_one_empty_row_column( + bool valid = true, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { - cudf::test::fixed_width_column_wrapper offsets{0, 0}; - cudf::test::fixed_width_column_wrapper values{}; + cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); + cudf::test::fixed_width_column_wrapper values(mr); return lists_column_wrapper( 1, offsets.release(), values.release(), valid ? 0 : 1, - valid ? rmm::device_buffer{} : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL)); + valid ? rmm::device_buffer{} + : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr()), + mr); } private: @@ -1563,13 +1869,18 @@ class lists_column_wrapper : public detail::column_wrapper { * @param values The column of values bounded by the offsets * @param null_count The number of null list entries * @param null_mask The bits specifying the null lists in device memory + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources associated with the adopted constituent parts */ lists_column_wrapper(size_type num_rows, std::unique_ptr&& offsets, std::unique_ptr&& values, size_type null_count, - rmm::device_buffer&& null_mask) + rmm::device_buffer&& null_mask, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { + static_cast(mr); // construct the list column wrapped = make_lists_column( num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); @@ -1589,10 +1900,14 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param elements Input columns to be wrapped * @param v The validity of each row + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column * */ void build_from_nested(std::initializer_list> elements, - std::vector const& v) + std::vector const& v, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { auto valids = cudf::detail::make_counting_transform_iterator( 0, [&v](auto i) { return v.empty() ? true : v[i]; }); @@ -1609,7 +1924,8 @@ class lists_column_wrapper : public detail::column_wrapper { int32_t const expected_depth = hierarchy_and_depth.second; // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy - auto [cols, stubs] = preprocess_columns(elements, expected_hierarchy, expected_depth); + auto [cols, stubs] = + preprocess_columns(elements, expected_hierarchy, expected_depth, stream, mr); // generate offsets size_type count = 0; @@ -1627,7 +1943,8 @@ class lists_column_wrapper : public detail::column_wrapper { // add the final offset offsetv.push_back(count); auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end()).release(); + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); // concatenate them together, skipping children that are null. std::vector children; @@ -1638,16 +1955,14 @@ class lists_column_wrapper : public detail::column_wrapper { cuda::std::identity{}); auto data = children.empty() ? cudf::empty_like(expected_hierarchy) - : cudf::concatenate(children, - cudf::test::get_default_stream(), - cudf::get_current_device_resource_ref()); + : cudf::concatenate(children, stream, mr.get_output_mr()); // increment depth depth = expected_depth + 1; auto [null_mask, null_count] = [&] { if (v.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); - return cudf::test::detail::make_null_mask(v.begin(), v.end()); + return cudf::test::detail::make_null_mask(v.begin(), v.end(), stream, mr); }(); // construct the list column @@ -1660,9 +1975,13 @@ class lists_column_wrapper : public detail::column_wrapper { * will be "unwrapped" when used in the nesting (list of lists) case. * * @param c Input column to be wrapped + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column * */ - void build_from_non_nested(std::unique_ptr c) + void build_from_non_nested(std::unique_ptr c, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), "Unexpected type"); @@ -1673,7 +1992,8 @@ class lists_column_wrapper : public detail::column_wrapper { offsetv.push_back(c->size()); } auto offsets = - cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end()).release(); + cudf::test::fixed_width_column_wrapper(offsetv.begin(), offsetv.end(), stream, mr) + .release(); // construct the list column. mark this as a root root = true; @@ -1715,11 +2035,16 @@ class lists_column_wrapper : public detail::column_wrapper { * * @param col Input column to be normalized * @param expected_hierarchy Input column which represents the expected hierarchy + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used for temporary normalized copies * * @return A new column representing a normalized copy of col */ - std::unique_ptr normalize_column(column_view const& col, - column_view const& expected_hierarchy) + std::unique_ptr normalize_column( + column_view const& col, + column_view const& expected_hierarchy, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { // if are at the bottom of the short column, it must be empty if (col.type().id() != type_id::LIST) { @@ -1732,18 +2057,19 @@ class lists_column_wrapper : public detail::column_wrapper { lists_column_view lcv(col); return make_lists_column( col.size(), - std::make_unique(lcv.offsets()), - normalize_column(lists_column_view(col).child(), - lists_column_view(expected_hierarchy).child()), + std::make_unique(lcv.offsets(), stream, mr.get_temporary_mr()), + normalize_column( + lists_column_view(col).child(), lists_column_view(expected_hierarchy).child(), stream, mr), col.null_count(), - cudf::copy_bitmask( - col, cudf::test::get_default_stream(), cudf::get_current_device_resource_ref())); + cudf::copy_bitmask(col, stream, mr.get_temporary_mr())); } std::pair, std::vector>> preprocess_columns( std::initializer_list> const& elements, column_view& expected_hierarchy, - int expected_depth) + int expected_depth, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { std::vector> stubs; std::vector cols; @@ -1751,37 +2077,38 @@ class lists_column_wrapper : public detail::column_wrapper { // preprocess the incoming lists. // - unwrap any "root" lists // - handle incomplete hierarchies - std::transform(elements.begin(), - elements.end(), - std::back_inserter(cols), - [&](lists_column_wrapper const& l) -> column_view { - // depth mismatch. attempt to normalize the short column. - // this function will also catch if this is a legitimately broken - // set of input - if (l.depth < expected_depth) { - if (l.root) { - // this exception distinguishes between the following two cases: - // - // { {{{1, 2, 3}}}, {} } - // In this case, row 0 is a List>>, whereas row 1 is - // just a List<> which is an apparent mismatch. However, because row 1 - // is empty we will allow that to semantically mean - // "a List>> that's empty at the top level" - // - // { {{{1, 2, 3}}}, {4, 5, 6} } - // In this case, row 1 is a concrete List with actual values. - // There is no way to rectify the differences so we will treat it as a - // true column mismatch. - CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); - stubs.push_back(empty_like(expected_hierarchy)); - } else { - stubs.push_back(normalize_column(l.get_view(), expected_hierarchy)); - } - return *(stubs.back()); - } - // the empty hierarchy case - return l.get_view(); - }); + std::transform( + elements.begin(), + elements.end(), + std::back_inserter(cols), + [&](lists_column_wrapper const& l) -> column_view { + // depth mismatch. attempt to normalize the short column. + // this function will also catch if this is a legitimately broken + // set of input + if (l.depth < expected_depth) { + if (l.root) { + // this exception distinguishes between the following two cases: + // + // { {{{1, 2, 3}}}, {} } + // In this case, row 0 is a List>>, whereas row 1 is + // just a List<> which is an apparent mismatch. However, because row 1 + // is empty we will allow that to semantically mean + // "a List>> that's empty at the top level" + // + // { {{{1, 2, 3}}}, {4, 5, 6} } + // In this case, row 1 is a concrete List with actual values. + // There is no way to rectify the differences so we will treat it as a + // true column mismatch. + CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); + stubs.push_back(empty_like(expected_hierarchy)); + } else { + stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, mr)); + } + return *(stubs.back()); + } + // the empty hierarchy case + return l.get_view(); + }); return {std::move(cols), std::move(stubs)}; } @@ -1824,13 +2151,35 @@ class structs_column_wrapper : public detail::column_wrapper { * auto struct_col {structs_col.release()}; * @endcode * + * The existing allocations in adopted child columns retain their original memory-resource + * provenance. The supplied output resource controls the struct null mask and any child + * allocations created while sanitizing null struct rows. + * * @param child_columns The vector of pre-constructed child columns * @param validity The vector of bools representing the column validity values + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used for new allocations owned by the returned column */ structs_column_wrapper(std::vector>&& child_columns, - std::vector const& validity = {}) + std::vector const& validity = {}, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + { + init(std::move(child_columns), validity, stream, mr); + } + + /** + * @brief Constructs a struct column by adopting child columns with no parent nulls. + * + * @param child_columns The vector of pre-constructed child columns + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used for new allocations owned by the returned column + */ + structs_column_wrapper(std::vector>&& child_columns, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : structs_column_wrapper(std::move(child_columns), std::vector{}, stream, mr) { - init(std::move(child_columns), validity); } /** @@ -1850,12 +2199,19 @@ class structs_column_wrapper : public detail::column_wrapper { * auto struct_col {structs_col.release()}; * @endcode * + * Child wrappers are deep-copied, so all allocations in the returned children use the supplied + * output resource. The source wrappers retain their original allocations. + * * @param child_column_wrappers The list of child column wrappers * @param validity The vector of bools representing the column validity values + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ structs_column_wrapper( std::initializer_list> child_column_wrappers, - std::vector const& validity = {}) + std::vector const& validity = {}, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { std::vector> child_columns; child_columns.reserve(child_column_wrappers.size()); @@ -1863,10 +2219,25 @@ class structs_column_wrapper : public detail::column_wrapper { child_column_wrappers.end(), std::back_inserter(child_columns), [&](auto const& column_wrapper) { - return std::make_unique(column_wrapper.get(), - cudf::test::get_default_stream()); + return std::make_unique( + column_wrapper.get(), stream, mr.get_output_mr()); }); - init(std::move(child_columns), validity); + init(std::move(child_columns), validity, stream, mr); + } + + /** + * @brief Constructs a struct column by copying child wrappers with no parent nulls. + * + * @param child_column_wrappers The list of child column wrappers + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column + */ + structs_column_wrapper( + std::initializer_list> child_column_wrappers, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + : structs_column_wrapper(child_column_wrappers, std::vector{}, stream, mr) + { } /** @@ -1888,11 +2259,16 @@ class structs_column_wrapper : public detail::column_wrapper { * * @param child_column_wrappers The list of child column wrappers * @param validity_iter Iterator returning the per-row validity bool + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ - template + template >* = nullptr> structs_column_wrapper( std::initializer_list> child_column_wrappers, - V validity_iter) + V validity_iter, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { std::vector> child_columns; child_columns.reserve(child_column_wrappers.size()); @@ -1900,15 +2276,17 @@ class structs_column_wrapper : public detail::column_wrapper { child_column_wrappers.end(), std::back_inserter(child_columns), [&](auto const& column_wrapper) { - return std::make_unique(column_wrapper.get(), - cudf::test::get_default_stream()); + return std::make_unique( + column_wrapper.get(), stream, mr.get_output_mr()); }); - init(std::move(child_columns), validity_iter); + init(std::move(child_columns), validity_iter, stream, mr); } private: void init(std::vector>&& child_columns, - std::vector const& validity) + std::vector const& validity, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { size_type num_rows = child_columns.empty() ? 0 : child_columns[0]->size(); @@ -1922,19 +2300,22 @@ class structs_column_wrapper : public detail::column_wrapper { auto [null_mask, null_count] = [&] { if (validity.size() <= 0) return std::make_pair(rmm::device_buffer{}, cudf::size_type{0}); - return cudf::test::detail::make_null_mask(validity.begin(), validity.end()); + return cudf::test::detail::make_null_mask(validity.begin(), validity.end(), stream, mr); }(); wrapped = cudf::make_structs_column(num_rows, std::move(child_columns), null_count, std::move(null_mask), - cudf::test::get_default_stream(), - cudf::get_current_device_resource_ref()); + stream, + mr.get_output_mr()); } template - void init(std::vector>&& child_columns, V validity_iterator) + void init(std::vector>&& child_columns, + V validity_iterator, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { size_type const num_rows = child_columns.empty() ? 0 : child_columns[0]->size(); @@ -1946,7 +2327,7 @@ class structs_column_wrapper : public detail::column_wrapper { std::vector validity(num_rows); std::copy(validity_iterator, validity_iterator + num_rows, validity.begin()); - init(std::move(child_columns), validity); + init(std::move(child_columns), validity, stream, mr); } }; diff --git a/cpp/include/cudf_test/memory_resource_utilities.hpp b/cpp/include/cudf_test/memory_resource_utilities.hpp index 4c63e6741c52..1ad81d7ef1eb 100644 --- a/cpp/include/cudf_test/memory_resource_utilities.hpp +++ b/cpp/include/cudf_test/memory_resource_utilities.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include @@ -17,6 +18,7 @@ #include #include +#include #include #include #include @@ -154,6 +156,24 @@ class memory_resource_test_harness { rmm::mr::callback_memory_resource _failing_mr; }; +/** + * @brief Callable that accepts a statistics resource and returns a column wrapper. + */ +template +concept column_wrapper_statistics_resource_factory = + requires(Factory& factory, rmm::mr::statistics_resource_adaptor& mr) { + { std::invoke(factory, mr) } -> std::derived_from; + }; + +/** + * @brief Callable that accepts `cudf::memory_resources` and returns a column wrapper. + */ +template +concept column_wrapper_memory_resources_factory = + requires(Factory& factory, cudf::memory_resources mr) { + { std::invoke(factory, mr) } -> std::derived_from; + }; + /** * @brief Verify that an owning result uses one explicitly supplied output resource. * @@ -169,7 +189,7 @@ class memory_resource_test_harness { * @param output_expectation Expected relationship between live and total output bytes * @param stream Stream to synchronize before inspecting allocation counters */ -template +template void expect_output_uses_resource( Factory&& factory, output_allocation_expectation output_expectation = output_allocation_expectation::EXACT, @@ -207,7 +227,7 @@ void expect_output_uses_resource( * @param expectations Expected output and temporary allocation behavior * @param stream Stream to synchronize before inspecting allocation counters */ -template +template void expect_output_uses_distinct_resources( Factory&& factory, memory_resource_expectations expectations = {}, diff --git a/cpp/include/cudf_test/timestamp_utilities.cuh b/cpp/include/cudf_test/timestamp_utilities.cuh index 62b8a1c8db87..f4386aac972e 100644 --- a/cpp/include/cudf_test/timestamp_utilities.cuh +++ b/cpp/include/cudf_test/timestamp_utilities.cuh @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include +#include #include #include @@ -32,11 +33,16 @@ using time_point_ms = * @param count The number of timestamps to create * @param start The first timestamp as a cuda::std::chrono::time_point * @param stop The last timestamp as a cuda::std::chrono::time_point + * @param stream CUDA stream used for device memory operations + * @param mr Memory resources used to allocate the returned column */ template -inline cudf::test::fixed_width_column_wrapper generate_timestamps(int32_t count, - time_point_ms start, - time_point_ms stop) +inline cudf::test::fixed_width_column_wrapper generate_timestamps( + int32_t count, + time_point_ms start, + time_point_ms stop, + rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { using Rep = typename T::rep; using Period = typename T::period; @@ -57,10 +63,10 @@ inline cudf::test::fixed_width_column_wrapper generate_timestamps(in if (nullable) { auto mask = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 2 == 0; }); - return cudf::test::fixed_width_column_wrapper(iter, iter + count, mask); + return cudf::test::fixed_width_column_wrapper(iter, iter + count, mask, stream, mr); } else { // This needs to be in an else to quash `statement_not_reachable` warnings - return cudf::test::fixed_width_column_wrapper(iter, iter + count); + return cudf::test::fixed_width_column_wrapper(iter, iter + count, stream, mr); } } diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 48d664272d16..08f6c3702255 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -489,8 +489,9 @@ std::string stringify_column_differences(cudf::device_span difference buffer << depth_str << "differences:" << std::endl; auto source_table = cudf::table_view({lhs, rhs}); - auto diff_column = - fixed_width_column_wrapper(h_differences.begin(), h_differences.end()); + // Intermediate gather indices — allocate on temporary, not output. + auto diff_column = fixed_width_column_wrapper( + h_differences.begin(), h_differences.end(), stream, mr.get_temporary_mr()); auto diff_table = cudf::gather(source_table, diff_column, cudf::out_of_bounds_policy::DONT_CHECK, diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 34a58ec6184c..1740eec47278 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ @@ -7,13 +7,272 @@ #include #include #include +#include #include #include #include +#include #include +using cudf::test::expect_output_uses_distinct_resources; +using cudf::test::temporary_allocation_expectation; + +namespace { +auto const uses_temporary = cudf::test::memory_resource_expectations{ + cudf::test::output_allocation_expectation::EXACT, temporary_allocation_expectation::SOME}; +} // namespace + +TEST(FixedWidthColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources) +{ + auto stream = cudf::test::get_default_stream(); + auto const elements = std::vector{1, 2, 3, 4}; + auto const validity = std::vector{true, false, true, false}; + + expect_output_uses_distinct_resources( + [&](auto mr) { return cudf::test::fixed_width_column_wrapper(stream, mr); }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + elements.begin(), elements.end(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + {1, 2, 3, 4}, stream, mr.get_output_mr()); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + elements.begin(), elements.end(), validity.begin(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + {1, 2, 3, 4}, {true, false, true, false}, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + {1, 2, 3, 4}, validity.begin(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + elements.begin(), elements.end(), {true, false, true, false}, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + using pair_type = std::pair; + return cudf::test::fixed_width_column_wrapper( + {pair_type{1, true}, pair_type{2, false}, pair_type{3, true}}, stream, mr); + }); +} + +TEST(FixedWidthColumnWrapperMemoryResourceTest, FixedPointElementPaths) +{ + auto stream = cudf::test::get_default_stream(); + using decimal32 = numeric::decimal32; + + auto const reps = std::vector{1, 2, 3, 4}; + auto const decimals = std::vector{decimal32{1, numeric::scale_type{0}}, + decimal32{2, numeric::scale_type{0}}, + decimal32{3, numeric::scale_type{0}}, + decimal32{4, numeric::scale_type{0}}}; + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + reps.begin(), reps.end(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_width_column_wrapper( + decimals.begin(), decimals.end(), stream, mr); + }); +} + +TEST(FixedPointColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources) +{ + auto stream = cudf::test::get_default_stream(); + auto const elements = std::vector{1, 2, 3, 4}; + auto const validity = std::vector{true, false, true, false}; + auto const scale = numeric::scale_type{-2}; + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + elements.begin(), elements.end(), scale, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + {1, 2, 3, 4}, scale, stream, mr.get_output_mr()); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + elements.begin(), elements.end(), validity.begin(), scale, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + {1, 2, 3, 4}, {true, false, true, false}, scale, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + {1, 2, 3, 4}, validity.begin(), scale, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::fixed_point_column_wrapper( + elements.begin(), elements.end(), {true, false, true, false}, scale, stream, mr); + }); +} + +TEST(StringsColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources) +{ + auto stream = cudf::test::get_default_stream(); + auto const strings = std::vector{"", "alpha", "beta", "gamma"}; + auto const validity = std::vector{true, false, true, false}; + + expect_output_uses_distinct_resources( + [&](auto mr) { return cudf::test::strings_column_wrapper(stream, mr); }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::strings_column_wrapper(strings.begin(), strings.end(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::strings_column_wrapper( + {"", "alpha", "beta", "gamma"}, stream, mr.get_output_mr()); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::strings_column_wrapper( + strings.begin(), strings.end(), validity.begin(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::strings_column_wrapper( + {"", "alpha", "beta", "gamma"}, validity.begin(), stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::strings_column_wrapper( + {"", "alpha", "beta", "gamma"}, {true, false, true, false}, stream, mr); + }); + + expect_output_uses_distinct_resources([&](auto mr) { + using pair_type = std::pair; + return cudf::test::strings_column_wrapper( + {pair_type{"", true}, pair_type{"alpha", false}, pair_type{"beta", true}}, stream, mr); + }); +} + +TEST(DictionaryColumnWrapperMemoryResourceTest, FixedWidthDistinctOutputAndTemporaryResources) +{ + auto stream = cudf::test::get_default_stream(); + auto const elements = std::vector{3, 1, 3, 2}; + auto const validity = std::vector{true, false, true, true}; + + // Intermediate fixed-width column is allocated on temporary_mr before encode. + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + elements.begin(), elements.end(), stream, mr); + }, + uses_temporary); + + // Single-ref overload: temporaries go to the current resource, not the harness temporary. + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::dictionary_column_wrapper({3, 1, 3, 2}, stream, mr.get_output_mr()); + }); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + elements.begin(), elements.end(), validity.begin(), stream, mr); + }, + uses_temporary); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + {3, 1, 3, 2}, validity.begin(), stream, mr); + }, + uses_temporary); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + {3, 1, 3, 2}, {true, false, true, true}, stream, mr); + }, + uses_temporary); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + elements.begin(), elements.end(), {true, false, true, true}, stream, mr); + }, + uses_temporary); +} + +TEST(DictionaryColumnWrapperMemoryResourceTest, EmptyStringDictionaryPreservesChildTypes) +{ + expect_output_uses_distinct_resources([&](auto mr) { + auto wrapper = + cudf::test::dictionary_column_wrapper(cudf::test::get_default_stream(), mr); + auto dictionary = cudf::dictionary_column_view{static_cast(wrapper)}; + + EXPECT_EQ(0, static_cast(wrapper).size()); + EXPECT_EQ(cudf::type_id::STRING, dictionary.keys().type().id()); + EXPECT_EQ(cudf::type_id::INT32, dictionary.indices().type().id()); + return wrapper; + }); +} + +TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporaryResources) +{ + auto stream = cudf::test::get_default_stream(); + auto const strings = std::vector{"gamma", "alpha", "gamma", "beta"}; + auto const validity = std::vector{true, false, true, true}; + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + strings.begin(), strings.end(), stream, mr); + }, + uses_temporary); + + // Single-ref overload: temporaries go to the current resource, not the harness temporary. + expect_output_uses_distinct_resources([&](auto mr) { + return cudf::test::dictionary_column_wrapper( + {"gamma", "alpha", "gamma", "beta"}, stream, mr.get_output_mr()); + }); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + strings.begin(), strings.end(), validity.begin(), stream, mr); + }, + uses_temporary); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + {"gamma", "alpha", "gamma", "beta"}, validity.begin(), stream, mr); + }, + uses_temporary); + + expect_output_uses_distinct_resources( + [&](auto mr) { + return cudf::test::dictionary_column_wrapper( + {"gamma", "alpha", "gamma", "beta"}, {true, false, true, true}, stream, mr); + }, + uses_temporary); +} + template struct FixedWidthColumnWrapperTest : public cudf::test::BaseFixture, cudf::test::UniformRandomGenerator { diff --git a/cpp/tests/wrappers/timestamps_test.cu b/cpp/tests/wrappers/timestamps_test.cu index e3af3a50ff54..b91444b6f614 100644 --- a/cpp/tests/wrappers/timestamps_test.cu +++ b/cpp/tests/wrappers/timestamps_test.cu @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,27 @@ struct compare_chrono_elements_to_primitive_representation { }; } // namespace +template +void expect_timestamp_output_uses_resource() +{ + using namespace cuda::std::chrono; + + cudf::test::expect_output_uses_distinct_resources([](auto resources) { + return cudf::test::generate_timestamps( + 100, + cudf::test::time_point_ms{milliseconds{-1000}}, + cudf::test::time_point_ms{milliseconds{1000}}, + cudf::test::get_default_stream(), + resources); + }); +} + +TEST(TimestampGeneratorMemoryResourceTest, DistinctOutputAndTemporaryResources) +{ + expect_timestamp_output_uses_resource(); + expect_timestamp_output_uses_resource(); +} + TYPED_TEST_SUITE(ChronoColumnTest, cudf::test::ChronoTypes); TYPED_TEST(ChronoColumnTest, ChronoDurationsMatchPrimitiveRepresentation) From 3f518afe0621cc5108ee8d6c7768543ad0aa4635 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Fri, 7 Aug 2026 16:26:23 -0700 Subject: [PATCH 02/17] fix wrapper tests Signed-off-by: niranda perera --- .../utilities_tests/column_wrapper_tests.cpp | 191 +++++++++--------- 1 file changed, 100 insertions(+), 91 deletions(-) diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 1740eec47278..4049f708078e 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -24,74 +24,6 @@ auto const uses_temporary = cudf::test::memory_resource_expectations{ cudf::test::output_allocation_expectation::EXACT, temporary_allocation_expectation::SOME}; } // namespace -TEST(FixedWidthColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources) -{ - auto stream = cudf::test::get_default_stream(); - auto const elements = std::vector{1, 2, 3, 4}; - auto const validity = std::vector{true, false, true, false}; - - expect_output_uses_distinct_resources( - [&](auto mr) { return cudf::test::fixed_width_column_wrapper(stream, mr); }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - elements.begin(), elements.end(), stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - {1, 2, 3, 4}, stream, mr.get_output_mr()); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - elements.begin(), elements.end(), validity.begin(), stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - {1, 2, 3, 4}, {true, false, true, false}, stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - {1, 2, 3, 4}, validity.begin(), stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - elements.begin(), elements.end(), {true, false, true, false}, stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - using pair_type = std::pair; - return cudf::test::fixed_width_column_wrapper( - {pair_type{1, true}, pair_type{2, false}, pair_type{3, true}}, stream, mr); - }); -} - -TEST(FixedWidthColumnWrapperMemoryResourceTest, FixedPointElementPaths) -{ - auto stream = cudf::test::get_default_stream(); - using decimal32 = numeric::decimal32; - - auto const reps = std::vector{1, 2, 3, 4}; - auto const decimals = std::vector{decimal32{1, numeric::scale_type{0}}, - decimal32{2, numeric::scale_type{0}}, - decimal32{3, numeric::scale_type{0}}, - decimal32{4, numeric::scale_type{0}}}; - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - reps.begin(), reps.end(), stream, mr); - }); - - expect_output_uses_distinct_resources([&](auto mr) { - return cudf::test::fixed_width_column_wrapper( - decimals.begin(), decimals.end(), stream, mr); - }); -} - TEST(FixedPointColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources) { auto stream = cudf::test::get_default_stream(); @@ -273,8 +205,38 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporary uses_temporary); } +/** + * @brief Base fixture that instruments column-wrapper tests with a memory-resource harness. + * + * Each test instantiates a fresh harness. Tests should construct wrappers with `resources()` and + * pass the released column to `validate_with_harness()` before returning. `TearDown` asserts that + * no output or temporary allocations remain live. + */ +struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { + void TearDown() override { _harness.expect_no_live_allocations(this->stream()); } + + rmm::cuda_stream_view stream() const { return cudf::test::get_default_stream(); } + + cudf::memory_resources resources() { return _harness.resources(); } + + /** + * @brief Validate that the harness owns the given result. + * + * Assert that the harness output resource holds bytes equal to `col->alloc_size()` and that no + * temporary allocations remain live. `col` is destroyed on return, so `TearDown` can additionally + * confirm that the output bytes were released. + */ + void validate_with_harness(std::unique_ptr col) + { + _harness.expect_resource_usage(col->alloc_size(), {}, this->stream()); + } + + private: + cudf::test::memory_resource_test_harness _harness{}; +}; + template -struct FixedWidthColumnWrapperTest : public cudf::test::BaseFixture, +struct FixedWidthColumnWrapperTest : public ColumnWrapperTestWithHarness, cudf::test::UniformRandomGenerator { FixedWidthColumnWrapperTest() : cudf::test::UniformRandomGenerator{1000, 5000} {} @@ -289,7 +251,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, EmptyIterator) { auto sequence = cuda::counting_iterator{0}; cudf::test::fixed_width_column_wrapper col( - sequence, sequence); + sequence, sequence, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 0); EXPECT_EQ(view.head(), nullptr); @@ -297,10 +259,12 @@ TYPED_TEST(FixedWidthColumnWrapperTest, EmptyIterator) EXPECT_FALSE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, EmptyList) { - cudf::test::fixed_width_column_wrapper col{}; + cudf::test::fixed_width_column_wrapper col(this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 0); EXPECT_EQ(view.head(), nullptr); @@ -308,6 +272,8 @@ TYPED_TEST(FixedWidthColumnWrapperTest, EmptyList) EXPECT_FALSE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NonNullableIteratorConstructor) @@ -317,7 +283,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NonNullableIteratorConstructor) auto size = this->size(); cudf::test::fixed_width_column_wrapper col( - sequence, sequence + size); + sequence, sequence + size, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), size); EXPECT_NE(nullptr, view.head()); @@ -325,11 +291,14 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NonNullableIteratorConstructor) EXPECT_FALSE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NonNullableListConstructor) { - cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4, 5}); + cudf::test::fixed_width_column_wrapper col( + {1, 2, 3, 4, 5}, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 5); @@ -338,6 +307,8 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NonNullableListConstructor) EXPECT_FALSE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllValid) @@ -349,7 +320,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllValid) auto size = this->size(); cudf::test::fixed_width_column_wrapper col( - sequence, sequence + size, all_valid); + sequence, sequence + size, all_valid, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), size); EXPECT_NE(nullptr, view.head()); @@ -357,13 +328,16 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllValid) EXPECT_TRUE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullableListConstructorAllValid) { auto all_valid = cudf::test::iterators::no_nulls(); - cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4, 5}, all_valid); + cudf::test::fixed_width_column_wrapper col( + {1, 2, 3, 4, 5}, all_valid, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 5); EXPECT_NE(nullptr, view.head()); @@ -371,6 +345,8 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableListConstructorAllValid) EXPECT_TRUE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllNull) @@ -382,7 +358,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllNull) auto size = this->size(); cudf::test::fixed_width_column_wrapper col( - sequence, sequence + size, all_null); + sequence, sequence + size, all_null, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), size); EXPECT_NE(nullptr, view.head()); @@ -391,13 +367,16 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableIteratorConstructorAllNull) EXPECT_TRUE(view.has_nulls()); EXPECT_EQ(view.null_count(), size); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullableListConstructorAllNull) { auto all_null = cudf::test::iterators::all_nulls(); - cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4, 5}, all_null); + cudf::test::fixed_width_column_wrapper col( + {1, 2, 3, 4, 5}, all_null, this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 5); EXPECT_NE(nullptr, view.head()); @@ -406,13 +385,17 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullableListConstructorAllNull) EXPECT_TRUE(view.has_nulls()); EXPECT_EQ(view.null_count(), 5); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNull) { using p = std::pair; cudf::test::fixed_width_column_wrapper col( - {p{1, false}, p{2, false}, p{3, false}, p{4, false}, p{5, false}}); + {p{1, false}, p{2, false}, p{3, false}, p{4, false}, p{5, false}}, + this->stream(), + this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 5); @@ -422,13 +405,16 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNull) EXPECT_TRUE(view.has_nulls()); EXPECT_EQ(view.null_count(), 5); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNullMatch) { auto odd_valid = cudf::test::iterators::nulls_at_multiples_of(2); - cudf::test::fixed_width_column_wrapper match_col({1, 2, 3, 4, 5}, odd_valid); + cudf::test::fixed_width_column_wrapper match_col( + {1, 2, 3, 4, 5}, odd_valid, this->stream(), this->resources()); cudf::column_view match_view = match_col; using p = std::pair; @@ -436,17 +422,24 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNullMatch) p{2, odd_valid[1]}, p{3, odd_valid[2]}, p{4, odd_valid[3]}, - p{5, odd_valid[4]}}); + p{5, odd_valid[4]}}, + this->stream(), + this->resources()); cudf::column_view view = col; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, + match_view, + cudf::test::debug_output_level::FIRST_ERROR, + this->stream(), + this->resources()); } TYPED_TEST(FixedWidthColumnWrapperTest, ReleaseWrapperAllValid) { auto all_valid = cudf::test::iterators::no_nulls(); - cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4, 5}, all_valid); + cudf::test::fixed_width_column_wrapper col( + {1, 2, 3, 4, 5}, all_valid, this->stream(), this->resources()); auto colPtr = col.release(); cudf::column_view view = *colPtr; EXPECT_EQ(view.size(), 5); @@ -455,13 +448,16 @@ TYPED_TEST(FixedWidthColumnWrapperTest, ReleaseWrapperAllValid) EXPECT_TRUE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(std::move(colPtr)); } TYPED_TEST(FixedWidthColumnWrapperTest, ReleaseWrapperAllNull) { auto all_null = cudf::test::iterators::all_nulls(); - cudf::test::fixed_width_column_wrapper col({1, 2, 3, 4, 5}, all_null); + cudf::test::fixed_width_column_wrapper col( + {1, 2, 3, 4, 5}, all_null, this->stream(), this->resources()); auto colPtr = col.release(); cudf::column_view view = *colPtr; EXPECT_EQ(view.size(), 5); @@ -471,11 +467,12 @@ TYPED_TEST(FixedWidthColumnWrapperTest, ReleaseWrapperAllNull) EXPECT_TRUE(view.has_nulls()); EXPECT_EQ(view.null_count(), 5); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(std::move(colPtr)); } template -struct StringsColumnWrapperTest : public cudf::test::BaseFixture, - cudf::test::UniformRandomGenerator { +struct StringsColumnWrapperTest : public ColumnWrapperTestWithHarness { auto data_type() { return cudf::data_type{cudf::type_to_id()}; } }; @@ -483,7 +480,7 @@ TYPED_TEST_SUITE(StringsColumnWrapperTest, cudf::test::StringTypes); TYPED_TEST(StringsColumnWrapperTest, EmptyList) { - cudf::test::strings_column_wrapper col; + cudf::test::strings_column_wrapper col(this->stream(), this->resources()); cudf::column_view view = col; EXPECT_EQ(view.size(), 0); EXPECT_EQ(view.head(), nullptr); @@ -491,13 +488,17 @@ TYPED_TEST(StringsColumnWrapperTest, EmptyList) EXPECT_FALSE(view.nullable()); EXPECT_FALSE(view.has_nulls()); EXPECT_EQ(view.offset(), 0); + + this->validate_with_harness(col.release()); } TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNull) { using p = std::pair; cudf::test::strings_column_wrapper col( - {p{"a", false}, p{"string", false}, p{"test", false}, p{"for", false}, p{"nulls", false}}); + {p{"a", false}, p{"string", false}, p{"test", false}, p{"for", false}, p{"nulls", false}}, + this->stream(), + this->resources()); cudf::strings_column_view view = cudf::column_view(col); constexpr auto count = 5; @@ -508,14 +509,16 @@ TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNull) EXPECT_NE(nullptr, view.offsets().head()); EXPECT_TRUE(view.has_nulls()); EXPECT_EQ(view.null_count(), 5); + + this->validate_with_harness(col.release()); } TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNullMatch) { auto odd_valid = cudf::test::iterators::nulls_at_multiples_of(2); - cudf::test::strings_column_wrapper match_col({"a", "string", "", "test", "for", "nulls"}, - odd_valid); + cudf::test::strings_column_wrapper match_col( + {"a", "string", "", "test", "for", "nulls"}, odd_valid, this->stream(), this->resources()); cudf::column_view match_view = match_col; using p = std::pair; @@ -524,8 +527,14 @@ TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNullMatch) p{"", odd_valid[2]}, p{"test", odd_valid[3]}, p{"for", odd_valid[4]}, - p{"nulls", odd_valid[5]}}); + p{"nulls", odd_valid[5]}}, + this->stream(), + this->resources()); cudf::column_view view = col; - CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view); + CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, + match_view, + cudf::test::debug_output_level::FIRST_ERROR, + this->stream(), + this->resources()); } From cb35fb093954b5555f5ea16aeaf2838eccac8e80 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Fri, 7 Aug 2026 16:50:04 -0700 Subject: [PATCH 03/17] fix col util tests Signed-off-by: niranda perera --- .../column_utilities_tests.cpp | 301 +++++++++++------- 1 file changed, 192 insertions(+), 109 deletions(-) diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index aa8f988b591f..a7af3fc4b901 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -48,21 +48,27 @@ TYPED_TEST_SUITE(ColumnUtilitiesTestFixedPoint, cudf::test::FixedPointTypes); TYPED_TEST(ColumnUtilitiesTest, NonNullableToHost) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + auto sequence = cudf::detail::make_counting_transform_iterator( 0, [](auto i) { return cudf::test::make_type_param_scalar(i); }); auto size = this->size(); std::vector data(sequence, sequence + size); - cudf::test::fixed_width_column_wrapper col(data.begin(), data.end()); + cudf::test::fixed_width_column_wrapper col(data.begin(), data.end(), stream, mr); - auto host_data = cudf::test::to_host(col); + auto host_data = cudf::test::to_host(col, stream, mr); EXPECT_TRUE(std::equal(data.begin(), data.end(), host_data.first.begin())); } TYPED_TEST(ColumnUtilitiesTest, NonNullableToHostWithOffset) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + auto sequence = cudf::detail::make_counting_transform_iterator( 0, [](auto i) { return cudf::test::make_type_param_scalar(i); }); @@ -71,18 +77,22 @@ TYPED_TEST(ColumnUtilitiesTest, NonNullableToHostWithOffset) auto data = std::vector(sequence, sequence + size); auto expected_data = std::vector(sequence + split, sequence + size); - auto col = cudf::test::fixed_width_column_wrapper(data.begin(), data.end()); + auto col = + cudf::test::fixed_width_column_wrapper(data.begin(), data.end(), stream, mr); auto const splits = std::vector{split}; auto result = cudf::split(col, splits); - auto host_data = cudf::test::to_host(result.back()); + auto host_data = cudf::test::to_host(result.back(), stream, mr); EXPECT_TRUE(std::equal(expected_data.begin(), expected_data.end(), host_data.first.begin())); } TYPED_TEST(ColumnUtilitiesTest, NullableToHostWithOffset) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + auto sequence = cudf::detail::make_counting_transform_iterator( 0, [](auto i) { return cudf::test::make_type_param_scalar(i); }); @@ -92,12 +102,13 @@ TYPED_TEST(ColumnUtilitiesTest, NullableToHostWithOffset) 0, [&split](auto i) { return i <= 10 and i > split; }); std::vector data(sequence, sequence + size); std::vector expected_data(sequence + split, sequence + size); - cudf::test::fixed_width_column_wrapper col(data.begin(), data.end(), valid); + cudf::test::fixed_width_column_wrapper col( + data.begin(), data.end(), valid, stream, mr); std::vector splits{split}; std::vector result = cudf::split(col, splits); - auto host_data = cudf::test::to_host(result.back()); + auto host_data = cudf::test::to_host(result.back(), stream, mr); EXPECT_TRUE(std::equal(expected_data.begin(), expected_data.end(), host_data.first.begin())); @@ -108,6 +119,9 @@ TYPED_TEST(ColumnUtilitiesTest, NullableToHostWithOffset) TYPED_TEST(ColumnUtilitiesTest, NullableToHostAllValid) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + auto sequence = cudf::detail::make_counting_transform_iterator( 0, [](auto i) { return cudf::test::make_type_param_scalar(i); }); @@ -116,9 +130,10 @@ TYPED_TEST(ColumnUtilitiesTest, NullableToHostAllValid) auto size = this->size(); std::vector data(sequence, sequence + size); - cudf::test::fixed_width_column_wrapper col(data.begin(), data.end(), all_valid); + cudf::test::fixed_width_column_wrapper col( + data.begin(), data.end(), all_valid, stream, mr); - auto host_data = cudf::test::to_host(col); + auto host_data = cudf::test::to_host(col, stream, mr); EXPECT_TRUE(std::equal(data.begin(), data.end(), host_data.first.begin())); @@ -131,19 +146,28 @@ struct ColumnUtilitiesEquivalenceTest : public cudf::test::BaseFixture {}; TEST_F(ColumnUtilitiesEquivalenceTest, DoubleTest) { - cudf::test::fixed_width_column_wrapper col1{10. / 3, 22. / 7}; - cudf::test::fixed_width_column_wrapper col2{31. / 3 - 21. / 3, 19. / 7 + 3. / 7}; + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + + cudf::test::fixed_width_column_wrapper col1({10. / 3, 22. / 7}, stream, mr); + cudf::test::fixed_width_column_wrapper col2( + {31. / 3 - 21. / 3, 19. / 7 + 3. / 7}, stream, mr); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(col1, col2); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + col1, col2, cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, stream, mr); } TEST_F(ColumnUtilitiesEquivalenceTest, NullabilityTest) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + auto all_valid = cudf::test::iterators::no_nulls(); - cudf::test::fixed_width_column_wrapper col1{1, 2, 3}; - cudf::test::fixed_width_column_wrapper col2({1, 2, 3}, all_valid); + cudf::test::fixed_width_column_wrapper col1({1, 2, 3}, stream, mr); + cudf::test::fixed_width_column_wrapper col2({1, 2, 3}, all_valid, stream, mr); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(col1, col2); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + col1, col2, cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, stream, mr); } TEST_F(ColumnUtilitiesEquivalenceTest, DistinctMemoryResources) @@ -202,12 +226,17 @@ struct ColumnUtilitiesStringsTest : public cudf::test::BaseFixture {}; TEST_F(ColumnUtilitiesStringsTest, StringsToHost) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + std::vector h_strings{"eee", "bb", nullptr, "", "aa", "bbb", "ééé"}; cudf::test::strings_column_wrapper strings( h_strings.begin(), h_strings.end(), - thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; })); - auto host_data = cudf::test::to_host(strings); + thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; }), + stream, + mr); + auto host_data = cudf::test::to_host(strings, stream, mr); auto result_itr = host_data.first.begin(); for (auto itr = h_strings.begin(); itr != h_strings.end(); ++itr, ++result_itr) { if (*itr) { EXPECT_TRUE((*result_itr) == (*itr)); } @@ -216,12 +245,17 @@ TEST_F(ColumnUtilitiesStringsTest, StringsToHost) TEST_F(ColumnUtilitiesStringsTest, StringsToHostAllNulls) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + std::vector h_strings{nullptr, nullptr, nullptr}; cudf::test::strings_column_wrapper strings( h_strings.begin(), h_strings.end(), - thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; })); - auto host_data = cudf::test::to_host(strings); + thrust::make_transform_iterator(h_strings.begin(), [](auto str) { return str != nullptr; }), + stream, + mr); + auto host_data = cudf::test::to_host(strings, stream, mr); auto results = host_data.first; EXPECT_EQ(std::size_t{3}, host_data.first.size()); EXPECT_TRUE(std::all_of(results.begin(), results.end(), [](auto s) { return s.empty(); })); @@ -229,6 +263,9 @@ TEST_F(ColumnUtilitiesStringsTest, StringsToHostAllNulls) TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHost) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + using namespace numeric; using decimalXX = TypeParam; using rep = cudf::device_storage_type_t; @@ -239,16 +276,20 @@ TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHost) auto fps = cudf::detail::make_counting_transform_iterator(0, to_fp); auto reps = cudf::detail::make_counting_transform_iterator(0, to_rep); - auto const size = 1000; - auto const expected = std::vector(fps, fps + size); - auto const col = cudf::test::fixed_point_column_wrapper(reps, reps + size, scale); - auto const host_data = cudf::test::to_host(col); + auto const size = 1000; + auto const expected = std::vector(fps, fps + size); + auto const col = + cudf::test::fixed_point_column_wrapper(reps, reps + size, scale, stream, mr); + auto const host_data = cudf::test::to_host(col, stream, mr); EXPECT_TRUE(std::equal(expected.begin(), expected.end(), host_data.first.begin())); } TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHostWithOffset) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + using namespace numeric; using decimalXX = TypeParam; using rep = cudf::device_storage_type_t; @@ -263,11 +304,12 @@ TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHostWithOffset) auto const split = cudf::size_type{2}; auto const expected = std::vector(fps + split, fps + size); - auto const col = cudf::test::fixed_point_column_wrapper(reps, reps + size, scale); - auto const splits = std::vector{split}; - auto result = cudf::split(col, splits); + auto const col = + cudf::test::fixed_point_column_wrapper(reps, reps + size, scale, stream, mr); + auto const splits = std::vector{split}; + auto result = cudf::split(col, splits); - auto host_data = cudf::test::to_host(result.back()); + auto host_data = cudf::test::to_host(result.back(), stream, mr); EXPECT_TRUE(std::equal(expected.begin(), expected.end(), host_data.first.begin())); } @@ -276,65 +318,82 @@ struct ColumnUtilitiesListsTest : public cudf::test::BaseFixture {}; TEST_F(ColumnUtilitiesListsTest, Equivalence) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + // list, nullable vs. non-nullable { auto all_valid = cudf::test::iterators::no_nulls(); - cudf::test::lists_column_wrapper a{{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}; - cudf::test::lists_column_wrapper b{{{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}, all_valid}; + cudf::test::lists_column_wrapper a( + {{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}, stream, mr); + cudf::test::lists_column_wrapper b( + {{1, 2, 3}, {5, 6}, {8, 9}, {10}, {14, 15}}, all_valid, stream, mr); // properties - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT(a, b); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT( + a, b, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); EXPECT_FALSE(cudf::test::detail::expect_column_properties_equal( - a, b, cudf::test::debug_output_level::QUIET)); + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); // values - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); - EXPECT_FALSE( - cudf::test::detail::expect_columns_equal(a, b, cudf::test::debug_output_level::QUIET)); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + a, b, cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, stream, mr); + EXPECT_FALSE(cudf::test::detail::expect_columns_equal( + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); } // list>, nullable vs. non-nullable { auto all_valid = cudf::test::iterators::no_nulls(); - cudf::test::lists_column_wrapper a{{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}; - cudf::test::lists_column_wrapper b{{{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}, - all_valid}; + cudf::test::lists_column_wrapper a( + {{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}, stream, mr); + cudf::test::lists_column_wrapper b( + {{{1, 2, 3}, {5, 6}}, {{8, 9}, {10}}, {{14, 15}}}, all_valid, stream, mr); // properties - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT(a, b); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT( + a, b, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); EXPECT_FALSE(cudf::test::detail::expect_column_properties_equal( - a, b, cudf::test::debug_output_level::QUIET)); + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(a, b); - EXPECT_FALSE( - cudf::test::detail::expect_columns_equal(a, b, cudf::test::debug_output_level::QUIET)); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT( + a, b, cudf::test::debug_output_level::FIRST_ERROR, cudf::test::default_ulp, stream, mr); + EXPECT_FALSE(cudf::test::detail::expect_columns_equal( + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); } } TEST_F(ColumnUtilitiesListsTest, DifferingRowCounts) { - cudf::test::fixed_width_column_wrapper a{1, 1, 1, 1}; - cudf::test::fixed_width_column_wrapper b{1, 1, 1, 1, 1}; + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + + cudf::test::fixed_width_column_wrapper a({1, 1, 1, 1}, stream, mr); + cudf::test::fixed_width_column_wrapper b({1, 1, 1, 1, 1}, stream, mr); - EXPECT_FALSE( - cudf::test::detail::expect_columns_equal(a, b, cudf::test::debug_output_level::QUIET)); + EXPECT_FALSE(cudf::test::detail::expect_columns_equal( + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); EXPECT_FALSE(cudf::test::detail::expect_column_properties_equal( - a, b, cudf::test::debug_output_level::QUIET)); - EXPECT_FALSE( - cudf::test::detail::expect_columns_equivalent(a, b, cudf::test::debug_output_level::QUIET)); + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); + EXPECT_FALSE(cudf::test::detail::expect_columns_equivalent( + a, b, cudf::test::debug_output_level::QUIET, cudf::test::default_ulp, stream, mr)); EXPECT_FALSE(cudf::test::detail::expect_column_properties_equivalent( - a, b, cudf::test::debug_output_level::QUIET)); + a, b, cudf::test::debug_output_level::QUIET, stream, mr)); } TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) { + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + // list { std::vector valids = {0, 0, 1, 0, 1, 0, 0}; - cudf::test::fixed_width_column_wrapper c0_offsets{0, 3, 6, 8, 11, 14, 16, 19}; - cudf::test::fixed_width_column_wrapper c0_data{ - 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7}; + cudf::test::fixed_width_column_wrapper c0_offsets( + {0, 3, 6, 8, 11, 14, 16, 19}, stream, mr); + cudf::test::fixed_width_column_wrapper c0_data( + {1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7}, stream, mr); auto [null_mask, null_count] = cudf::test::detail::make_null_mask(valids.begin(), valids.end()); @@ -344,8 +403,8 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) return cudf::purge_nonempty_nulls(tmp->view()); }(); - cudf::test::fixed_width_column_wrapper c1_offsets{0, 0, 0, 2, 2, 5, 5, 5}; - cudf::test::fixed_width_column_wrapper c1_data{3, 3, 5, 5, 5}; + cudf::test::fixed_width_column_wrapper c1_offsets({0, 0, 0, 2, 2, 5, 5, 5}, stream, mr); + cudf::test::fixed_width_column_wrapper c1_data({3, 3, 5, 5, 5}, stream, mr); auto c1 = [&] { auto tmp = make_lists_column( 7, @@ -357,23 +416,26 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) }(); // properties - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(*c0, *c1); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL( + *c0, *c1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); // values - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*c0, *c1); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *c0, *c1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } // list>> { std::vector level1_valids = {0, 0, 1, 0, 1, 0, 0}; - cudf::test::fixed_width_column_wrapper c0_l1_offsets{0, 1, 2, 4, 4, 7, 7, 7}; - cudf::test::fixed_width_column_wrapper c0_l2_offsets{0, 1, 2, 5, 6, 7, 10, 14}; - cudf::test::fixed_width_column_wrapper c0_l3_ints{ - 1, 1, -1, -2, -3, 1, 1, -4, -5, -6, -7, -8, -9, -10}; - cudf::test::fixed_width_column_wrapper c0_l3_floats{ - 1, 1, 10, 20, 30, 1, 1, 40, 50, 60, 70, 80, 90, 100}; - cudf::test::structs_column_wrapper c0_l2_data({c0_l3_ints, c0_l3_floats}); + cudf::test::fixed_width_column_wrapper c0_l1_offsets({0, 1, 2, 4, 4, 7, 7, 7}, stream, mr); + cudf::test::fixed_width_column_wrapper c0_l2_offsets( + {0, 1, 2, 5, 6, 7, 10, 14}, stream, mr); + cudf::test::fixed_width_column_wrapper c0_l3_ints( + {1, 1, -1, -2, -3, 1, 1, -4, -5, -6, -7, -8, -9, -10}, stream, mr); + cudf::test::fixed_width_column_wrapper c0_l3_floats( + {1, 1, 10, 20, 30, 1, 1, 40, 50, 60, 70, 80, 90, 100}, stream, mr); + cudf::test::structs_column_wrapper c0_l2_data({c0_l3_ints, c0_l3_floats}, stream, mr); std::vector c0_l2_valids = {1, 1, 1, 0, 0, 1, 1}; auto [null_mask, null_count] = @@ -392,12 +454,13 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) return cudf::purge_nonempty_nulls(tmp->view()); }(); - cudf::test::fixed_width_column_wrapper c1_l1_offsets{0, 0, 0, 2, 2, 5, 5, 5}; - cudf::test::fixed_width_column_wrapper c1_l2_offsets{0, 3, 3, 3, 6, 10}; - cudf::test::fixed_width_column_wrapper c1_l3_ints{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}; - cudf::test::fixed_width_column_wrapper c1_l3_floats{ - 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; - cudf::test::structs_column_wrapper c1_l2_data({c1_l3_ints, c1_l3_floats}); + cudf::test::fixed_width_column_wrapper c1_l1_offsets({0, 0, 0, 2, 2, 5, 5, 5}, stream, mr); + cudf::test::fixed_width_column_wrapper c1_l2_offsets({0, 3, 3, 3, 6, 10}, stream, mr); + cudf::test::fixed_width_column_wrapper c1_l3_ints( + {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}, stream, mr); + cudf::test::fixed_width_column_wrapper c1_l3_floats( + {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, stream, mr); + cudf::test::structs_column_wrapper c1_l2_data({c1_l3_ints, c1_l3_floats}, stream, mr); std::vector c1_l2_valids = {1, 0, 0, 1, 1}; std::tie(null_mask, null_count) = @@ -417,10 +480,12 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) }(); // properties - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(*c0, *c1); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL( + *c0, *c1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); // values - CUDF_TEST_EXPECT_COLUMNS_EQUAL(*c0, *c1); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + *c0, *c1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } } @@ -428,62 +493,80 @@ struct ColumnUtilitiesStructsTest : public cudf::test::BaseFixture {}; TEST_F(ColumnUtilitiesStructsTest, Properties) { - cudf::test::strings_column_wrapper s0_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper s0_scol1{5, 4, 3, 2, 1}; - cudf::test::strings_column_wrapper s0_sscol0{"5555", "4444", "333", "22", "1"}; - cudf::test::fixed_width_column_wrapper s0_sscol1{50, 40, 30, 20, 10}; - cudf::test::lists_column_wrapper s0_sscol2{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}; - cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}); - cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}); + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + + cudf::test::strings_column_wrapper s0_scol0({"mno", "jkl", "ghi", "def", "abc"}, stream, mr); + cudf::test::fixed_width_column_wrapper s0_scol1({5, 4, 3, 2, 1}, stream, mr); + cudf::test::strings_column_wrapper s0_sscol0({"5555", "4444", "333", "22", "1"}, stream, mr); + cudf::test::fixed_width_column_wrapper s0_sscol1({50, 40, 30, 20, 10}, stream, mr); + cudf::test::lists_column_wrapper s0_sscol2( + {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, stream, mr); + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, stream, mr); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, stream, mr); auto all_valid = cuda::make_constant_iterator(true); - cudf::test::strings_column_wrapper s1_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper s1_scol1{5, 4, 3, 2, 1}; - cudf::test::strings_column_wrapper s1_sscol0{"5555", "4444", "333", "22", "1"}; - cudf::test::fixed_width_column_wrapper s1_sscol1{50, 40, 30, 20, 10}; - cudf::test::lists_column_wrapper s1_sscol2{{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, - all_valid}; - cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}); - cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}); + cudf::test::strings_column_wrapper s1_scol0({"mno", "jkl", "ghi", "def", "abc"}, stream, mr); + cudf::test::fixed_width_column_wrapper s1_scol1({5, 4, 3, 2, 1}, stream, mr); + cudf::test::strings_column_wrapper s1_sscol0({"5555", "4444", "333", "22", "1"}, stream, mr); + cudf::test::fixed_width_column_wrapper s1_sscol1({50, 40, 30, 20, 10}, stream, mr); + cudf::test::lists_column_wrapper s1_sscol2( + {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, all_valid, stream, mr); + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, stream, mr); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, stream, mr); // equivalent, but not equal - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT(s_col0, s_col1); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT( + s_col0, s_col1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); EXPECT_FALSE(cudf::test::detail::expect_column_properties_equal( - s_col0, s_col1, cudf::test::debug_output_level::QUIET)); + s_col0, s_col1, cudf::test::debug_output_level::QUIET, stream, mr)); - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(s_col0, s_col0); - CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL(s_col1, s_col1); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL( + s_col0, s_col0, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); + CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUAL( + s_col1, s_col1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } TEST_F(ColumnUtilitiesStructsTest, Values) { - cudf::test::strings_column_wrapper s0_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper s0_scol1{5, 4, 3, 2, 1}; - cudf::test::strings_column_wrapper s0_sscol0{"5555", "4444", "333", "22", "1"}; - cudf::test::fixed_width_column_wrapper s0_sscol1{50, 40, 30, 20, 10}; - cudf::test::lists_column_wrapper s0_sscol2{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}; - cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}); - cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}); + auto stream = cudf::test::get_default_stream(); + auto mr = this->mr(); + + cudf::test::strings_column_wrapper s0_scol0({"mno", "jkl", "ghi", "def", "abc"}, stream, mr); + cudf::test::fixed_width_column_wrapper s0_scol1({5, 4, 3, 2, 1}, stream, mr); + cudf::test::strings_column_wrapper s0_sscol0({"5555", "4444", "333", "22", "1"}, stream, mr); + cudf::test::fixed_width_column_wrapper s0_sscol1({50, 40, 30, 20, 10}, stream, mr); + cudf::test::lists_column_wrapper s0_sscol2( + {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, stream, mr); + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, stream, mr); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, stream, mr); auto all_valid = cuda::make_constant_iterator(true); - cudf::test::strings_column_wrapper s1_scol0{"mno", "jkl", "ghi", "def", "abc"}; - cudf::test::fixed_width_column_wrapper s1_scol1{5, 4, 3, 2, 1}; - cudf::test::strings_column_wrapper s1_sscol0{"5555", "4444", "333", "22", "1"}; - cudf::test::fixed_width_column_wrapper s1_sscol1{50, 40, 30, 20, 10}; - cudf::test::lists_column_wrapper s1_sscol2{{{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, - all_valid}; - cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}); - cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}); + cudf::test::strings_column_wrapper s1_scol0({"mno", "jkl", "ghi", "def", "abc"}, stream, mr); + cudf::test::fixed_width_column_wrapper s1_scol1({5, 4, 3, 2, 1}, stream, mr); + cudf::test::strings_column_wrapper s1_sscol0({"5555", "4444", "333", "22", "1"}, stream, mr); + cudf::test::fixed_width_column_wrapper s1_sscol1({50, 40, 30, 20, 10}, stream, mr); + cudf::test::lists_column_wrapper s1_sscol2( + {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, all_valid, stream, mr); + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, stream, mr); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, stream, mr); // equivalent, but not equal - CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(s_col0, s_col1); + CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(s_col0, + s_col1, + cudf::test::debug_output_level::FIRST_ERROR, + cudf::test::default_ulp, + stream, + mr); EXPECT_FALSE(cudf::test::detail::expect_columns_equal( - s_col0, s_col1, cudf::test::debug_output_level::QUIET)); + s_col0, s_col1, cudf::test::debug_output_level::QUIET, stream, mr)); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col0, s_col0); - CUDF_TEST_EXPECT_COLUMNS_EQUAL(s_col1, s_col1); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + s_col0, s_col0, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); + CUDF_TEST_EXPECT_COLUMNS_EQUAL( + s_col1, s_col1, cudf::test::debug_output_level::FIRST_ERROR, stream, mr); } CUDF_TEST_PROGRAM_MAIN() From 4a02ab8251b13bc071ef20db7d2296839802b6a4 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 12:45:54 -0700 Subject: [PATCH 04/17] fix ctrs Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 84 ++++++------------- cpp/tests/copying/concatenate_tests.cpp | 3 +- cpp/tests/copying/scatter_tests.cpp | 4 +- cpp/tests/encode/encode_tests.cpp | 4 +- cpp/tests/filling/sequence_tests.cpp | 2 +- cpp/tests/interop/dlpack_test.cpp | 4 +- cpp/tests/io/cudftable_test.cpp | 2 +- .../partitioning/hash_partition_test.cpp | 4 +- cpp/tests/quantiles/quantile_test.cpp | 4 +- cpp/tests/quantiles/quantiles_test.cpp | 14 ++-- cpp/tests/reductions/scan_tests.cpp | 8 +- cpp/tests/replace/clamp_test.cpp | 2 +- cpp/tests/replace/replace_nulls_tests.cpp | 2 +- cpp/tests/replace/replace_tests.cpp | 2 +- .../reshape/interleave_columns_tests.cpp | 12 +-- cpp/tests/reshape/table_to_array_tests.cpp | 2 +- cpp/tests/reshape/tile_tests.cpp | 2 +- cpp/tests/rolling/grouped_rolling_test.cpp | 4 +- cpp/tests/rolling/rolling_test.cpp | 2 +- cpp/tests/sort/top_k_tests.cpp | 2 +- cpp/tests/streams/interop_test.cpp | 4 +- cpp/tests/streams/quantile_test.cpp | 2 +- .../integration/unary_transform_test.cpp | 2 +- cpp/tests/transform/mask_to_bools_test.cpp | 6 +- cpp/tests/transform/nans_to_null_test.cpp | 4 +- .../column_utilities_tests.cpp | 20 ++--- 26 files changed, 83 insertions(+), 118 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 7a18a8058720..e199c84f4ab4 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -355,9 +355,8 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - explicit fixed_width_column_wrapper( - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + fixed_width_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { std::vector empty; @@ -822,16 +821,13 @@ class strings_column_wrapper : public detail::column_wrapper { public: /** * @brief Default constructor initializes an empty column of strings - */ - /** - * @brief Initializes an empty strings column on the specified resource * * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - explicit strings_column_wrapper( - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + // Non-explicit so `{}` can copy-initialize empty string columns (e.g. nested in structs). + strings_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : strings_column_wrapper(std::initializer_list{}, stream, mr) { } @@ -1070,18 +1066,16 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty column with dictionary type. - */ - /** - * @brief Initializes an empty dictionary column on the specified resource * * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - explicit dictionary_column_wrapper( - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + // Non-explicit so `{}` can copy-initialize empty dictionary columns. + dictionary_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { + static_cast(stream); static_cast(mr); wrapped = cudf::make_empty_column(cudf::type_id::DICTIONARY32); } @@ -1320,16 +1314,13 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty dictionary column of strings - */ - /** - * @brief Initializes an empty string dictionary column on the specified resource * * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - explicit dictionary_column_wrapper( - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + // Non-explicit so `{}` can copy-initialize empty dictionary columns. + dictionary_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : dictionary_column_wrapper(std::initializer_list{}, stream, mr) { } @@ -1767,7 +1758,7 @@ class lists_column_wrapper : public detail::column_wrapper { } /** - * @brief Construct am empty lists column + * @brief Construct an empty lists column * * Example: * @code{.cpp} @@ -1776,15 +1767,11 @@ class lists_column_wrapper : public detail::column_wrapper { * lists_column_wrapper l{}; * @endcode * - */ - /** - * @brief Construct an empty lists column on the specified resource - * * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - explicit lists_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + lists_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), + cudf::memory_resources mr = cudf::get_current_device_resource_ref()) : column_wrapper{} { build_from_non_nested(make_empty_column(cudf::type_to_id()), stream, mr); @@ -1849,7 +1836,7 @@ class lists_column_wrapper : public detail::column_wrapper { cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); - cudf::test::fixed_width_column_wrapper values(mr); + cudf::test::fixed_width_column_wrapper values(stream, mr); return lists_column_wrapper( 1, offsets.release(), @@ -1857,6 +1844,7 @@ class lists_column_wrapper : public detail::column_wrapper { valid ? 0 : 1, valid ? rmm::device_buffer{} : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr()), + stream, mr); } @@ -2155,6 +2143,9 @@ class structs_column_wrapper : public detail::column_wrapper { * provenance. The supplied output resource controls the struct null mask and any child * allocations created while sanitizing null struct rows. * + * To pass an explicit stream/mr with no parent nulls, pass an empty validity: + * `structs_column_wrapper(std::move(children), {}, stream, mr)`. + * * @param child_columns The vector of pre-constructed child columns * @param validity The vector of bools representing the column validity values * @param stream CUDA stream used for device memory operations @@ -2168,20 +2159,6 @@ class structs_column_wrapper : public detail::column_wrapper { init(std::move(child_columns), validity, stream, mr); } - /** - * @brief Constructs a struct column by adopting child columns with no parent nulls. - * - * @param child_columns The vector of pre-constructed child columns - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used for new allocations owned by the returned column - */ - structs_column_wrapper(std::vector>&& child_columns, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : structs_column_wrapper(std::move(child_columns), std::vector{}, stream, mr) - { - } - /** * @brief Constructs a struct column from the list of column wrappers for child columns. * @@ -2202,6 +2179,9 @@ class structs_column_wrapper : public detail::column_wrapper { * Child wrappers are deep-copied, so all allocations in the returned children use the supplied * output resource. The source wrappers retain their original allocations. * + * To pass an explicit stream/mr with no parent nulls, pass an empty validity: + * `structs_column_wrapper({wrappers}, {}, stream, mr)`. + * * @param child_column_wrappers The list of child column wrappers * @param validity The vector of bools representing the column validity values * @param stream CUDA stream used for device memory operations @@ -2225,21 +2205,6 @@ class structs_column_wrapper : public detail::column_wrapper { init(std::move(child_columns), validity, stream, mr); } - /** - * @brief Constructs a struct column by copying child wrappers with no parent nulls. - * - * @param child_column_wrappers The list of child column wrappers - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column - */ - structs_column_wrapper( - std::initializer_list> child_column_wrappers, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : structs_column_wrapper(child_column_wrappers, std::vector{}, stream, mr) - { - } - /** * @brief Constructs a struct column from the list of column wrappers for child columns. * @@ -2263,7 +2228,8 @@ class structs_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column */ template >* = nullptr> + std::enable_if_t && + !std::is_convertible_v>* = nullptr> structs_column_wrapper( std::initializer_list> child_column_wrappers, V validity_iter, diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index 8875add31856..6f42323bfe99 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -823,8 +823,7 @@ TEST_F(StructsColumnTest, ConcatenateStructs) {true, false})); src.push_back(cudf::test::structs_column_wrapper({name_cols[1], age_cols[1], is_human_cols[1]}, {true, true})); - src.push_back( - cudf::test::structs_column_wrapper({name_cols[2], age_cols[2], is_human_cols[2]}, {})); + src.push_back(cudf::test::structs_column_wrapper({name_cols[2], age_cols[2], is_human_cols[2]})); src.push_back(cudf::test::structs_column_wrapper({name_cols[3], age_cols[3], is_human_cols[3]}, {true, false})); diff --git a/cpp/tests/copying/scatter_tests.cpp b/cpp/tests/copying/scatter_tests.cpp index b23ecdcee24f..e3f3450e6606 100644 --- a/cpp/tests/copying/scatter_tests.cpp +++ b/cpp/tests/copying/scatter_tests.cpp @@ -220,7 +220,7 @@ TYPED_TEST(ScatterDataTypeTests, EmptyScatterMap) cudf::test::fixed_width_column_wrapper source({1, 2, 3, 4, 5, 6}); cudf::test::fixed_width_column_wrapper target( {10, 20, 30, 40, 50, 60, 70, 80}); - cudf::test::fixed_width_column_wrapper scatter_map({}); + cudf::test::fixed_width_column_wrapper scatter_map{}; auto const source_table = cudf::table_view({source, source}); auto const target_table = cudf::table_view({target, target}); @@ -241,7 +241,7 @@ TYPED_TEST(ScatterDataTypeTests, EmptyScalarScatterMap) cudf::test::fixed_width_column_wrapper target( {10, 20, 30, 40, 50, 60, 70, 80}); - cudf::test::fixed_width_column_wrapper scatter_map({}); + cudf::test::fixed_width_column_wrapper scatter_map{}; auto const target_table = cudf::table_view({target}); diff --git a/cpp/tests/encode/encode_tests.cpp b/cpp/tests/encode/encode_tests.cpp index 25f38fa89b71..b9c8bcaeb47b 100644 --- a/cpp/tests/encode/encode_tests.cpp +++ b/cpp/tests/encode/encode_tests.cpp @@ -31,8 +31,8 @@ TYPED_TEST(EncodeNumericTests, SingleNullEncode) TYPED_TEST(EncodeNumericTests, EmptyEncode) { - cudf::test::fixed_width_column_wrapper input({}); - cudf::test::fixed_width_column_wrapper expect({}); + cudf::test::fixed_width_column_wrapper input{}; + cudf::test::fixed_width_column_wrapper expect{}; auto const result = cudf::encode(cudf::table_view({input})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result.second->view(), expect); diff --git a/cpp/tests/filling/sequence_tests.cpp b/cpp/tests/filling/sequence_tests.cpp index 7ec3188a6ae4..a6180f45d847 100644 --- a/cpp/tests/filling/sequence_tests.cpp +++ b/cpp/tests/filling/sequence_tests.cpp @@ -62,7 +62,7 @@ TYPED_TEST(SequenceTypedTestFixture, EmptyOutput) cudf::size_type num_els = 0; - cudf::test::fixed_width_column_wrapper expected_w({}); + cudf::test::fixed_width_column_wrapper expected_w{}; auto result = cudf::sequence(num_els, init, step); diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index a3d0234b7c0d..b3b1fc4a7151 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -63,8 +63,8 @@ TEST_F(DLPackUntypedTests, EmptyTableToDlpack) TEST_F(DLPackUntypedTests, EmptyColsToDlpack) { - cudf::test::fixed_width_column_wrapper col1({}); - cudf::test::fixed_width_column_wrapper col2({}); + cudf::test::fixed_width_column_wrapper col1{}; + cudf::test::fixed_width_column_wrapper col2{}; cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input)); validate_dtype(tensor->dl_tensor.dtype); diff --git a/cpp/tests/io/cudftable_test.cpp b/cpp/tests/io/cudftable_test.cpp index 63859cb99d30..96ecf94eb707 100644 --- a/cpp/tests/io/cudftable_test.cpp +++ b/cpp/tests/io/cudftable_test.cpp @@ -108,7 +108,7 @@ TEST_F(CudftableTest, MultiColumnFixedWidth) TEST_F(CudftableTest, EmptyColumn) { - cudf::test::fixed_width_column_wrapper empty_col({}); + cudf::test::fixed_width_column_wrapper empty_col{}; auto const expected = cudf::table_view{{empty_col}}; run_test(expected); diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index 0a9d4f4992fc..aa0017007745 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -90,8 +90,8 @@ TEST_F(HashPartition, ZeroPartitions) TEST_F(HashPartition, ZeroRows) { - fixed_width_column_wrapper floats({}); - fixed_width_column_wrapper integers({}); + fixed_width_column_wrapper floats{}; + fixed_width_column_wrapper integers{}; strings_column_wrapper strings; auto input = cudf::table_view({floats, integers, strings}); diff --git a/cpp/tests/quantiles/quantile_test.cpp b/cpp/tests/quantiles/quantile_test.cpp index 2096fc2e4ce9..d03c4cfe5640 100644 --- a/cpp/tests/quantiles/quantile_test.cpp +++ b/cpp/tests/quantiles/quantile_test.cpp @@ -413,7 +413,7 @@ TYPED_TEST(QuantileTest, TestInterpolateExtremaLow) TYPED_TEST(QuantileTest, TestEmpty) { - auto input = cudf::test::fixed_width_column_wrapper({}); + auto input = cudf::test::fixed_width_column_wrapper(); auto expected = cudf::test::fixed_width_column_wrapper({0, 0}, {false, false}); auto actual = cudf::quantile(input, {0.5, 0.25}); } @@ -429,7 +429,7 @@ TYPED_TEST_SUITE(QuantileUnsupportedTypesTest, UnsupportedTestTypes); TYPED_TEST(QuantileUnsupportedTypesTest, TestZeroElements) { - cudf::test::fixed_width_column_wrapper input({}); + cudf::test::fixed_width_column_wrapper input{}; EXPECT_THROW(cudf::quantile(input, {0}), cudf::logic_error); } diff --git a/cpp/tests/quantiles/quantiles_test.cpp b/cpp/tests/quantiles/quantiles_test.cpp index 08cba6cf18ce..3b590f0446f2 100644 --- a/cpp/tests/quantiles/quantiles_test.cpp +++ b/cpp/tests/quantiles/quantiles_test.cpp @@ -33,7 +33,7 @@ TYPED_TEST(QuantilesTest, TestMultiColumnZeroRows) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_a{}; auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, {0.0f}), cudf::logic_error); @@ -56,8 +56,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnOrderCountMismatch) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a({}); - cudf::test::fixed_width_column_wrapper input_b({}); + cudf::test::fixed_width_column_wrapper input_a{}; + cudf::test::fixed_width_column_wrapper input_b{}; auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, @@ -73,8 +73,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnNullOrderCountMismatch) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a({}); - cudf::test::fixed_width_column_wrapper input_b({}); + cudf::test::fixed_width_column_wrapper input_a{}; + cudf::test::fixed_width_column_wrapper input_b{}; auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, @@ -90,8 +90,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnArithmeticInterpolation) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a({}); - cudf::test::fixed_width_column_wrapper input_b({}); + cudf::test::fixed_width_column_wrapper input_a{}; + cudf::test::fixed_width_column_wrapper input_b{}; auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, {0.0f}, cudf::interpolation::LINEAR), std::invalid_argument); diff --git a/cpp/tests/reductions/scan_tests.cpp b/cpp/tests/reductions/scan_tests.cpp index 64493c818f3f..2b0b65375e89 100644 --- a/cpp/tests/reductions/scan_tests.cpp +++ b/cpp/tests/reductions/scan_tests.cpp @@ -386,8 +386,8 @@ TYPED_TEST_SUITE(ScanEmptyTest, cudf::test::NumericTypes); TYPED_TEST(ScanEmptyTest, MinInclusive) { - cudf::test::fixed_width_column_wrapper col({}); - cudf::test::fixed_width_column_wrapper expected({}); + cudf::test::fixed_width_column_wrapper col{}; + cudf::test::fixed_width_column_wrapper expected{}; auto result = cudf::scan( col, *cudf::make_min_aggregation(), cudf::scan_type::INCLUSIVE); @@ -396,8 +396,8 @@ TYPED_TEST(ScanEmptyTest, MinInclusive) TYPED_TEST(ScanEmptyTest, MinExclusive) { - cudf::test::fixed_width_column_wrapper col({}); - cudf::test::fixed_width_column_wrapper expected({}); + cudf::test::fixed_width_column_wrapper col{}; + cudf::test::fixed_width_column_wrapper expected{}; auto result = cudf::scan( col, *cudf::make_min_aggregation(), cudf::scan_type::EXCLUSIVE); diff --git a/cpp/tests/replace/clamp_test.cpp b/cpp/tests/replace/clamp_test.cpp index 2a198d3b18bb..bb1060dcdc79 100644 --- a/cpp/tests/replace/clamp_test.cpp +++ b/cpp/tests/replace/clamp_test.cpp @@ -116,7 +116,7 @@ TEST_F(ClampEmptyCaseTest, EmptyInput) auto hi = cudf::make_numeric_scalar(cudf::data_type(cudf::type_id::INT32)); hi->set_valid_async(true); - cudf::test::fixed_width_column_wrapper input({}); + cudf::test::fixed_width_column_wrapper input{}; auto got = cudf::clamp(input, *lo, *hi); diff --git a/cpp/tests/replace/replace_nulls_tests.cpp b/cpp/tests/replace/replace_nulls_tests.cpp index 7f15fef2c270..363b32daf88e 100644 --- a/cpp/tests/replace/replace_nulls_tests.cpp +++ b/cpp/tests/replace/replace_nulls_tests.cpp @@ -663,7 +663,7 @@ TEST_F(ReplaceDictionaryTest, ReplaceNullsError) TEST_F(ReplaceDictionaryTest, ReplaceNullsEmpty) { - cudf::test::fixed_width_column_wrapper input_empty_w({}); + cudf::test::fixed_width_column_wrapper input_empty_w{}; auto input_empty = cudf::dictionary::encode(input_empty_w); auto result = cudf::replace_nulls(input_empty->view(), input_empty->view()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), input_empty->view()); diff --git a/cpp/tests/replace/replace_tests.cpp b/cpp/tests/replace/replace_tests.cpp index 3c0185a46fd1..1ee6d2f006e9 100644 --- a/cpp/tests/replace/replace_tests.cpp +++ b/cpp/tests/replace/replace_tests.cpp @@ -615,7 +615,7 @@ TEST_F(ReplaceDictionaryTest, EmptyReplacement) cudf::test::fixed_width_column_wrapper input_w( {1.0, 2.0, 1.0, 2.0, 0.0, 3.0, 4.0, 4.0, 3.0}, {1, 1, 1, 1, 0, 1, 1, 1, 1}); auto input = cudf::dictionary::encode(input_w); - cudf::test::fixed_width_column_wrapper empty_w({}); + cudf::test::fixed_width_column_wrapper empty_w{}; auto empty = cudf::dictionary::encode(empty_w); auto result = cudf::find_and_replace_all(input->view(), empty->view(), empty->view()); diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 66dc44a8e790..989945bf9cab 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -88,11 +88,11 @@ TYPED_TEST(InterleaveColumnsTest, OneColumnEmpty) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper a({}); + cudf::test::fixed_width_column_wrapper a{}; cudf::table_view in(std::vector{a}); - auto expected = cudf::test::fixed_width_column_wrapper({}); + auto expected = cudf::test::fixed_width_column_wrapper(); auto actual = cudf::interleave_columns(in); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view()); @@ -102,13 +102,13 @@ TYPED_TEST(InterleaveColumnsTest, ThreeColumnsEmpty) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper a({}); - cudf::test::fixed_width_column_wrapper b({}); - cudf::test::fixed_width_column_wrapper c({}); + cudf::test::fixed_width_column_wrapper a{}; + cudf::test::fixed_width_column_wrapper b{}; + cudf::test::fixed_width_column_wrapper c{}; cudf::table_view in(std::vector{a, b, c}); - auto expected = cudf::test::fixed_width_column_wrapper({}); + auto expected = cudf::test::fixed_width_column_wrapper(); auto actual = cudf::interleave_columns(in); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view()); diff --git a/cpp/tests/reshape/table_to_array_tests.cpp b/cpp/tests/reshape/table_to_array_tests.cpp index 89e7a72334db..af3054ee6e72 100644 --- a/cpp/tests/reshape/table_to_array_tests.cpp +++ b/cpp/tests/reshape/table_to_array_tests.cpp @@ -180,7 +180,7 @@ TEST(TableToDeviceArrayTest, NoRows) { auto stream = cudf::get_default_stream(); - cudf::test::fixed_width_column_wrapper col({}); + cudf::test::fixed_width_column_wrapper col{}; cudf::table_view input_table({col}); rmm::device_buffer output(0, stream); diff --git a/cpp/tests/reshape/tile_tests.cpp b/cpp/tests/reshape/tile_tests.cpp index 50be2837d4c6..5b89f5403a77 100644 --- a/cpp/tests/reshape/tile_tests.cpp +++ b/cpp/tests/reshape/tile_tests.cpp @@ -32,7 +32,7 @@ TYPED_TEST(TileTest, NoRows) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper in_a({}); + cudf::test::fixed_width_column_wrapper in_a{}; cudf::table_view in(std::vector{in_a}); auto expected = in; diff --git a/cpp/tests/rolling/grouped_rolling_test.cpp b/cpp/tests/rolling/grouped_rolling_test.cpp index b568a909ff0e..e0bebb6b86ea 100644 --- a/cpp/tests/rolling/grouped_rolling_test.cpp +++ b/cpp/tests/rolling/grouped_rolling_test.cpp @@ -420,7 +420,7 @@ class GroupedRollingTest : public cudf::test::BaseFixture { std::conditional_t, int64_t, T>, false>( input, group_offsets, preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper({}).release(); + default: return cudf::test::fixed_width_column_wrapper().release(); } } }; @@ -1156,7 +1156,7 @@ class GroupedTimeRangeRollingTest : public cudf::test::BaseFixture { preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper({}).release(); + default: return cudf::test::fixed_width_column_wrapper().release(); } } }; diff --git a/cpp/tests/rolling/rolling_test.cpp b/cpp/tests/rolling/rolling_test.cpp index a2f178499388..a3a76eacd2ea 100644 --- a/cpp/tests/rolling/rolling_test.cpp +++ b/cpp/tests/rolling/rolling_test.cpp @@ -601,7 +601,7 @@ class RollingTest : public cudf::test::BaseFixture { std::conditional_t(), T, double>, true>( input, preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper({}).release(); + default: return cudf::test::fixed_width_column_wrapper().release(); } } }; diff --git a/cpp/tests/sort/top_k_tests.cpp b/cpp/tests/sort/top_k_tests.cpp index d761c6e30125..abf2258fc5f4 100644 --- a/cpp/tests/sort/top_k_tests.cpp +++ b/cpp/tests/sort/top_k_tests.cpp @@ -424,7 +424,7 @@ TEST_F(TopK, Errors) auto offsets = cudf::test::fixed_width_column_wrapper({0, 15, 20, 23, 40, 42}); EXPECT_THROW(cudf::segmented_top_k(input, offsets, -1), std::invalid_argument); EXPECT_THROW(cudf::segmented_top_k_order(input, offsets, -1), std::invalid_argument); - offsets = cudf::test::fixed_width_column_wrapper({}); + offsets = cudf::test::fixed_width_column_wrapper(); EXPECT_THROW(cudf::segmented_top_k(input, offsets, 10), std::invalid_argument); EXPECT_THROW(cudf::segmented_top_k_order(input, offsets, 10), std::invalid_argument); offsets = cudf::test::fixed_width_column_wrapper({0, 15}, {1, 0}); diff --git a/cpp/tests/streams/interop_test.cpp b/cpp/tests/streams/interop_test.cpp index 484c288e8a21..3e8080133523 100644 --- a/cpp/tests/streams/interop_test.cpp +++ b/cpp/tests/streams/interop_test.cpp @@ -30,8 +30,8 @@ TEST_F(DLPackTest, ToDLPack) TEST_F(DLPackTest, FromDLPack) { using unique_managed_tensor = std::unique_ptr; - cudf::test::fixed_width_column_wrapper col1({}); - cudf::test::fixed_width_column_wrapper col2({}); + cudf::test::fixed_width_column_wrapper col1{}; + cudf::test::fixed_width_column_wrapper col2{}; cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input, cudf::test::get_default_stream())); auto result = cudf::from_dlpack(tensor.get(), cudf::test::get_default_stream()); diff --git a/cpp/tests/streams/quantile_test.cpp b/cpp/tests/streams/quantile_test.cpp index 98e188a679b9..97c48b99620c 100644 --- a/cpp/tests/streams/quantile_test.cpp +++ b/cpp/tests/streams/quantile_test.cpp @@ -42,7 +42,7 @@ TEST_F(QuantileTest, TestMultiColumnUnsorted) TEST_F(QuantileTest, TestEmpty) { - auto input = cudf::test::fixed_width_column_wrapper({}); + auto input = cudf::test::fixed_width_column_wrapper(); cudf::quantile( input, {0.5, 0.25}, cudf::interpolation::LINEAR, {}, true, cudf::test::get_default_stream()); } diff --git a/cpp/tests/transform/integration/unary_transform_test.cpp b/cpp/tests/transform/integration/unary_transform_test.cpp index 528ef661cda6..c358f3ef1322 100644 --- a/cpp/tests/transform/integration/unary_transform_test.cpp +++ b/cpp/tests/transform/integration/unary_transform_test.cpp @@ -674,7 +674,7 @@ __device__ inline void decode(float * output, float input){ // empty column { - auto a_empty = cudf::test::fixed_width_column_wrapper({}).release(); + auto a_empty = cudf::test::fixed_width_column_wrapper().release(); auto a_encoded = cudf::dictionary::encode(a_empty->view()); cudf::transform_input inputs[] = {*a_encoded}; diff --git a/cpp/tests/transform/mask_to_bools_test.cpp b/cpp/tests/transform/mask_to_bools_test.cpp index 047b53beee62..2f7633d4ff23 100644 --- a/cpp/tests/transform/mask_to_bools_test.cpp +++ b/cpp/tests/transform/mask_to_bools_test.cpp @@ -17,7 +17,7 @@ struct MaskToBools : public cudf::test::BaseFixture {}; TEST_F(MaskToBools, NullDataWithZeroLength) { - auto expected = cudf::test::fixed_width_column_wrapper({}); + auto expected = cudf::test::fixed_width_column_wrapper(); auto out = cudf::mask_to_bools(nullptr, 0, 0); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, out->view()); @@ -25,14 +25,14 @@ TEST_F(MaskToBools, NullDataWithZeroLength) TEST_F(MaskToBools, NullDataWithNonZeroLength) { - auto expected = cudf::test::fixed_width_column_wrapper({}); + auto expected = cudf::test::fixed_width_column_wrapper(); EXPECT_THROW(cudf::mask_to_bools(nullptr, 0, 2), cudf::logic_error); } TEST_F(MaskToBools, ImproperBitRange) { - auto expected = cudf::test::fixed_width_column_wrapper({}); + auto expected = cudf::test::fixed_width_column_wrapper(); EXPECT_THROW(cudf::mask_to_bools(nullptr, 2, 1), cudf::logic_error); } diff --git a/cpp/tests/transform/nans_to_null_test.cpp b/cpp/tests/transform/nans_to_null_test.cpp index f9d6c6aca573..822b3c962bc8 100644 --- a/cpp/tests/transform/nans_to_null_test.cpp +++ b/cpp/tests/transform/nans_to_null_test.cpp @@ -116,7 +116,7 @@ TYPED_TEST(NaNsToNullTest, EmptyColumn) { using T = TypeParam; - auto input_column = cudf::test::fixed_width_column_wrapper({}); + auto input_column = cudf::test::fixed_width_column_wrapper(); this->run_test(input_column, input_column); } @@ -141,6 +141,6 @@ TEST_F(NaNsToNullFailTest, IntegerType) TEST_F(NaNsToNullFailTest, EmptyColumn) { - auto input_column = cudf::test::fixed_width_column_wrapper({}); + auto input_column = cudf::test::fixed_width_column_wrapper(); EXPECT_THROW(cudf::column_nans_to_nulls(input_column), std::invalid_argument); } diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index a7af3fc4b901..f90a213f0803 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -435,7 +435,7 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) {1, 1, -1, -2, -3, 1, 1, -4, -5, -6, -7, -8, -9, -10}, stream, mr); cudf::test::fixed_width_column_wrapper c0_l3_floats( {1, 1, 10, 20, 30, 1, 1, 40, 50, 60, 70, 80, 90, 100}, stream, mr); - cudf::test::structs_column_wrapper c0_l2_data({c0_l3_ints, c0_l3_floats}, stream, mr); + cudf::test::structs_column_wrapper c0_l2_data({c0_l3_ints, c0_l3_floats}, {}, stream, mr); std::vector c0_l2_valids = {1, 1, 1, 0, 0, 1, 1}; auto [null_mask, null_count] = @@ -460,7 +460,7 @@ TEST_F(ColumnUtilitiesListsTest, DifferentPhysicalStructureBeforeConstruction) {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}, stream, mr); cudf::test::fixed_width_column_wrapper c1_l3_floats( {10, 20, 30, 40, 50, 60, 70, 80, 90, 100}, stream, mr); - cudf::test::structs_column_wrapper c1_l2_data({c1_l3_ints, c1_l3_floats}, stream, mr); + cudf::test::structs_column_wrapper c1_l2_data({c1_l3_ints, c1_l3_floats}, {}, stream, mr); std::vector c1_l2_valids = {1, 0, 0, 1, 1}; std::tie(null_mask, null_count) = @@ -502,8 +502,8 @@ TEST_F(ColumnUtilitiesStructsTest, Properties) cudf::test::fixed_width_column_wrapper s0_sscol1({50, 40, 30, 20, 10}, stream, mr); cudf::test::lists_column_wrapper s0_sscol2( {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, stream, mr); - cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, stream, mr); - cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, stream, mr); + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, {}, stream, mr); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, {}, stream, mr); auto all_valid = cuda::make_constant_iterator(true); @@ -513,8 +513,8 @@ TEST_F(ColumnUtilitiesStructsTest, Properties) cudf::test::fixed_width_column_wrapper s1_sscol1({50, 40, 30, 20, 10}, stream, mr); cudf::test::lists_column_wrapper s1_sscol2( {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, all_valid, stream, mr); - cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, stream, mr); - cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, stream, mr); + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, {}, stream, mr); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, {}, stream, mr); // equivalent, but not equal CUDF_TEST_EXPECT_COLUMN_PROPERTIES_EQUIVALENT( @@ -539,8 +539,8 @@ TEST_F(ColumnUtilitiesStructsTest, Values) cudf::test::fixed_width_column_wrapper s0_sscol1({50, 40, 30, 20, 10}, stream, mr); cudf::test::lists_column_wrapper s0_sscol2( {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, stream, mr); - cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, stream, mr); - cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, stream, mr); + cudf::test::structs_column_wrapper s0_scol2({s0_sscol0, s0_sscol1, s0_sscol2}, {}, stream, mr); + cudf::test::structs_column_wrapper s_col0({s0_scol0, s0_scol1, s0_scol2}, {}, stream, mr); auto all_valid = cuda::make_constant_iterator(true); @@ -550,8 +550,8 @@ TEST_F(ColumnUtilitiesStructsTest, Values) cudf::test::fixed_width_column_wrapper s1_sscol1({50, 40, 30, 20, 10}, stream, mr); cudf::test::lists_column_wrapper s1_sscol2( {{1, 2}, {3, 4}, {5}, {6, 7, 8}, {12, 12}}, all_valid, stream, mr); - cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, stream, mr); - cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, stream, mr); + cudf::test::structs_column_wrapper s1_scol2({s1_sscol0, s1_sscol1, s1_sscol2}, {}, stream, mr); + cudf::test::structs_column_wrapper s_col1({s1_scol0, s1_scol1, s1_scol2}, {}, stream, mr); // equivalent, but not equal CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(s_col0, From 8479c3d212cc0a877b6610cc20c3f9c6a9692f0d Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 13:33:05 -0700 Subject: [PATCH 05/17] precommit Signed-off-by: niranda perera --- cpp/tests/encode/encode_tests.cpp | 2 +- cpp/tests/filling/sequence_tests.cpp | 2 +- cpp/tests/interop/dlpack_test.cpp | 2 +- cpp/tests/partitioning/hash_partition_test.cpp | 2 +- cpp/tests/quantiles/quantile_test.cpp | 2 +- cpp/tests/quantiles/quantiles_test.cpp | 2 +- cpp/tests/reductions/scan_tests.cpp | 2 +- cpp/tests/replace/clamp_test.cpp | 2 +- cpp/tests/replace/replace_nulls_tests.cpp | 2 +- cpp/tests/reshape/interleave_columns_tests.cpp | 2 +- cpp/tests/reshape/table_to_array_tests.cpp | 2 +- cpp/tests/reshape/tile_tests.cpp | 2 +- cpp/tests/streams/interop_test.cpp | 2 +- cpp/tests/streams/quantile_test.cpp | 2 +- cpp/tests/transform/mask_to_bools_test.cpp | 2 +- cpp/tests/transform/nans_to_null_test.cpp | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cpp/tests/encode/encode_tests.cpp b/cpp/tests/encode/encode_tests.cpp index b9c8bcaeb47b..246caae0eab7 100644 --- a/cpp/tests/encode/encode_tests.cpp +++ b/cpp/tests/encode/encode_tests.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 */ #include diff --git a/cpp/tests/filling/sequence_tests.cpp b/cpp/tests/filling/sequence_tests.cpp index a6180f45d847..0b115e10513d 100644 --- a/cpp/tests/filling/sequence_tests.cpp +++ b/cpp/tests/filling/sequence_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index b3b1fc4a7151..8a3f06ecdf74 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index aa0017007745..45bdf877c43b 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ #include diff --git a/cpp/tests/quantiles/quantile_test.cpp b/cpp/tests/quantiles/quantile_test.cpp index d03c4cfe5640..21faae40ba7d 100644 --- a/cpp/tests/quantiles/quantile_test.cpp +++ b/cpp/tests/quantiles/quantile_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/quantiles/quantiles_test.cpp b/cpp/tests/quantiles/quantiles_test.cpp index 3b590f0446f2..e8bc44de1fc2 100644 --- a/cpp/tests/quantiles/quantiles_test.cpp +++ b/cpp/tests/quantiles/quantiles_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 */ diff --git a/cpp/tests/reductions/scan_tests.cpp b/cpp/tests/reductions/scan_tests.cpp index 2b0b65375e89..2caf981c7de9 100644 --- a/cpp/tests/reductions/scan_tests.cpp +++ b/cpp/tests/reductions/scan_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/replace/clamp_test.cpp b/cpp/tests/replace/clamp_test.cpp index bb1060dcdc79..81c15ad8b360 100644 --- a/cpp/tests/replace/clamp_test.cpp +++ b/cpp/tests/replace/clamp_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/replace/replace_nulls_tests.cpp b/cpp/tests/replace/replace_nulls_tests.cpp index 363b32daf88e..ead5f233a788 100644 --- a/cpp/tests/replace/replace_nulls_tests.cpp +++ b/cpp/tests/replace/replace_nulls_tests.cpp @@ -1,7 +1,7 @@ /* * SPDX-FileCopyrightText: Copyright 2018 BlazingDB, Inc. * SPDX-FileCopyrightText: Copyright 2018 Alexander Ocsa - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ /* diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 989945bf9cab..1b32f8519bc8 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/reshape/table_to_array_tests.cpp b/cpp/tests/reshape/table_to_array_tests.cpp index af3054ee6e72..9009d36cb560 100644 --- a/cpp/tests/reshape/table_to_array_tests.cpp +++ b/cpp/tests/reshape/table_to_array_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/reshape/tile_tests.cpp b/cpp/tests/reshape/tile_tests.cpp index 5b89f5403a77..63424dc6fda7 100644 --- a/cpp/tests/reshape/tile_tests.cpp +++ b/cpp/tests/reshape/tile_tests.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 */ diff --git a/cpp/tests/streams/interop_test.cpp b/cpp/tests/streams/interop_test.cpp index 3e8080133523..bc944922ba9f 100644 --- a/cpp/tests/streams/interop_test.cpp +++ b/cpp/tests/streams/interop_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/streams/quantile_test.cpp b/cpp/tests/streams/quantile_test.cpp index 97c48b99620c..554b28738801 100644 --- a/cpp/tests/streams/quantile_test.cpp +++ b/cpp/tests/streams/quantile_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/transform/mask_to_bools_test.cpp b/cpp/tests/transform/mask_to_bools_test.cpp index 2f7633d4ff23..686b02f90061 100644 --- a/cpp/tests/transform/mask_to_bools_test.cpp +++ b/cpp/tests/transform/mask_to_bools_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ diff --git a/cpp/tests/transform/nans_to_null_test.cpp b/cpp/tests/transform/nans_to_null_test.cpp index 822b3c962bc8..a1c3652fe7f8 100644 --- a/cpp/tests/transform/nans_to_null_test.cpp +++ b/cpp/tests/transform/nans_to_null_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 */ From 20eddfd82090aea2847676e4a66ad4cee2062021 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 13:40:48 -0700 Subject: [PATCH 06/17] remove defaults Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index e199c84f4ab4..a2e3e608070a 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -156,11 +156,10 @@ template ()>* = nullptr> -rmm::device_buffer make_elements( - InputIterator begin, - InputIterator end, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) +rmm::device_buffer make_elements(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { static_assert(cudf::is_fixed_width(), "Unexpected non-fixed width type."); auto transformer = fixed_width_type_converter{}; @@ -191,11 +190,10 @@ template () and cudf::is_fixed_point()>* = nullptr> -rmm::device_buffer make_elements( - InputIterator begin, - InputIterator end, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) +rmm::device_buffer make_elements(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { using RepType = typename ElementTo::rep; auto transformer = fixed_width_type_converter{}; @@ -222,11 +220,10 @@ template () and cudf::is_fixed_point()>* = nullptr> -rmm::device_buffer make_elements( - InputIterator begin, - InputIterator end, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) +rmm::device_buffer make_elements(InputIterator begin, + InputIterator end, + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { using namespace numeric; using RepType = typename ElementTo::rep; From 2e4d5a8a4086a7d682a6b6aeeb101148cab3bfdd Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 14:15:14 -0700 Subject: [PATCH 07/17] code rabbit suggestions Signed-off-by: niranda perera --- cpp/tests/utilities_tests/column_utilities_tests.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/tests/utilities_tests/column_utilities_tests.cpp b/cpp/tests/utilities_tests/column_utilities_tests.cpp index f90a213f0803..ae55a56948bc 100644 --- a/cpp/tests/utilities_tests/column_utilities_tests.cpp +++ b/cpp/tests/utilities_tests/column_utilities_tests.cpp @@ -81,7 +81,7 @@ TYPED_TEST(ColumnUtilitiesTest, NonNullableToHostWithOffset) cudf::test::fixed_width_column_wrapper(data.begin(), data.end(), stream, mr); auto const splits = std::vector{split}; - auto result = cudf::split(col, splits); + auto result = cudf::split(col, splits, stream); auto host_data = cudf::test::to_host(result.back(), stream, mr); @@ -106,7 +106,7 @@ TYPED_TEST(ColumnUtilitiesTest, NullableToHostWithOffset) data.begin(), data.end(), valid, stream, mr); std::vector splits{split}; - std::vector result = cudf::split(col, splits); + std::vector result = cudf::split(col, splits, stream); auto host_data = cudf::test::to_host(result.back(), stream, mr); @@ -307,7 +307,7 @@ TYPED_TEST(ColumnUtilitiesTestFixedPoint, NonNullableToHostWithOffset) auto const col = cudf::test::fixed_point_column_wrapper(reps, reps + size, scale, stream, mr); auto const splits = std::vector{split}; - auto result = cudf::split(col, splits); + auto result = cudf::split(col, splits, stream); auto host_data = cudf::test::to_host(result.back(), stream, mr); From 32b153df91df3250fb402c837979918b0e21726a Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 14:15:51 -0700 Subject: [PATCH 08/17] addng failing default mr Signed-off-by: niranda perera --- .../utilities_tests/column_wrapper_tests.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 4049f708078e..66daaec801f5 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -16,6 +16,8 @@ #include +#include + using cudf::test::expect_output_uses_distinct_resources; using cudf::test::temporary_allocation_expectation; @@ -208,12 +210,23 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporary /** * @brief Base fixture that instruments column-wrapper tests with a memory-resource harness. * - * Each test instantiates a fresh harness. Tests should construct wrappers with `resources()` and - * pass the released column to `validate_with_harness()` before returning. `TearDown` asserts that - * no output or temporary allocations remain live. + * Each test instantiates a fresh harness. `SetUp` installs a current device resource that throws on + * allocation so accidental fallback to the default MR fails the test. Tests should construct + * wrappers with `resources()` and pass the released column to `validate_with_harness()` before + * returning. `TearDown` restores the prior current resource and asserts that no output or temporary + * allocations remain live. */ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { - void TearDown() override { _harness.expect_no_live_allocations(this->stream()); } + void SetUp() override + { + _fail_on_current.emplace(_harness.fail_on_current_device_resource_use()); + } + + void TearDown() override + { + _fail_on_current.reset(); + _harness.expect_no_live_allocations(this->stream()); + } rmm::cuda_stream_view stream() const { return cudf::test::get_default_stream(); } @@ -232,7 +245,9 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { } private: + // Constructed before SetUp so its upstream is the real current resource. cudf::test::memory_resource_test_harness _harness{}; + std::optional _fail_on_current; }; template From 3cab3a696cdfb50e43c010318749207c0f06560e Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 15:25:11 -0700 Subject: [PATCH 09/17] fix ctr Signed-off-by: niranda perera --- .../utilities_tests/column_wrapper_tests.cpp | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 66daaec801f5..06f26b81db88 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -16,8 +16,6 @@ #include -#include - using cudf::test::expect_output_uses_distinct_resources; using cudf::test::temporary_allocation_expectation; @@ -210,23 +208,14 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporary /** * @brief Base fixture that instruments column-wrapper tests with a memory-resource harness. * - * Each test instantiates a fresh harness. `SetUp` installs a current device resource that throws on - * allocation so accidental fallback to the default MR fails the test. Tests should construct - * wrappers with `resources()` and pass the released column to `validate_with_harness()` before - * returning. `TearDown` restores the prior current resource and asserts that no output or temporary - * allocations remain live. + * Each test instantiates a fresh harness. The failing current-device-resource scope is installed in + * the fixture constructor (after `_harness`) so accidental fallback to the default MR fails the + * test. Tests should construct wrappers with `resources()` and pass the released column to + * `validate_with_harness()` before returning. `TearDown` asserts that no output or temporary + * allocations remain live; the prior current resource is restored when the fixture is destroyed. */ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { - void SetUp() override - { - _fail_on_current.emplace(_harness.fail_on_current_device_resource_use()); - } - - void TearDown() override - { - _fail_on_current.reset(); - _harness.expect_no_live_allocations(this->stream()); - } + void TearDown() override { _harness.expect_no_live_allocations(this->stream()); } rmm::cuda_stream_view stream() const { return cudf::test::get_default_stream(); } @@ -245,9 +234,9 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { } private: - // Constructed before SetUp so its upstream is the real current resource. cudf::test::memory_resource_test_harness _harness{}; - std::optional _fail_on_current; + cudf::test::scoped_current_device_resource _fail_on_current{ + _harness.fail_on_current_device_resource_use()}; }; template From 19857eb4c15c8e9332064697b2f76f5202e056b2 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Mon, 10 Aug 2026 18:17:57 -0700 Subject: [PATCH 10/17] fix test with todo Signed-off-by: niranda perera --- .../cudf_test/memory_resource_utilities.hpp | 16 +++++++----- cpp/tests/utilities/column_utilities.cu | 5 ++++ .../utilities/memory_resource_utilities.cpp | 25 +++++++++++++++++-- .../utilities_tests/column_wrapper_tests.cpp | 20 ++++++++++----- 4 files changed, 52 insertions(+), 14 deletions(-) diff --git a/cpp/include/cudf_test/memory_resource_utilities.hpp b/cpp/include/cudf_test/memory_resource_utilities.hpp index 1ad81d7ef1eb..f1986eada3c4 100644 --- a/cpp/include/cudf_test/memory_resource_utilities.hpp +++ b/cpp/include/cudf_test/memory_resource_utilities.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace CUDF_EXPORT cudf { @@ -30,9 +31,10 @@ namespace test { * @brief Exception-safe owner for a temporary current device resource. * * The installed resource and the previous resource are held by owning type-erased resource values. - * Destruction restores the previous resource, including during stack unwinding. Because the current - * resource is device-global state, scopes must not overlap concurrent work that changes or uses the - * current resource. + * Destruction restores the previous resource, including during stack unwinding. The object is + * movable: the moved-from object no longer restores on destruction. Because the current resource is + * device-global state, scopes must not overlap concurrent work that changes or uses the current + * resource. */ class scoped_current_device_resource { public: @@ -48,11 +50,13 @@ class scoped_current_device_resource { scoped_current_device_resource(scoped_current_device_resource const&) = delete; scoped_current_device_resource& operator=(scoped_current_device_resource const&) = delete; - scoped_current_device_resource(scoped_current_device_resource&&) = delete; - scoped_current_device_resource& operator=(scoped_current_device_resource&&) = delete; + scoped_current_device_resource(scoped_current_device_resource&&) noexcept; + scoped_current_device_resource& operator=(scoped_current_device_resource&&) noexcept; private: - cuda::mr::any_resource _previous; + void restore() noexcept; + + std::optional> _previous; }; /** @brief Expected relationship between live and total output-resource allocations. */ diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 08f6c3702255..ef2299a3496b 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -542,6 +542,8 @@ struct column_comparator_impl { auto lhs_tview = table_view{{lhs}}; auto rhs_tview = table_view{{rhs}}; + // TODO: Pass `mr` once two_table_comparator / equality preprocessed_table::create accept + // memory_resources instead of allocating from the current device resource. auto const comparator = cudf::detail::row::equality::two_table_comparator{lhs_tview, rhs_tview, stream}; auto const has_nulls = cudf::has_nulls(lhs_tview) or cudf::has_nulls(rhs_tview); @@ -885,6 +887,9 @@ bool expect_columns_equal(cudf::column_view const& lhs, rmm::cuda_stream_view stream, cudf::memory_resources mr) { + // TODO: equality row preprocessing (two_table_comparator / preprocessed_table::create) still + // allocates from the current device resource; pass `mr` through once that path accepts + // memory_resources so callers need not disable failing current-resource scopes. check_non_empty_nulls(lhs, rhs, stream); auto lhs_indices = generate_all_row_indices(lhs.size(), stream, mr); auto rhs_indices = generate_all_row_indices(rhs.size(), stream, mr); diff --git a/cpp/tests/utilities/memory_resource_utilities.cpp b/cpp/tests/utilities/memory_resource_utilities.cpp index 117758d670d3..010afc351595 100644 --- a/cpp/tests/utilities/memory_resource_utilities.cpp +++ b/cpp/tests/utilities/memory_resource_utilities.cpp @@ -22,9 +22,30 @@ scoped_current_device_resource::scoped_current_device_resource( { } -scoped_current_device_resource::~scoped_current_device_resource() +scoped_current_device_resource::scoped_current_device_resource( + scoped_current_device_resource&& other) noexcept + : _previous{std::exchange(other._previous, std::nullopt)} +{ +} + +scoped_current_device_resource& scoped_current_device_resource::operator=( + scoped_current_device_resource&& other) noexcept +{ + if (this != &other) { + restore(); + _previous = std::exchange(other._previous, std::nullopt); + } + return *this; +} + +scoped_current_device_resource::~scoped_current_device_resource() { restore(); } + +void scoped_current_device_resource::restore() noexcept { - std::ignore = cudf::set_current_device_resource(std::move(_previous)); + if (_previous.has_value()) { + std::ignore = cudf::set_current_device_resource(std::move(*_previous)); + _previous.reset(); + } } memory_resource_test_harness::memory_resource_test_harness(rmm::device_async_resource_ref upstream) diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 06f26b81db88..e3d786d33035 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -16,6 +16,8 @@ #include +#include + using cudf::test::expect_output_uses_distinct_resources; using cudf::test::temporary_allocation_expectation; @@ -208,11 +210,11 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporary /** * @brief Base fixture that instruments column-wrapper tests with a memory-resource harness. * - * Each test instantiates a fresh harness. The failing current-device-resource scope is installed in - * the fixture constructor (after `_harness`) so accidental fallback to the default MR fails the - * test. Tests should construct wrappers with `resources()` and pass the released column to - * `validate_with_harness()` before returning. `TearDown` asserts that no output or temporary - * allocations remain live; the prior current resource is restored when the fixture is destroyed. + * Each test instantiates a fresh harness. The failing current-device-resource scope is installed + * after `_harness` so accidental fallback to the default MR fails the test. Tests should construct + * wrappers with `resources()` and pass the released column to `validate_with_harness()` before + * returning. `TearDown` asserts that no output or temporary allocations remain live; the prior + * current resource is restored when the optional scope is reset or destroyed. */ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { void TearDown() override { _harness.expect_no_live_allocations(this->stream()); } @@ -221,6 +223,8 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { cudf::memory_resources resources() { return _harness.resources(); } + void disable_current_device_resource_use() { _fail_on_current.reset(); } + /** * @brief Validate that the harness owns the given result. * @@ -235,7 +239,7 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { private: cudf::test::memory_resource_test_harness _harness{}; - cudf::test::scoped_current_device_resource _fail_on_current{ + std::optional _fail_on_current{ _harness.fail_on_current_device_resource_use()}; }; @@ -431,6 +435,8 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNullMatch) this->resources()); cudf::column_view view = col; + // TODO: Remove once equality row preprocessing uses the supplied memory resources. + this->disable_current_device_resource_use(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, @@ -536,6 +542,8 @@ TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNullMatch) this->resources()); cudf::column_view view = col; + // TODO: Remove once equality row preprocessing uses the supplied memory resources. + this->disable_current_device_resource_use(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, From cd3466f56d8a397ff083a6f21c1e939321df455f Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 11 Aug 2026 13:28:53 -0700 Subject: [PATCH 11/17] simplify empty ctrs Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 195 ++++++------------ cpp/tests/copying/concatenate_tests.cpp | 3 +- cpp/tests/copying/scatter_tests.cpp | 4 +- cpp/tests/encode/encode_tests.cpp | 6 +- cpp/tests/filling/sequence_tests.cpp | 4 +- cpp/tests/interop/dlpack_test.cpp | 6 +- cpp/tests/io/cudftable_test.cpp | 2 +- .../partitioning/hash_partition_test.cpp | 6 +- cpp/tests/quantiles/quantile_test.cpp | 6 +- cpp/tests/quantiles/quantiles_test.cpp | 16 +- cpp/tests/reductions/scan_tests.cpp | 10 +- cpp/tests/replace/clamp_test.cpp | 4 +- cpp/tests/replace/replace_nulls_tests.cpp | 4 +- cpp/tests/replace/replace_tests.cpp | 2 +- .../reshape/interleave_columns_tests.cpp | 14 +- cpp/tests/reshape/table_to_array_tests.cpp | 4 +- cpp/tests/reshape/tile_tests.cpp | 4 +- cpp/tests/rolling/grouped_rolling_test.cpp | 4 +- cpp/tests/rolling/rolling_test.cpp | 2 +- cpp/tests/sort/top_k_tests.cpp | 2 +- cpp/tests/streams/interop_test.cpp | 6 +- cpp/tests/streams/quantile_test.cpp | 4 +- .../integration/unary_transform_test.cpp | 2 +- cpp/tests/transform/mask_to_bools_test.cpp | 8 +- cpp/tests/transform/nans_to_null_test.cpp | 6 +- .../utilities_tests/column_wrapper_tests.cpp | 11 +- 26 files changed, 132 insertions(+), 203 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index a2e3e608070a..824ff3076e32 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -347,22 +347,11 @@ template class fixed_width_column_wrapper : public detail::column_wrapper { public: /** - * @brief Initializes an empty column with proper dtype - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column + * @brief Default constructor initializes an empty column with proper dtype */ - fixed_width_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} + fixed_width_column_wrapper() : column_wrapper{} { - std::vector empty; - wrapped.reset(new cudf::column{ - cudf::data_type{cudf::type_to_id()}, - 0, - detail::make_elements(empty.begin(), empty.end(), stream, mr), - rmm::device_buffer{}, - 0}); + wrapped = cudf::make_empty_column(cudf::type_to_id()); } /** @@ -426,10 +415,7 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename InputIterator, - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template fixed_width_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v, @@ -517,10 +503,7 @@ class fixed_width_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename ValidityIterator, - typename ElementFrom, - std::enable_if_t>* = nullptr> + template fixed_width_column_wrapper(std::initializer_list element_list, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -818,15 +801,10 @@ class strings_column_wrapper : public detail::column_wrapper { public: /** * @brief Default constructor initializes an empty column of strings - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column */ - // Non-explicit so `{}` can copy-initialize empty string columns (e.g. nested in structs). - strings_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : strings_column_wrapper(std::initializer_list{}, stream, mr) + strings_column_wrapper() : column_wrapper{} { + wrapped = cudf::make_empty_column(cudf::type_id::STRING); } /** @@ -904,10 +882,7 @@ class strings_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename StringsIterator, - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template strings_column_wrapper(StringsIterator begin, StringsIterator end, ValidityIterator v, @@ -973,9 +948,7 @@ class strings_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template strings_column_wrapper(std::initializer_list strings, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1063,17 +1036,9 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty column with dictionary type. - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column */ - // Non-explicit so `{}` can copy-initialize empty dictionary columns. - dictionary_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} + dictionary_column_wrapper() : column_wrapper{} { - static_cast(stream); - static_cast(mr); wrapped = cudf::make_empty_column(cudf::type_id::DICTIONARY32); } @@ -1139,10 +1104,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename InputIterator, - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template dictionary_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v, @@ -1230,10 +1192,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename ValidityIterator, - typename ElementFrom, - std::enable_if_t>* = nullptr> + template dictionary_column_wrapper(std::initializer_list element_list, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1311,16 +1270,8 @@ class dictionary_column_wrapper : public detail::column_wrapper { /** * @brief Default constructor initializes an empty dictionary column of strings - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column */ - // Non-explicit so `{}` can copy-initialize empty dictionary columns. - dictionary_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : dictionary_column_wrapper(std::initializer_list{}, stream, mr) - { - } + dictionary_column_wrapper() : dictionary_column_wrapper(std::initializer_list{}) {} /** * @brief Construct a non-nullable dictionary column of strings from the range @@ -1388,10 +1339,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename StringsIterator, - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template dictionary_column_wrapper(StringsIterator begin, StringsIterator end, ValidityIterator v, @@ -1447,9 +1395,7 @@ class dictionary_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template dictionary_column_wrapper(std::initializer_list strings, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1604,11 +1550,9 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename Element = T, - typename ValidityIterator, - std::enable_if_t() && - !std::is_convertible_v>* = nullptr> + template ()>* = nullptr> lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1640,12 +1584,10 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename Element = T, - typename InputIterator, - typename ValidityIterator, - std::enable_if_t() && - !std::is_convertible_v>* = nullptr> + template ()>* = nullptr> lists_column_wrapper(InputIterator begin, InputIterator end, ValidityIterator v, @@ -1705,11 +1647,9 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename Element = T, - typename ValidityIterator, - std::enable_if_t && - !std::is_convertible_v>* = nullptr> + template >* = nullptr> lists_column_wrapper(std::initializer_list elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1763,15 +1703,14 @@ class lists_column_wrapper : public detail::column_wrapper { * // [] * lists_column_wrapper l{}; * @endcode - * - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used to allocate the returned column */ - lists_column_wrapper(rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) - : column_wrapper{} + lists_column_wrapper() : column_wrapper{} { - build_from_non_nested(make_empty_column(cudf::type_to_id()), stream, mr); + // Mark as a root so nesting unwraps to the empty child, matching + // build_from_non_nested on an empty leaf. + root = true; + depth = 0; + wrapped = make_empty_lists_column(data_type{type_to_id()}); } /** @@ -1801,9 +1740,7 @@ class lists_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template < - typename ValidityIterator, - std::enable_if_t>* = nullptr> + template lists_column_wrapper(std::initializer_list> elements, ValidityIterator v, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), @@ -1833,16 +1770,14 @@ class lists_column_wrapper : public detail::column_wrapper { cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { cudf::test::fixed_width_column_wrapper offsets({0, 0}, stream, mr); - cudf::test::fixed_width_column_wrapper values(stream, mr); + cudf::test::fixed_width_column_wrapper values{}; return lists_column_wrapper( 1, offsets.release(), values.release(), valid ? 0 : 1, valid ? rmm::device_buffer{} - : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr()), - stream, - mr); + : cudf::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr.get_output_mr())); } private: @@ -1854,18 +1789,13 @@ class lists_column_wrapper : public detail::column_wrapper { * @param values The column of values bounded by the offsets * @param null_count The number of null list entries * @param null_mask The bits specifying the null lists in device memory - * @param stream CUDA stream used for device memory operations - * @param mr Memory resources associated with the adopted constituent parts */ lists_column_wrapper(size_type num_rows, std::unique_ptr&& offsets, std::unique_ptr&& values, size_type null_count, - rmm::device_buffer&& null_mask, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::device_buffer&& null_mask) { - static_cast(mr); // construct the list column wrapped = make_lists_column( num_rows, std::move(offsets), std::move(values), null_count, std::move(null_mask)); @@ -1891,8 +1821,8 @@ class lists_column_wrapper : public detail::column_wrapper { */ void build_from_nested(std::initializer_list> elements, std::vector const& v, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { auto valids = cudf::detail::make_counting_transform_iterator( 0, [&v](auto i) { return v.empty() ? true : v[i]; }); @@ -1909,8 +1839,8 @@ class lists_column_wrapper : public detail::column_wrapper { int32_t const expected_depth = hierarchy_and_depth.second; // preprocess columns so that every column_view in 'cols' is an equivalent hierarchy - auto [cols, stubs] = - preprocess_columns(elements, expected_hierarchy, expected_depth, stream, mr); + auto [cols, stubs] = preprocess_columns( + elements, expected_hierarchy, expected_depth, stream, mr.get_temporary_mr()); // generate offsets size_type count = 0; @@ -1965,8 +1895,8 @@ class lists_column_wrapper : public detail::column_wrapper { * */ void build_from_non_nested(std::unique_ptr c, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { CUDF_EXPECTS(c->type().id() == type_id::EMPTY || !cudf::is_nested(c->type()), "Unexpected type"); @@ -2021,15 +1951,14 @@ class lists_column_wrapper : public detail::column_wrapper { * @param col Input column to be normalized * @param expected_hierarchy Input column which represents the expected hierarchy * @param stream CUDA stream used for device memory operations - * @param mr Memory resources used for temporary normalized copies + * @param temp_mr Device memory resource used for temporary normalized copies * * @return A new column representing a normalized copy of col */ - std::unique_ptr normalize_column( - column_view const& col, - column_view const& expected_hierarchy, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + std::unique_ptr normalize_column(column_view const& col, + column_view const& expected_hierarchy, + rmm::cuda_stream_view stream, + rmm::device_async_resource_ref temp_mr) { // if are at the bottom of the short column, it must be empty if (col.type().id() != type_id::LIST) { @@ -2040,21 +1969,22 @@ class lists_column_wrapper : public detail::column_wrapper { } lists_column_view lcv(col); - return make_lists_column( - col.size(), - std::make_unique(lcv.offsets(), stream, mr.get_temporary_mr()), - normalize_column( - lists_column_view(col).child(), lists_column_view(expected_hierarchy).child(), stream, mr), - col.null_count(), - cudf::copy_bitmask(col, stream, mr.get_temporary_mr())); + return make_lists_column(col.size(), + std::make_unique(lcv.offsets(), stream, temp_mr), + normalize_column(lists_column_view(col).child(), + lists_column_view(expected_hierarchy).child(), + stream, + temp_mr), + col.null_count(), + cudf::copy_bitmask(col, stream, temp_mr)); } std::pair, std::vector>> preprocess_columns( std::initializer_list> const& elements, column_view& expected_hierarchy, int expected_depth, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::cuda_stream_view stream, + rmm::device_async_resource_ref temp_mr) { std::vector> stubs; std::vector cols; @@ -2087,7 +2017,7 @@ class lists_column_wrapper : public detail::column_wrapper { CUDF_EXPECTS(l.wrapped->size() == 0, "Mismatch in column types!"); stubs.push_back(empty_like(expected_hierarchy)); } else { - stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, mr)); + stubs.push_back(normalize_column(l.get_view(), expected_hierarchy, stream, temp_mr)); } return *(stubs.back()); } @@ -2225,8 +2155,7 @@ class structs_column_wrapper : public detail::column_wrapper { * @param mr Memory resources used to allocate the returned column */ template && - !std::is_convertible_v>* = nullptr> + std::enable_if_t>* = nullptr> structs_column_wrapper( std::initializer_list> child_column_wrappers, V validity_iter, @@ -2248,8 +2177,8 @@ class structs_column_wrapper : public detail::column_wrapper { private: void init(std::vector>&& child_columns, std::vector const& validity, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { size_type num_rows = child_columns.empty() ? 0 : child_columns[0]->size(); @@ -2277,8 +2206,8 @@ class structs_column_wrapper : public detail::column_wrapper { template void init(std::vector>&& child_columns, V validity_iterator, - rmm::cuda_stream_view stream = cudf::test::get_default_stream(), - cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + rmm::cuda_stream_view stream, + cudf::memory_resources mr) { size_type const num_rows = child_columns.empty() ? 0 : child_columns[0]->size(); diff --git a/cpp/tests/copying/concatenate_tests.cpp b/cpp/tests/copying/concatenate_tests.cpp index 6f42323bfe99..8875add31856 100644 --- a/cpp/tests/copying/concatenate_tests.cpp +++ b/cpp/tests/copying/concatenate_tests.cpp @@ -823,7 +823,8 @@ TEST_F(StructsColumnTest, ConcatenateStructs) {true, false})); src.push_back(cudf::test::structs_column_wrapper({name_cols[1], age_cols[1], is_human_cols[1]}, {true, true})); - src.push_back(cudf::test::structs_column_wrapper({name_cols[2], age_cols[2], is_human_cols[2]})); + src.push_back( + cudf::test::structs_column_wrapper({name_cols[2], age_cols[2], is_human_cols[2]}, {})); src.push_back(cudf::test::structs_column_wrapper({name_cols[3], age_cols[3], is_human_cols[3]}, {true, false})); diff --git a/cpp/tests/copying/scatter_tests.cpp b/cpp/tests/copying/scatter_tests.cpp index e3f3450e6606..b23ecdcee24f 100644 --- a/cpp/tests/copying/scatter_tests.cpp +++ b/cpp/tests/copying/scatter_tests.cpp @@ -220,7 +220,7 @@ TYPED_TEST(ScatterDataTypeTests, EmptyScatterMap) cudf::test::fixed_width_column_wrapper source({1, 2, 3, 4, 5, 6}); cudf::test::fixed_width_column_wrapper target( {10, 20, 30, 40, 50, 60, 70, 80}); - cudf::test::fixed_width_column_wrapper scatter_map{}; + cudf::test::fixed_width_column_wrapper scatter_map({}); auto const source_table = cudf::table_view({source, source}); auto const target_table = cudf::table_view({target, target}); @@ -241,7 +241,7 @@ TYPED_TEST(ScatterDataTypeTests, EmptyScalarScatterMap) cudf::test::fixed_width_column_wrapper target( {10, 20, 30, 40, 50, 60, 70, 80}); - cudf::test::fixed_width_column_wrapper scatter_map{}; + cudf::test::fixed_width_column_wrapper scatter_map({}); auto const target_table = cudf::table_view({target}); diff --git a/cpp/tests/encode/encode_tests.cpp b/cpp/tests/encode/encode_tests.cpp index 246caae0eab7..25f38fa89b71 100644 --- a/cpp/tests/encode/encode_tests.cpp +++ b/cpp/tests/encode/encode_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include @@ -31,8 +31,8 @@ TYPED_TEST(EncodeNumericTests, SingleNullEncode) TYPED_TEST(EncodeNumericTests, EmptyEncode) { - cudf::test::fixed_width_column_wrapper input{}; - cudf::test::fixed_width_column_wrapper expect{}; + cudf::test::fixed_width_column_wrapper input({}); + cudf::test::fixed_width_column_wrapper expect({}); auto const result = cudf::encode(cudf::table_view({input})); CUDF_TEST_EXPECT_COLUMNS_EQUAL(result.second->view(), expect); diff --git a/cpp/tests/filling/sequence_tests.cpp b/cpp/tests/filling/sequence_tests.cpp index 0b115e10513d..7ec3188a6ae4 100644 --- a/cpp/tests/filling/sequence_tests.cpp +++ b/cpp/tests/filling/sequence_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -62,7 +62,7 @@ TYPED_TEST(SequenceTypedTestFixture, EmptyOutput) cudf::size_type num_els = 0; - cudf::test::fixed_width_column_wrapper expected_w{}; + cudf::test::fixed_width_column_wrapper expected_w({}); auto result = cudf::sequence(num_els, init, step); diff --git a/cpp/tests/interop/dlpack_test.cpp b/cpp/tests/interop/dlpack_test.cpp index 8a3f06ecdf74..a3d0234b7c0d 100644 --- a/cpp/tests/interop/dlpack_test.cpp +++ b/cpp/tests/interop/dlpack_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2024, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include @@ -63,8 +63,8 @@ TEST_F(DLPackUntypedTests, EmptyTableToDlpack) TEST_F(DLPackUntypedTests, EmptyColsToDlpack) { - cudf::test::fixed_width_column_wrapper col1{}; - cudf::test::fixed_width_column_wrapper col2{}; + cudf::test::fixed_width_column_wrapper col1({}); + cudf::test::fixed_width_column_wrapper col2({}); cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input)); validate_dtype(tensor->dl_tensor.dtype); diff --git a/cpp/tests/io/cudftable_test.cpp b/cpp/tests/io/cudftable_test.cpp index 96ecf94eb707..63859cb99d30 100644 --- a/cpp/tests/io/cudftable_test.cpp +++ b/cpp/tests/io/cudftable_test.cpp @@ -108,7 +108,7 @@ TEST_F(CudftableTest, MultiColumnFixedWidth) TEST_F(CudftableTest, EmptyColumn) { - cudf::test::fixed_width_column_wrapper empty_col{}; + cudf::test::fixed_width_column_wrapper empty_col({}); auto const expected = cudf::table_view{{empty_col}}; run_test(expected); diff --git a/cpp/tests/partitioning/hash_partition_test.cpp b/cpp/tests/partitioning/hash_partition_test.cpp index 45bdf877c43b..0a9d4f4992fc 100644 --- a/cpp/tests/partitioning/hash_partition_test.cpp +++ b/cpp/tests/partitioning/hash_partition_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include @@ -90,8 +90,8 @@ TEST_F(HashPartition, ZeroPartitions) TEST_F(HashPartition, ZeroRows) { - fixed_width_column_wrapper floats{}; - fixed_width_column_wrapper integers{}; + fixed_width_column_wrapper floats({}); + fixed_width_column_wrapper integers({}); strings_column_wrapper strings; auto input = cudf::table_view({floats, integers, strings}); diff --git a/cpp/tests/quantiles/quantile_test.cpp b/cpp/tests/quantiles/quantile_test.cpp index 21faae40ba7d..2096fc2e4ce9 100644 --- a/cpp/tests/quantiles/quantile_test.cpp +++ b/cpp/tests/quantiles/quantile_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -413,7 +413,7 @@ TYPED_TEST(QuantileTest, TestInterpolateExtremaLow) TYPED_TEST(QuantileTest, TestEmpty) { - auto input = cudf::test::fixed_width_column_wrapper(); + auto input = cudf::test::fixed_width_column_wrapper({}); auto expected = cudf::test::fixed_width_column_wrapper({0, 0}, {false, false}); auto actual = cudf::quantile(input, {0.5, 0.25}); } @@ -429,7 +429,7 @@ TYPED_TEST_SUITE(QuantileUnsupportedTypesTest, UnsupportedTestTypes); TYPED_TEST(QuantileUnsupportedTypesTest, TestZeroElements) { - cudf::test::fixed_width_column_wrapper input{}; + cudf::test::fixed_width_column_wrapper input({}); EXPECT_THROW(cudf::quantile(input, {0}), cudf::logic_error); } diff --git a/cpp/tests/quantiles/quantiles_test.cpp b/cpp/tests/quantiles/quantiles_test.cpp index e8bc44de1fc2..08cba6cf18ce 100644 --- a/cpp/tests/quantiles/quantiles_test.cpp +++ b/cpp/tests/quantiles/quantiles_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -33,7 +33,7 @@ TYPED_TEST(QuantilesTest, TestMultiColumnZeroRows) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a{}; + cudf::test::fixed_width_column_wrapper input_a({}); auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, {0.0f}), cudf::logic_error); @@ -56,8 +56,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnOrderCountMismatch) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a{}; - cudf::test::fixed_width_column_wrapper input_b{}; + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, @@ -73,8 +73,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnNullOrderCountMismatch) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a{}; - cudf::test::fixed_width_column_wrapper input_b{}; + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, @@ -90,8 +90,8 @@ TYPED_TEST(QuantilesTest, TestMultiColumnArithmeticInterpolation) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper input_a{}; - cudf::test::fixed_width_column_wrapper input_b{}; + cudf::test::fixed_width_column_wrapper input_a({}); + cudf::test::fixed_width_column_wrapper input_b({}); auto input = cudf::table_view({input_a}); EXPECT_THROW(cudf::quantiles(input, {0.0f}, cudf::interpolation::LINEAR), std::invalid_argument); diff --git a/cpp/tests/reductions/scan_tests.cpp b/cpp/tests/reductions/scan_tests.cpp index 2caf981c7de9..64493c818f3f 100644 --- a/cpp/tests/reductions/scan_tests.cpp +++ b/cpp/tests/reductions/scan_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -386,8 +386,8 @@ TYPED_TEST_SUITE(ScanEmptyTest, cudf::test::NumericTypes); TYPED_TEST(ScanEmptyTest, MinInclusive) { - cudf::test::fixed_width_column_wrapper col{}; - cudf::test::fixed_width_column_wrapper expected{}; + cudf::test::fixed_width_column_wrapper col({}); + cudf::test::fixed_width_column_wrapper expected({}); auto result = cudf::scan( col, *cudf::make_min_aggregation(), cudf::scan_type::INCLUSIVE); @@ -396,8 +396,8 @@ TYPED_TEST(ScanEmptyTest, MinInclusive) TYPED_TEST(ScanEmptyTest, MinExclusive) { - cudf::test::fixed_width_column_wrapper col{}; - cudf::test::fixed_width_column_wrapper expected{}; + cudf::test::fixed_width_column_wrapper col({}); + cudf::test::fixed_width_column_wrapper expected({}); auto result = cudf::scan( col, *cudf::make_min_aggregation(), cudf::scan_type::EXCLUSIVE); diff --git a/cpp/tests/replace/clamp_test.cpp b/cpp/tests/replace/clamp_test.cpp index 81c15ad8b360..2a198d3b18bb 100644 --- a/cpp/tests/replace/clamp_test.cpp +++ b/cpp/tests/replace/clamp_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -116,7 +116,7 @@ TEST_F(ClampEmptyCaseTest, EmptyInput) auto hi = cudf::make_numeric_scalar(cudf::data_type(cudf::type_id::INT32)); hi->set_valid_async(true); - cudf::test::fixed_width_column_wrapper input{}; + cudf::test::fixed_width_column_wrapper input({}); auto got = cudf::clamp(input, *lo, *hi); diff --git a/cpp/tests/replace/replace_nulls_tests.cpp b/cpp/tests/replace/replace_nulls_tests.cpp index ead5f233a788..7f15fef2c270 100644 --- a/cpp/tests/replace/replace_nulls_tests.cpp +++ b/cpp/tests/replace/replace_nulls_tests.cpp @@ -1,7 +1,7 @@ /* * SPDX-FileCopyrightText: Copyright 2018 BlazingDB, Inc. * SPDX-FileCopyrightText: Copyright 2018 Alexander Ocsa - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ /* @@ -663,7 +663,7 @@ TEST_F(ReplaceDictionaryTest, ReplaceNullsError) TEST_F(ReplaceDictionaryTest, ReplaceNullsEmpty) { - cudf::test::fixed_width_column_wrapper input_empty_w{}; + cudf::test::fixed_width_column_wrapper input_empty_w({}); auto input_empty = cudf::dictionary::encode(input_empty_w); auto result = cudf::replace_nulls(input_empty->view(), input_empty->view()); CUDF_TEST_EXPECT_COLUMNS_EQUIVALENT(result->view(), input_empty->view()); diff --git a/cpp/tests/replace/replace_tests.cpp b/cpp/tests/replace/replace_tests.cpp index 1ee6d2f006e9..3c0185a46fd1 100644 --- a/cpp/tests/replace/replace_tests.cpp +++ b/cpp/tests/replace/replace_tests.cpp @@ -615,7 +615,7 @@ TEST_F(ReplaceDictionaryTest, EmptyReplacement) cudf::test::fixed_width_column_wrapper input_w( {1.0, 2.0, 1.0, 2.0, 0.0, 3.0, 4.0, 4.0, 3.0}, {1, 1, 1, 1, 0, 1, 1, 1, 1}); auto input = cudf::dictionary::encode(input_w); - cudf::test::fixed_width_column_wrapper empty_w{}; + cudf::test::fixed_width_column_wrapper empty_w({}); auto empty = cudf::dictionary::encode(empty_w); auto result = cudf::find_and_replace_all(input->view(), empty->view(), empty->view()); diff --git a/cpp/tests/reshape/interleave_columns_tests.cpp b/cpp/tests/reshape/interleave_columns_tests.cpp index 1b32f8519bc8..66dc44a8e790 100644 --- a/cpp/tests/reshape/interleave_columns_tests.cpp +++ b/cpp/tests/reshape/interleave_columns_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -88,11 +88,11 @@ TYPED_TEST(InterleaveColumnsTest, OneColumnEmpty) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper a{}; + cudf::test::fixed_width_column_wrapper a({}); cudf::table_view in(std::vector{a}); - auto expected = cudf::test::fixed_width_column_wrapper(); + auto expected = cudf::test::fixed_width_column_wrapper({}); auto actual = cudf::interleave_columns(in); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view()); @@ -102,13 +102,13 @@ TYPED_TEST(InterleaveColumnsTest, ThreeColumnsEmpty) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper a{}; - cudf::test::fixed_width_column_wrapper b{}; - cudf::test::fixed_width_column_wrapper c{}; + cudf::test::fixed_width_column_wrapper a({}); + cudf::test::fixed_width_column_wrapper b({}); + cudf::test::fixed_width_column_wrapper c({}); cudf::table_view in(std::vector{a, b, c}); - auto expected = cudf::test::fixed_width_column_wrapper(); + auto expected = cudf::test::fixed_width_column_wrapper({}); auto actual = cudf::interleave_columns(in); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, actual->view()); diff --git a/cpp/tests/reshape/table_to_array_tests.cpp b/cpp/tests/reshape/table_to_array_tests.cpp index 9009d36cb560..89e7a72334db 100644 --- a/cpp/tests/reshape/table_to_array_tests.cpp +++ b/cpp/tests/reshape/table_to_array_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -180,7 +180,7 @@ TEST(TableToDeviceArrayTest, NoRows) { auto stream = cudf::get_default_stream(); - cudf::test::fixed_width_column_wrapper col{}; + cudf::test::fixed_width_column_wrapper col({}); cudf::table_view input_table({col}); rmm::device_buffer output(0, stream); diff --git a/cpp/tests/reshape/tile_tests.cpp b/cpp/tests/reshape/tile_tests.cpp index 63424dc6fda7..50be2837d4c6 100644 --- a/cpp/tests/reshape/tile_tests.cpp +++ b/cpp/tests/reshape/tile_tests.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2024, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -32,7 +32,7 @@ TYPED_TEST(TileTest, NoRows) { using T = TypeParam; - cudf::test::fixed_width_column_wrapper in_a{}; + cudf::test::fixed_width_column_wrapper in_a({}); cudf::table_view in(std::vector{in_a}); auto expected = in; diff --git a/cpp/tests/rolling/grouped_rolling_test.cpp b/cpp/tests/rolling/grouped_rolling_test.cpp index e0bebb6b86ea..b568a909ff0e 100644 --- a/cpp/tests/rolling/grouped_rolling_test.cpp +++ b/cpp/tests/rolling/grouped_rolling_test.cpp @@ -420,7 +420,7 @@ class GroupedRollingTest : public cudf::test::BaseFixture { std::conditional_t, int64_t, T>, false>( input, group_offsets, preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper().release(); + default: return cudf::test::fixed_width_column_wrapper({}).release(); } } }; @@ -1156,7 +1156,7 @@ class GroupedTimeRangeRollingTest : public cudf::test::BaseFixture { preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper().release(); + default: return cudf::test::fixed_width_column_wrapper({}).release(); } } }; diff --git a/cpp/tests/rolling/rolling_test.cpp b/cpp/tests/rolling/rolling_test.cpp index a3a76eacd2ea..a2f178499388 100644 --- a/cpp/tests/rolling/rolling_test.cpp +++ b/cpp/tests/rolling/rolling_test.cpp @@ -601,7 +601,7 @@ class RollingTest : public cudf::test::BaseFixture { std::conditional_t(), T, double>, true>( input, preceding_window, following_window, min_periods); - default: return cudf::test::fixed_width_column_wrapper().release(); + default: return cudf::test::fixed_width_column_wrapper({}).release(); } } }; diff --git a/cpp/tests/sort/top_k_tests.cpp b/cpp/tests/sort/top_k_tests.cpp index abf2258fc5f4..d761c6e30125 100644 --- a/cpp/tests/sort/top_k_tests.cpp +++ b/cpp/tests/sort/top_k_tests.cpp @@ -424,7 +424,7 @@ TEST_F(TopK, Errors) auto offsets = cudf::test::fixed_width_column_wrapper({0, 15, 20, 23, 40, 42}); EXPECT_THROW(cudf::segmented_top_k(input, offsets, -1), std::invalid_argument); EXPECT_THROW(cudf::segmented_top_k_order(input, offsets, -1), std::invalid_argument); - offsets = cudf::test::fixed_width_column_wrapper(); + offsets = cudf::test::fixed_width_column_wrapper({}); EXPECT_THROW(cudf::segmented_top_k(input, offsets, 10), std::invalid_argument); EXPECT_THROW(cudf::segmented_top_k_order(input, offsets, 10), std::invalid_argument); offsets = cudf::test::fixed_width_column_wrapper({0, 15}, {1, 0}); diff --git a/cpp/tests/streams/interop_test.cpp b/cpp/tests/streams/interop_test.cpp index bc944922ba9f..484c288e8a21 100644 --- a/cpp/tests/streams/interop_test.cpp +++ b/cpp/tests/streams/interop_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -30,8 +30,8 @@ TEST_F(DLPackTest, ToDLPack) TEST_F(DLPackTest, FromDLPack) { using unique_managed_tensor = std::unique_ptr; - cudf::test::fixed_width_column_wrapper col1{}; - cudf::test::fixed_width_column_wrapper col2{}; + cudf::test::fixed_width_column_wrapper col1({}); + cudf::test::fixed_width_column_wrapper col2({}); cudf::table_view input({col1, col2}); unique_managed_tensor tensor(cudf::to_dlpack(input, cudf::test::get_default_stream())); auto result = cudf::from_dlpack(tensor.get(), cudf::test::get_default_stream()); diff --git a/cpp/tests/streams/quantile_test.cpp b/cpp/tests/streams/quantile_test.cpp index 554b28738801..98e188a679b9 100644 --- a/cpp/tests/streams/quantile_test.cpp +++ b/cpp/tests/streams/quantile_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -42,7 +42,7 @@ TEST_F(QuantileTest, TestMultiColumnUnsorted) TEST_F(QuantileTest, TestEmpty) { - auto input = cudf::test::fixed_width_column_wrapper(); + auto input = cudf::test::fixed_width_column_wrapper({}); cudf::quantile( input, {0.5, 0.25}, cudf::interpolation::LINEAR, {}, true, cudf::test::get_default_stream()); } diff --git a/cpp/tests/transform/integration/unary_transform_test.cpp b/cpp/tests/transform/integration/unary_transform_test.cpp index c358f3ef1322..528ef661cda6 100644 --- a/cpp/tests/transform/integration/unary_transform_test.cpp +++ b/cpp/tests/transform/integration/unary_transform_test.cpp @@ -674,7 +674,7 @@ __device__ inline void decode(float * output, float input){ // empty column { - auto a_empty = cudf::test::fixed_width_column_wrapper().release(); + auto a_empty = cudf::test::fixed_width_column_wrapper({}).release(); auto a_encoded = cudf::dictionary::encode(a_empty->view()); cudf::transform_input inputs[] = {*a_encoded}; diff --git a/cpp/tests/transform/mask_to_bools_test.cpp b/cpp/tests/transform/mask_to_bools_test.cpp index 686b02f90061..047b53beee62 100644 --- a/cpp/tests/transform/mask_to_bools_test.cpp +++ b/cpp/tests/transform/mask_to_bools_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2020-2023, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,7 +17,7 @@ struct MaskToBools : public cudf::test::BaseFixture {}; TEST_F(MaskToBools, NullDataWithZeroLength) { - auto expected = cudf::test::fixed_width_column_wrapper(); + auto expected = cudf::test::fixed_width_column_wrapper({}); auto out = cudf::mask_to_bools(nullptr, 0, 0); CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, out->view()); @@ -25,14 +25,14 @@ TEST_F(MaskToBools, NullDataWithZeroLength) TEST_F(MaskToBools, NullDataWithNonZeroLength) { - auto expected = cudf::test::fixed_width_column_wrapper(); + auto expected = cudf::test::fixed_width_column_wrapper({}); EXPECT_THROW(cudf::mask_to_bools(nullptr, 0, 2), cudf::logic_error); } TEST_F(MaskToBools, ImproperBitRange) { - auto expected = cudf::test::fixed_width_column_wrapper(); + auto expected = cudf::test::fixed_width_column_wrapper({}); EXPECT_THROW(cudf::mask_to_bools(nullptr, 2, 1), cudf::logic_error); } diff --git a/cpp/tests/transform/nans_to_null_test.cpp b/cpp/tests/transform/nans_to_null_test.cpp index a1c3652fe7f8..f9d6c6aca573 100644 --- a/cpp/tests/transform/nans_to_null_test.cpp +++ b/cpp/tests/transform/nans_to_null_test.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -116,7 +116,7 @@ TYPED_TEST(NaNsToNullTest, EmptyColumn) { using T = TypeParam; - auto input_column = cudf::test::fixed_width_column_wrapper(); + auto input_column = cudf::test::fixed_width_column_wrapper({}); this->run_test(input_column, input_column); } @@ -141,6 +141,6 @@ TEST_F(NaNsToNullFailTest, IntegerType) TEST_F(NaNsToNullFailTest, EmptyColumn) { - auto input_column = cudf::test::fixed_width_column_wrapper(); + auto input_column = cudf::test::fixed_width_column_wrapper({}); EXPECT_THROW(cudf::column_nans_to_nulls(input_column), std::invalid_argument); } diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index e3d786d33035..0065e8ab9fd4 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -71,7 +71,7 @@ TEST(StringsColumnWrapperMemoryResourceTest, DistinctOutputAndTemporaryResources auto const validity = std::vector{true, false, true, false}; expect_output_uses_distinct_resources( - [&](auto mr) { return cudf::test::strings_column_wrapper(stream, mr); }); + [&]([[maybe_unused]] auto mr) { return cudf::test::strings_column_wrapper{}; }); expect_output_uses_distinct_resources([&](auto mr) { return cudf::test::strings_column_wrapper(strings.begin(), strings.end(), stream, mr); @@ -154,9 +154,8 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, FixedWidthDistinctOutputAndTempo TEST(DictionaryColumnWrapperMemoryResourceTest, EmptyStringDictionaryPreservesChildTypes) { - expect_output_uses_distinct_resources([&](auto mr) { - auto wrapper = - cudf::test::dictionary_column_wrapper(cudf::test::get_default_stream(), mr); + expect_output_uses_distinct_resources([&]([[maybe_unused]] auto mr) { + auto wrapper = cudf::test::dictionary_column_wrapper(); auto dictionary = cudf::dictionary_column_view{static_cast(wrapper)}; EXPECT_EQ(0, static_cast(wrapper).size()); @@ -272,7 +271,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, EmptyIterator) } TYPED_TEST(FixedWidthColumnWrapperTest, EmptyList) { - cudf::test::fixed_width_column_wrapper col(this->stream(), this->resources()); + cudf::test::fixed_width_column_wrapper col{}; cudf::column_view view = col; EXPECT_EQ(view.size(), 0); EXPECT_EQ(view.head(), nullptr); @@ -490,7 +489,7 @@ TYPED_TEST_SUITE(StringsColumnWrapperTest, cudf::test::StringTypes); TYPED_TEST(StringsColumnWrapperTest, EmptyList) { - cudf::test::strings_column_wrapper col(this->stream(), this->resources()); + cudf::test::strings_column_wrapper col; cudf::column_view view = col; EXPECT_EQ(view.size(), 0); EXPECT_EQ(view.head(), nullptr); From e3cc3dba64d916d152636ca75f1cf6d7d32cb41e Mon Sep 17 00:00:00 2001 From: niranda perera Date: Tue, 11 Aug 2026 19:32:17 -0700 Subject: [PATCH 12/17] rename util Signed-off-by: niranda perera --- cpp/include/cudf_test/column_wrapper.hpp | 41 ++++++++++--------- .../utilities_tests/column_wrapper_tests.cpp | 6 +-- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 824ff3076e32..7c6f3600fb5d 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -166,7 +166,9 @@ rmm::device_buffer make_elements(InputIterator begin, auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(ElementTo), stream, mr.get_output_mr()}; + rmm::device_buffer buffer{elements.data(), size * sizeof(ElementTo), stream, mr.get_output_mr()}; + stream.synchronize(); // wait for async H2D before host source is destroyed + return buffer; } // The two signatures below are identical to the above overload apart from @@ -200,7 +202,9 @@ rmm::device_buffer make_elements(InputIterator begin, auto transform_begin = thrust::make_transform_iterator(begin, transformer); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transform_begin, transform_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; + rmm::device_buffer buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; + stream.synchronize(); // wait for async H2D before host source is destroyed + return buffer; } /** @@ -235,7 +239,9 @@ rmm::device_buffer make_elements(InputIterator begin, auto transformer_begin = thrust::make_transform_iterator(begin, to_rep); auto const size = cudf::distance(begin, end); auto const elements = thrust::host_vector(transformer_begin, transformer_begin + size); - return rmm::device_buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; + rmm::device_buffer buffer{elements.data(), size * sizeof(RepType), stream, mr.get_output_mr()}; + stream.synchronize(); // wait for async H2D before host source is destroyed + return buffer; } //! @endcond @@ -295,10 +301,11 @@ std::pair make_null_mask( cudf::memory_resources mr = cudf::get_current_device_resource_ref()) { auto [null_mask, null_count] = make_null_mask_vector(begin, end); - auto d_mask = rmm::device_buffer{null_mask.data(), - cudf::bitmask_allocation_size_bytes(cudf::distance(begin, end)), - stream, - mr.get_output_mr()}; + rmm::device_buffer d_mask{null_mask.data(), + cudf::bitmask_allocation_size_bytes(cudf::distance(begin, end)), + stream, + mr.get_output_mr()}; + stream.synchronize(); // wait for async H2D before host source is destroyed return {std::move(d_mask), null_count}; } @@ -616,13 +623,9 @@ class fixed_point_column_wrapper : public detail::column_wrapper { auto const elements = thrust::host_vector(begin, end); auto const id = type_to_id>(); auto const data_type = cudf::data_type{id, static_cast(scale)}; - - wrapped.reset(new cudf::column{ - data_type, - size, - rmm::device_buffer{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}, - rmm::device_buffer{}, - 0}); + rmm::device_buffer data{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}; + wrapped.reset(new cudf::column{data_type, size, std::move(data), rmm::device_buffer{}, 0}); + stream.synchronize(); // wait for async H2D before host source is destroyed } /** @@ -692,12 +695,10 @@ class fixed_point_column_wrapper : public detail::column_wrapper { auto const id = type_to_id>(); auto const data_type = cudf::data_type{id, static_cast(scale)}; auto [null_mask, null_count] = detail::make_null_mask(v, v + size, stream, mr); - wrapped.reset(new cudf::column{ - data_type, - size, - rmm::device_buffer{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}, - std::move(null_mask), - null_count}); + rmm::device_buffer data{elements.data(), size * sizeof(Rep), stream, mr.get_output_mr()}; + wrapped.reset( + new cudf::column{data_type, size, std::move(data), std::move(null_mask), null_count}); + stream.synchronize(); // wait for async H2D before host source is destroyed } /** diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 0065e8ab9fd4..0d42266f60db 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -222,7 +222,7 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { cudf::memory_resources resources() { return _harness.resources(); } - void disable_current_device_resource_use() { _fail_on_current.reset(); } + void enable_current_device_resource_use() { _fail_on_current.reset(); } /** * @brief Validate that the harness owns the given result. @@ -435,7 +435,7 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNullMatch) cudf::column_view view = col; // TODO: Remove once equality row preprocessing uses the supplied memory resources. - this->disable_current_device_resource_use(); + this->enable_current_device_resource_use(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, @@ -542,7 +542,7 @@ TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNullMatch) cudf::column_view view = col; // TODO: Remove once equality row preprocessing uses the supplied memory resources. - this->disable_current_device_resource_use(); + this->enable_current_device_resource_use(); CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, From 40155c3992882148d7f91dca2cac52d3d89ea78c Mon Sep 17 00:00:00 2001 From: Niranda Perera Date: Wed, 12 Aug 2026 09:39:15 -0700 Subject: [PATCH 13/17] Apply suggestion from @bdice Co-authored-by: Bradley Dice --- cpp/tests/utilities/column_utilities.cu | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index ef2299a3496b..3d8d247b1fa5 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -489,7 +489,6 @@ std::string stringify_column_differences(cudf::device_span difference buffer << depth_str << "differences:" << std::endl; auto source_table = cudf::table_view({lhs, rhs}); - // Intermediate gather indices — allocate on temporary, not output. auto diff_column = fixed_width_column_wrapper( h_differences.begin(), h_differences.end(), stream, mr.get_temporary_mr()); auto diff_table = cudf::gather(source_table, From f4293ad5f6485ecf4c3c9a25fd147b33a3233e29 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Wed, 12 Aug 2026 09:51:24 -0700 Subject: [PATCH 14/17] moving base fixture & use concepts Signed-off-by: niranda perera --- cpp/include/cudf_test/base_fixture.hpp | 47 ++++++++++++++++++- cpp/include/cudf_test/column_wrapper.hpp | 10 +++- .../utilities_tests/column_wrapper_tests.cpp | 26 +--------- 3 files changed, 55 insertions(+), 28 deletions(-) diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index 583abe9931d8..d7ccd0ec174f 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -1,21 +1,26 @@ /* - * 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 */ #pragma once #include +#include #include +#include #include #include #include +#include #include #include +#include + namespace CUDF_EXPORT cudf { namespace test { @@ -39,6 +44,46 @@ class BaseFixture : public ::testing::Test { rmm::device_async_resource_ref mr() { return _mr; } }; +/** + * @brief Base fixture that instruments tests with a memory-resource harness. + * + * Each test instantiates a fresh harness. The failing current-device-resource scope is installed + * after `_harness` so accidental fallback to the default MR fails the test. Tests should construct + * results with `resources()`. `TearDown` asserts that no output or temporary allocations remain + * live; the prior current resource is restored when the optional scope is reset or destroyed. + */ +struct BaseFixtureWithHarness : public BaseFixture { + /** + * @brief Assert that the harness has no live output or temporary allocations. + */ + void TearDown() override { _harness.expect_no_live_allocations(stream()); } + + /** + * @brief Return the default stream used by tests inheriting from this fixture. + * @return CUDA stream view + */ + [[nodiscard]] rmm::cuda_stream_view stream() const { return cudf::test::get_default_stream(); } + + /** + * @brief Return the harness output and temporary memory resources. + * @return Explicit output and temporary resources that do not consult the current resource + */ + cudf::memory_resources resources() { return _harness.resources(); } + + /** + * @brief Clear the failing current-device-resource scope for the remainder of the test. + * + * After this call, APIs may allocate from the restored current device resource without failing + * the test. Prefer removing the need for this once those APIs accept explicit resources. + */ + void enable_current_device_resource_use() { _fail_on_current.reset(); } + + protected: + memory_resource_test_harness _harness{mr()}; + std::optional _fail_on_current{ + _harness.fail_on_current_device_resource_use()}; +}; + /** * @brief Base test fixture that takes a parameter. * diff --git a/cpp/include/cudf_test/column_wrapper.hpp b/cpp/include/cudf_test/column_wrapper.hpp index 7c6f3600fb5d..dc828edd582c 100644 --- a/cpp/include/cudf_test/column_wrapper.hpp +++ b/cpp/include/cudf_test/column_wrapper.hpp @@ -2038,6 +2038,12 @@ class lists_column_wrapper : public detail::column_wrapper { bool root = false; }; +/** + * @brief True when `T` is convertible to `rmm::cuda_stream_view`. + */ +template +concept convertible_to_cuda_stream_view = std::is_convertible_v; + /** * @brief `column_wrapper` derived class for wrapping columns of structs. */ @@ -2155,13 +2161,13 @@ class structs_column_wrapper : public detail::column_wrapper { * @param stream CUDA stream used for device memory operations * @param mr Memory resources used to allocate the returned column */ - template >* = nullptr> + template structs_column_wrapper( std::initializer_list> child_column_wrappers, V validity_iter, rmm::cuda_stream_view stream = cudf::test::get_default_stream(), cudf::memory_resources mr = cudf::get_current_device_resource_ref()) + requires(!convertible_to_cuda_stream_view) { std::vector> child_columns; child_columns.reserve(child_column_wrappers.size()); diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index 0d42266f60db..fb779516d994 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -16,8 +16,6 @@ #include -#include - using cudf::test::expect_output_uses_distinct_resources; using cudf::test::temporary_allocation_expectation; @@ -206,24 +204,7 @@ TEST(DictionaryColumnWrapperMemoryResourceTest, StringDistinctOutputAndTemporary uses_temporary); } -/** - * @brief Base fixture that instruments column-wrapper tests with a memory-resource harness. - * - * Each test instantiates a fresh harness. The failing current-device-resource scope is installed - * after `_harness` so accidental fallback to the default MR fails the test. Tests should construct - * wrappers with `resources()` and pass the released column to `validate_with_harness()` before - * returning. `TearDown` asserts that no output or temporary allocations remain live; the prior - * current resource is restored when the optional scope is reset or destroyed. - */ -struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { - void TearDown() override { _harness.expect_no_live_allocations(this->stream()); } - - rmm::cuda_stream_view stream() const { return cudf::test::get_default_stream(); } - - cudf::memory_resources resources() { return _harness.resources(); } - - void enable_current_device_resource_use() { _fail_on_current.reset(); } - +struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixtureWithHarness { /** * @brief Validate that the harness owns the given result. * @@ -235,11 +216,6 @@ struct ColumnWrapperTestWithHarness : public cudf::test::BaseFixture { { _harness.expect_resource_usage(col->alloc_size(), {}, this->stream()); } - - private: - cudf::test::memory_resource_test_harness _harness{}; - std::optional _fail_on_current{ - _harness.fail_on_current_device_resource_use()}; }; template From 1a5fa3858599bc0e789480409c16be8d948f3a7d Mon Sep 17 00:00:00 2001 From: niranda perera Date: Wed, 12 Aug 2026 10:09:54 -0700 Subject: [PATCH 15/17] precommit --- cpp/tests/utilities/column_utilities.cu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/tests/utilities/column_utilities.cu b/cpp/tests/utilities/column_utilities.cu index 3d8d247b1fa5..224f20941053 100644 --- a/cpp/tests/utilities/column_utilities.cu +++ b/cpp/tests/utilities/column_utilities.cu @@ -489,7 +489,7 @@ std::string stringify_column_differences(cudf::device_span difference buffer << depth_str << "differences:" << std::endl; auto source_table = cudf::table_view({lhs, rhs}); - auto diff_column = fixed_width_column_wrapper( + auto diff_column = fixed_width_column_wrapper( h_differences.begin(), h_differences.end(), stream, mr.get_temporary_mr()); auto diff_table = cudf::gather(source_table, diff_column, From 58544b7bd4f81cfd81eec6cc3690e83e724d3fb1 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Thu, 13 Aug 2026 14:25:54 -0700 Subject: [PATCH 16/17] addressing bdice concerns Signed-off-by: niranda perera --- cpp/include/cudf_test/base_fixture.hpp | 18 ++----------- .../cudf_test/memory_resource_utilities.hpp | 16 +++++------- .../utilities/memory_resource_utilities.cpp | 25 ++----------------- .../utilities_tests/column_wrapper_tests.cpp | 8 +++--- 4 files changed, 14 insertions(+), 53 deletions(-) diff --git a/cpp/include/cudf_test/base_fixture.hpp b/cpp/include/cudf_test/base_fixture.hpp index d7ccd0ec174f..003955369001 100644 --- a/cpp/include/cudf_test/base_fixture.hpp +++ b/cpp/include/cudf_test/base_fixture.hpp @@ -19,8 +19,6 @@ #include -#include - namespace CUDF_EXPORT cudf { namespace test { @@ -47,10 +45,8 @@ class BaseFixture : public ::testing::Test { /** * @brief Base fixture that instruments tests with a memory-resource harness. * - * Each test instantiates a fresh harness. The failing current-device-resource scope is installed - * after `_harness` so accidental fallback to the default MR fails the test. Tests should construct - * results with `resources()`. `TearDown` asserts that no output or temporary allocations remain - * live; the prior current resource is restored when the optional scope is reset or destroyed. + * Each test instantiates a fresh harness. Tests should construct results with `resources()`. + * `TearDown` asserts that no output or temporary allocations remain live. */ struct BaseFixtureWithHarness : public BaseFixture { /** @@ -70,18 +66,8 @@ struct BaseFixtureWithHarness : public BaseFixture { */ cudf::memory_resources resources() { return _harness.resources(); } - /** - * @brief Clear the failing current-device-resource scope for the remainder of the test. - * - * After this call, APIs may allocate from the restored current device resource without failing - * the test. Prefer removing the need for this once those APIs accept explicit resources. - */ - void enable_current_device_resource_use() { _fail_on_current.reset(); } - protected: memory_resource_test_harness _harness{mr()}; - std::optional _fail_on_current{ - _harness.fail_on_current_device_resource_use()}; }; /** diff --git a/cpp/include/cudf_test/memory_resource_utilities.hpp b/cpp/include/cudf_test/memory_resource_utilities.hpp index f1986eada3c4..1ad81d7ef1eb 100644 --- a/cpp/include/cudf_test/memory_resource_utilities.hpp +++ b/cpp/include/cudf_test/memory_resource_utilities.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include namespace CUDF_EXPORT cudf { @@ -31,10 +30,9 @@ namespace test { * @brief Exception-safe owner for a temporary current device resource. * * The installed resource and the previous resource are held by owning type-erased resource values. - * Destruction restores the previous resource, including during stack unwinding. The object is - * movable: the moved-from object no longer restores on destruction. Because the current resource is - * device-global state, scopes must not overlap concurrent work that changes or uses the current - * resource. + * Destruction restores the previous resource, including during stack unwinding. Because the current + * resource is device-global state, scopes must not overlap concurrent work that changes or uses the + * current resource. */ class scoped_current_device_resource { public: @@ -50,13 +48,11 @@ class scoped_current_device_resource { scoped_current_device_resource(scoped_current_device_resource const&) = delete; scoped_current_device_resource& operator=(scoped_current_device_resource const&) = delete; - scoped_current_device_resource(scoped_current_device_resource&&) noexcept; - scoped_current_device_resource& operator=(scoped_current_device_resource&&) noexcept; + scoped_current_device_resource(scoped_current_device_resource&&) = delete; + scoped_current_device_resource& operator=(scoped_current_device_resource&&) = delete; private: - void restore() noexcept; - - std::optional> _previous; + cuda::mr::any_resource _previous; }; /** @brief Expected relationship between live and total output-resource allocations. */ diff --git a/cpp/tests/utilities/memory_resource_utilities.cpp b/cpp/tests/utilities/memory_resource_utilities.cpp index 010afc351595..117758d670d3 100644 --- a/cpp/tests/utilities/memory_resource_utilities.cpp +++ b/cpp/tests/utilities/memory_resource_utilities.cpp @@ -22,30 +22,9 @@ scoped_current_device_resource::scoped_current_device_resource( { } -scoped_current_device_resource::scoped_current_device_resource( - scoped_current_device_resource&& other) noexcept - : _previous{std::exchange(other._previous, std::nullopt)} -{ -} - -scoped_current_device_resource& scoped_current_device_resource::operator=( - scoped_current_device_resource&& other) noexcept -{ - if (this != &other) { - restore(); - _previous = std::exchange(other._previous, std::nullopt); - } - return *this; -} - -scoped_current_device_resource::~scoped_current_device_resource() { restore(); } - -void scoped_current_device_resource::restore() noexcept +scoped_current_device_resource::~scoped_current_device_resource() { - if (_previous.has_value()) { - std::ignore = cudf::set_current_device_resource(std::move(*_previous)); - _previous.reset(); - } + std::ignore = cudf::set_current_device_resource(std::move(_previous)); } memory_resource_test_harness::memory_resource_test_harness(rmm::device_async_resource_ref upstream) diff --git a/cpp/tests/utilities_tests/column_wrapper_tests.cpp b/cpp/tests/utilities_tests/column_wrapper_tests.cpp index fb779516d994..dfc5638e2653 100644 --- a/cpp/tests/utilities_tests/column_wrapper_tests.cpp +++ b/cpp/tests/utilities_tests/column_wrapper_tests.cpp @@ -410,8 +410,8 @@ TYPED_TEST(FixedWidthColumnWrapperTest, NullablePairListConstructorAllNullMatch) this->resources()); cudf::column_view view = col; - // TODO: Remove once equality row preprocessing uses the supplied memory resources. - this->enable_current_device_resource_use(); + // TODO: Check the harness with a failing current resource once equality row preprocessing uses + // the supplied memory resources. CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, @@ -517,8 +517,8 @@ TYPED_TEST(StringsColumnWrapperTest, NullablePairListConstructorAllNullMatch) this->resources()); cudf::column_view view = col; - // TODO: Remove once equality row preprocessing uses the supplied memory resources. - this->enable_current_device_resource_use(); + // TODO: Check the harness with a failing current resource once equality row preprocessing uses + // the supplied memory resources. CUDF_TEST_EXPECT_COLUMNS_EQUAL(view, match_view, cudf::test::debug_output_level::FIRST_ERROR, From 47c4eb4899afdd4544e66e68239d7089c53fab90 Mon Sep 17 00:00:00 2001 From: niranda perera Date: Fri, 14 Aug 2026 07:34:42 -0700 Subject: [PATCH 17/17] trigger build