Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d11a8bb
Port column wrappers to accept memory_resources and stream
nirandaperera Aug 7, 2026
3f518af
fix wrapper tests
nirandaperera Aug 7, 2026
cb35fb0
fix col util tests
nirandaperera Aug 7, 2026
4a02ab8
fix ctrs
nirandaperera Aug 10, 2026
4d2d6b8
Merge branch 'main' of github.com:rapidsai/cudf into test-column-wrap…
nirandaperera Aug 10, 2026
8479c3d
precommit
nirandaperera Aug 10, 2026
20eddfd
remove defaults
nirandaperera Aug 10, 2026
2e4d5a8
code rabbit suggestions
nirandaperera Aug 10, 2026
32b153d
addng failing default mr
nirandaperera Aug 10, 2026
3cab3a6
fix ctr
nirandaperera Aug 10, 2026
b839630
Merge branch 'main' of github.com:rapidsai/cudf into test-column-wrap…
nirandaperera Aug 10, 2026
19857eb
fix test with todo
nirandaperera Aug 11, 2026
877ffc3
Merge branch 'main' of github.com:rapidsai/cudf into test-column-wrap…
nirandaperera Aug 11, 2026
cd3466f
simplify empty ctrs
nirandaperera Aug 11, 2026
e3cc3db
rename util
nirandaperera Aug 12, 2026
40155c3
Apply suggestion from @bdice
nirandaperera Aug 12, 2026
f4293ad
moving base fixture & use concepts
nirandaperera Aug 12, 2026
25e3b24
Merge branch 'test-column-wrappers-mr' of github.com:nirandaperera/cu…
nirandaperera Aug 12, 2026
e701a38
Merge branch 'main' of github.com:NVIDIA/cudf into test-column-wrappe…
nirandaperera Aug 12, 2026
1a5fa38
precommit
nirandaperera Aug 12, 2026
aa0742e
Merge branch 'main' into test-column-wrappers-mr
bdice Aug 13, 2026
58544b7
addressing bdice concerns
nirandaperera Aug 13, 2026
00ef7bd
Merge branch 'test-column-wrappers-mr' of github.com:nirandaperera/cu…
nirandaperera Aug 13, 2026
c7a70e3
Merge branch 'main' into test-column-wrappers-mr
nirandaperera Aug 14, 2026
47c4eb4
trigger build
nirandaperera Aug 14, 2026
128c1c9
Merge branch 'test-column-wrappers-mr' of github.com:nirandaperera/cu…
nirandaperera Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion cpp/include/cudf_test/base_fixture.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
/*
* 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 <cudf_test/cudf_gtest.hpp>
#include <cudf_test/default_stream.hpp>
#include <cudf_test/file_utilities.hpp>
#include <cudf_test/memory_resource_utilities.hpp>

#include <cudf/utilities/export.hpp>
#include <cudf/utilities/memory_resource.hpp>
#include <cudf/utilities/traits.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <rmm/resource_ref.hpp>

#include <cuda/memory_resource>
Expand Down Expand Up @@ -39,6 +42,34 @@ 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. Tests should construct results with `resources()`.
* `TearDown` asserts that no output or temporary allocations remain live.
*/
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(); }

protected:
memory_resource_test_harness _harness{mr()};
};

/**
* @brief Base test fixture that takes a parameter.
*
Expand Down
704 changes: 492 additions & 212 deletions cpp/include/cudf_test/column_wrapper.hpp

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions cpp/include/cudf_test/memory_resource_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#pragma once

#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/cudf_gtest.hpp>
#include <cudf_test/default_stream.hpp>

Expand All @@ -17,6 +18,7 @@
#include <cuda/memory_resource>
#include <cuda/stream_ref>

#include <concepts>
#include <cstddef>
#include <functional>
#include <utility>
Expand Down Expand Up @@ -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 <typename Factory>
concept column_wrapper_statistics_resource_factory =
requires(Factory& factory, rmm::mr::statistics_resource_adaptor& mr) {
{ std::invoke(factory, mr) } -> std::derived_from<detail::column_wrapper>;
};

/**
* @brief Callable that accepts `cudf::memory_resources` and returns a column wrapper.
*/
template <typename Factory>
concept column_wrapper_memory_resources_factory =
requires(Factory& factory, cudf::memory_resources mr) {
{ std::invoke(factory, mr) } -> std::derived_from<detail::column_wrapper>;
};

/**
* @brief Verify that an owning result uses one explicitly supplied output resource.
*
Expand All @@ -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 <typename Factory>
template <column_wrapper_statistics_resource_factory Factory>
void expect_output_uses_resource(
Factory&& factory,
output_allocation_expectation output_expectation = output_allocation_expectation::EXACT,
Expand Down Expand Up @@ -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 <typename Factory>
template <column_wrapper_memory_resources_factory Factory>
void expect_output_uses_distinct_resources(
Factory&& factory,
memory_resource_expectations expectations = {},
Expand Down
16 changes: 11 additions & 5 deletions cpp/include/cudf_test/timestamp_utilities.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <cudf_test/column_wrapper.hpp>
#include <cudf_test/default_stream.hpp>

#include <cudf/detail/iterator.cuh>
#include <cudf/utilities/export.hpp>
Expand All @@ -31,11 +32,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 <typename T, bool nullable = false>
inline cudf::test::fixed_width_column_wrapper<T, int64_t> generate_timestamps(int32_t count,
time_point_ms start,
time_point_ms stop)
inline cudf::test::fixed_width_column_wrapper<T, int64_t> 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;
Expand All @@ -56,10 +62,10 @@ inline cudf::test::fixed_width_column_wrapper<T, int64_t> 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<T, int64_t>(iter, iter + count, mask);
return cudf::test::fixed_width_column_wrapper<T, int64_t>(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<T, int64_t>(iter, iter + count);
return cudf::test::fixed_width_column_wrapper<T, int64_t>(iter, iter + count, stream, mr);
}
}

Expand Down
9 changes: 7 additions & 2 deletions cpp/tests/utilities/column_utilities.cu
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ std::string stringify_column_differences(cudf::device_span<int const> difference
buffer << depth_str << "differences:" << std::endl;

auto source_table = cudf::table_view({lhs, rhs});
auto diff_column =
fixed_width_column_wrapper<int32_t>(h_differences.begin(), h_differences.end());
auto diff_column = fixed_width_column_wrapper<int32_t>(
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,
Expand Down Expand Up @@ -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.
Comment on lines +545 to +546

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like this is included in #23027. Is this a requirement to get to the cudf::label_bins pilot, or is this additional scope? Either way we should make sure it's tracked in the issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its already drafted #23617

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the comparators and preprocessed table changes, to fully make the column utils like
CUDF_TEST_EXPECT_COLUMNS_EQUAL free from current 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);
Expand Down Expand Up @@ -883,6 +885,9 @@ bool expect_columns_equal(cudf::column_view const& lhs,
cuda::stream_ref 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);
Expand Down
Loading
Loading