Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable_distinct public api now has a stream parameter #16068

Merged
2 changes: 0 additions & 2 deletions cpp/include/cudf/detail/stream_compaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ std::unique_ptr<table> distinct(table_view const& input,

/**
* @copydoc cudf::stable_distinct
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<table> stable_distinct(table_view const& input,
std::vector<size_type> const& keys,
Expand Down
2 changes: 2 additions & 0 deletions cpp/include/cudf/stream_compaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ std::unique_ptr<column> distinct_indices(
* @param keep Copy any, first, last, or none of the found duplicates
* @param nulls_equal Flag to specify whether null elements should be considered as equal
* @param nans_equal Flag to specify whether NaN elements should be considered as equal
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned table
* @return Table with distinct rows, preserving input order
*/
Expand All @@ -329,6 +330,7 @@ std::unique_ptr<table> stable_distinct(
duplicate_keep_option keep = duplicate_keep_option::KEEP_ANY,
null_equality nulls_equal = null_equality::EQUAL,
nan_equality nans_equal = nan_equality::ALL_EQUAL,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
ttnghia marked this conversation as resolved.
Show resolved Hide resolved
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/stream_compaction/stable_distinct.cu
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ std::unique_ptr<table> stable_distinct(table_view const& input,
duplicate_keep_option keep,
null_equality nulls_equal,
nan_equality nans_equal,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
CUDF_FUNC_RANGE();
return detail::stable_distinct(
input, keys, keep, nulls_equal, nans_equal, cudf::get_default_stream(), mr);
return detail::stable_distinct(input, keys, keep, nulls_equal, nans_equal, stream, mr);
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace cudf
37 changes: 24 additions & 13 deletions cpp/tests/stream_compaction/stable_distinct_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ TEST_F(StableDistinctKeepAny, NoNullsTableWithNaNs)
auto const exp_keys2 = floats_col{19., NaN, NaN, NaN, 20., 20., 9., 21.};
auto const expected = cudf::table_view{{exp_col1, exp_col2, exp_keys1, exp_keys2}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -200,7 +201,8 @@ TEST_F(StableDistinctKeepAny, NoNullsTableWithNaNs)
auto const exp_keys2 = floats_col{19., NaN, 20., 20., 9., 21.};
auto const expected = cudf::table_view{{exp_col1, exp_col2, exp_keys1, exp_keys2}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}
}
Expand Down Expand Up @@ -381,7 +383,8 @@ TEST_F(StableDistinctKeepAny, InputWithNullsAndNaNs)
auto const exp_keys = floats_col{{20., null, NaN, NaN, NaN, 19., 21.}, null_at(1)};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -391,7 +394,8 @@ TEST_F(StableDistinctKeepAny, InputWithNullsAndNaNs)
auto const exp_keys = floats_col{{20., null, NaN, 19., 21.}, null_at(1)};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_EQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -401,7 +405,8 @@ TEST_F(StableDistinctKeepAny, InputWithNullsAndNaNs)
auto const exp_keys = floats_col{{20., null, null, NaN, NaN, NaN, 19., 21.}, nulls_at({1, 2})};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_UNEQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_UNEQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -411,7 +416,8 @@ TEST_F(StableDistinctKeepAny, InputWithNullsAndNaNs)
auto const exp_keys = floats_col{{20., null, null, NaN, 19., 21.}, nulls_at({1, 2})};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_ANY, NULL_UNEQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_ANY, NULL_UNEQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}
}
Expand Down Expand Up @@ -508,7 +514,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsEqual)
auto const exp_keys = floats_col{20., NaN, 19., 21., 22.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_FIRST, NULL_EQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_FIRST, NULL_EQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -518,7 +525,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsEqual)
auto const exp_keys = floats_col{20., NaN, 21., 19., 22.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_LAST, NULL_EQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_LAST, NULL_EQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -528,7 +536,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsEqual)
auto const exp_keys = floats_col{20., 21., 22.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_NONE, NULL_EQUAL, NAN_EQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_NONE, NULL_EQUAL, NAN_EQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}
}
Expand All @@ -547,8 +556,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsUnequal)
auto const exp_keys = floats_col{20., NaN, NaN, 19., 21., 22.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result =
cudf::stable_distinct(input, key_idx, KEEP_FIRST, NULL_UNEQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_FIRST, NULL_UNEQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -558,7 +567,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsUnequal)
auto const exp_keys = floats_col{NaN, NaN, 21., 19., 22., 20.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_LAST, NULL_UNEQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_LAST, NULL_UNEQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}

Expand All @@ -568,7 +578,8 @@ TEST_F(StableDistinctKeepFirstLastNone, InputWithNaNsUnequal)
auto const exp_keys = floats_col{NaN, NaN, 21., 22.};
auto const expected = cudf::table_view{{exp_col, exp_keys}};

auto const result = cudf::stable_distinct(input, key_idx, KEEP_NONE, NULL_UNEQUAL, NAN_UNEQUAL);
auto const result = cudf::stable_distinct(
input, key_idx, KEEP_NONE, NULL_UNEQUAL, NAN_UNEQUAL, cudf::test::get_default_stream());
CUDF_TEST_EXPECT_TABLES_EQUAL(expected, *result);
}
}
Expand Down
Loading