Skip to content

Commit

Permalink
Remove static column vectors from window function tests.
Browse files Browse the repository at this point in the history
Fixes rapidsai#18079.

This commit fixes the failures reported in rapidsai#18079, where the use of static
column vector objects in the tests causes the use of a CUDA runtime context
before it's been initialized, causing the tests to fail with:
```
parallel_for failed: cudaErrorInvalidResourceHandle: invalid resource handle
```

Signed-off-by: MithunR <[email protected]>
  • Loading branch information
mythrocks committed Feb 26, 2025
1 parent e365986 commit 0a44371
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions cpp/tests/rolling/offset_row_window_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ auto constexpr null = int32_t{0}; // NULL representation for int32_t;
auto no_nulls_list() { return nulls_at({}); }

struct OffsetRowWindowTest : public cudf::test::BaseFixture {
static ints_column const _keys; // {0, 0, 0, 0, 0, 0, 1, 1, 1, 1};
static ints_column const _values; // {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

struct rolling_runner {
cudf::window_bounds _preceding, _following;
cudf::size_type _min_periods;
bool _grouped = true;
ints_column const _keys; // {0, 0, 0, 0, 0, 0, 1, 1, 1, 1};
ints_column const _values; // {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

rolling_runner(cudf::window_bounds const& preceding,
cudf::window_bounds const& following,
cudf::size_type min_periods_ = 1)
: _preceding{preceding}, _following{following}, _min_periods{min_periods_}
: _preceding{preceding}, _following{following}, _min_periods{min_periods_},
_keys{0, 0, 0, 0, 0, 0, 1, 1, 1, 1},
_values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
{
}

Expand All @@ -80,9 +82,6 @@ struct OffsetRowWindowTest : public cudf::test::BaseFixture {
};
};

ints_column const OffsetRowWindowTest::_keys{0, 0, 0, 0, 0, 0, 1, 1, 1, 1};
ints_column const OffsetRowWindowTest::_values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

auto const AGG_COUNT_NON_NULL =
cudf::make_count_aggregation<cudf::rolling_aggregation>(cudf::null_policy::EXCLUDE);
auto const AGG_COUNT_ALL =
Expand All @@ -96,7 +95,8 @@ TEST_F(OffsetRowWindowTest, OffsetRowWindow_Grouped_3_to_Minus_1)
{
auto const preceding = cudf::window_bounds::get(3);
auto const following = cudf::window_bounds::get(-1);
auto run_rolling = rolling_runner{preceding, following}.min_periods(1).grouped(true);
auto run_rolling = rolling_runner{preceding, following};
run_rolling.min_periods(1).grouped(true);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(*run_rolling(*AGG_COUNT_NON_NULL),
ints_column{{0, 1, 2, 2, 2, 2, 0, 1, 2, 2}, nulls_at({0, 6})});
Expand Down Expand Up @@ -136,7 +136,8 @@ TEST_F(OffsetRowWindowTest, OffsetRowWindow_Ungrouped_3_to_Minus_1)
{
auto const preceding = cudf::window_bounds::get(3);
auto const following = cudf::window_bounds::get(-1);
auto run_rolling = rolling_runner{preceding, following}.min_periods(1).grouped(false);
auto run_rolling = rolling_runner{preceding, following};
run_rolling.min_periods(1).grouped(false);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(*run_rolling(*AGG_COUNT_NON_NULL),
ints_column{{0, 1, 2, 2, 2, 2, 2, 2, 2, 2}, nulls_at({0})});
Expand Down Expand Up @@ -176,7 +177,8 @@ TEST_F(OffsetRowWindowTest, OffsetRowWindow_Grouped_0_to_2)
{
auto const preceding = cudf::window_bounds::get(0);
auto const following = cudf::window_bounds::get(2);
auto run_rolling = rolling_runner{preceding, following}.min_periods(1).grouped(true);
auto run_rolling = rolling_runner{preceding, following};
run_rolling.min_periods(1).grouped(true);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(
*run_rolling(*AGG_COUNT_NON_NULL),
Expand Down Expand Up @@ -219,7 +221,8 @@ TEST_F(OffsetRowWindowTest, OffsetRowWindow_Ungrouped_0_to_2)
{
auto const preceding = cudf::window_bounds::get(0);
auto const following = cudf::window_bounds::get(2);
auto run_rolling = rolling_runner{preceding, following}.min_periods(1).grouped(false);
auto run_rolling = rolling_runner{preceding, following};
run_rolling.min_periods(1).grouped(false);

CUDF_TEST_EXPECT_COLUMNS_EQUAL(*run_rolling(*AGG_COUNT_NON_NULL),
ints_column{{2, 2, 2, 2, 2, 2, 2, 2, 1, null}, nulls_at({9})});
Expand Down

0 comments on commit 0a44371

Please sign in to comment.