diff --git a/cpp/benchmarks/lists/set_operations.cpp b/cpp/benchmarks/lists/set_operations.cpp index 5b240923358..6bed33d2570 100644 --- a/cpp/benchmarks/lists/set_operations.cpp +++ b/cpp/benchmarks/lists/set_operations.cpp @@ -54,6 +54,7 @@ void nvbench_set_op(nvbench::state& state, BenchFuncPtr bfunc) cudf::lists_column_view{*rhs}, cudf::null_equality::EQUAL, cudf::nan_equality::ALL_EQUAL, + cudf::get_default_stream(), rmm::mr::get_current_device_resource()); }); } diff --git a/cpp/include/cudf/lists/set_operations.hpp b/cpp/include/cudf/lists/set_operations.hpp index 9d58d0f5b98..6fb8989f0bb 100644 --- a/cpp/include/cudf/lists/set_operations.hpp +++ b/cpp/include/cudf/lists/set_operations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ namespace cudf::lists { * to be `UNEQUAL` which means only non-null elements are checked for overlapping * @param nans_equal Flag to specify whether floating-point NaNs should be considered as equal * @param mr Device memory resource used to allocate the returned object + * @param stream CUDA stream used for device memory operations and kernel launches * @return A column of type BOOL containing the check results */ std::unique_ptr have_overlap( @@ -60,6 +61,7 @@ std::unique_ptr have_overlap( lists_column_view const& rhs, null_equality nulls_equal = null_equality::EQUAL, nan_equality nans_equal = nan_equality::ALL_EQUAL, + rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** @@ -87,6 +89,7 @@ std::unique_ptr have_overlap( * @param rhs The input lists column for the other side * @param nulls_equal Flag to specify whether null elements should be considered as equal * @param nans_equal Flag to specify whether floating-point NaNs 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 object * @return A lists column containing the intersection results */ @@ -95,6 +98,7 @@ std::unique_ptr intersect_distinct( lists_column_view const& rhs, null_equality nulls_equal = null_equality::EQUAL, nan_equality nans_equal = nan_equality::ALL_EQUAL, + rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** @@ -122,6 +126,7 @@ std::unique_ptr intersect_distinct( * @param rhs The input lists column for the other side * @param nulls_equal Flag to specify whether null elements should be considered as equal * @param nans_equal Flag to specify whether floating-point NaNs 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 object * @return A lists column containing the union results */ @@ -130,6 +135,7 @@ std::unique_ptr union_distinct( lists_column_view const& rhs, null_equality nulls_equal = null_equality::EQUAL, nan_equality nans_equal = nan_equality::ALL_EQUAL, + rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** @@ -157,6 +163,7 @@ std::unique_ptr union_distinct( * @param rhs The input lists column of elements to exclude * @param nulls_equal Flag to specify whether null elements should be considered as equal * @param nans_equal Flag to specify whether floating-point NaNs 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 object * @return A lists column containing the difference results */ @@ -165,6 +172,7 @@ std::unique_ptr difference_distinct( lists_column_view const& rhs, null_equality nulls_equal = null_equality::EQUAL, nan_equality nans_equal = nan_equality::ALL_EQUAL, + rmm::cuda_stream_view stream = cudf::get_default_stream(), rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource()); /** @} */ // end of group diff --git a/cpp/src/lists/set_operations.cu b/cpp/src/lists/set_operations.cu index 5687a491363..5647b503cf7 100644 --- a/cpp/src/lists/set_operations.cu +++ b/cpp/src/lists/set_operations.cu @@ -278,42 +278,44 @@ std::unique_ptr have_overlap(lists_column_view const& lhs, lists_column_view const& rhs, null_equality nulls_equal, nan_equality nans_equal, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::have_overlap(lhs, rhs, nulls_equal, nans_equal, cudf::get_default_stream(), mr); + return detail::have_overlap(lhs, rhs, nulls_equal, nans_equal, stream, mr); } std::unique_ptr intersect_distinct(lists_column_view const& lhs, lists_column_view const& rhs, null_equality nulls_equal, nan_equality nans_equal, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::intersect_distinct( - lhs, rhs, nulls_equal, nans_equal, cudf::get_default_stream(), mr); + return detail::intersect_distinct(lhs, rhs, nulls_equal, nans_equal, stream, mr); } std::unique_ptr union_distinct(lists_column_view const& lhs, lists_column_view const& rhs, null_equality nulls_equal, nan_equality nans_equal, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::union_distinct(lhs, rhs, nulls_equal, nans_equal, cudf::get_default_stream(), mr); + return detail::union_distinct(lhs, rhs, nulls_equal, nans_equal, stream, mr); } std::unique_ptr difference_distinct(lists_column_view const& lhs, lists_column_view const& rhs, null_equality nulls_equal, nan_equality nans_equal, + rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr) { CUDF_FUNC_RANGE(); - return detail::difference_distinct( - lhs, rhs, nulls_equal, nans_equal, cudf::get_default_stream(), mr); + return detail::difference_distinct(lhs, rhs, nulls_equal, nans_equal, stream, mr); } } // namespace cudf::lists diff --git a/cpp/tests/streams/lists_test.cpp b/cpp/tests/streams/lists_test.cpp index 82a4cb8aa4a..74e0e8837f7 100644 --- a/cpp/tests/streams/lists_test.cpp +++ b/cpp/tests/streams/lists_test.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -166,3 +167,47 @@ TEST_F(ListTest, Distinct) cudf::nan_equality::ALL_EQUAL, cudf::test::get_default_stream()); } + +TEST_F(ListTest, DifferenceDistinct) +{ + cudf::test::lists_column_wrapper list_col_a{{0, 1}, {2, 3, 7, 8}, {4, 5}}; + cudf::test::lists_column_wrapper list_col_b{{0, 1}, {1, 3, 6, 8}, {5}}; + cudf::lists::difference_distinct(list_col_a, + list_col_b, + cudf::null_equality::EQUAL, + cudf::nan_equality::ALL_EQUAL, + cudf::test::get_default_stream()); +} + +TEST_F(ListTest, IntersectDistinct) +{ + cudf::test::lists_column_wrapper list_col_a{{0, 1}, {2, 3, 7, 8}, {4, 5}}; + cudf::test::lists_column_wrapper list_col_b{{0, 1}, {1, 3, 6, 8}, {5}}; + cudf::lists::intersect_distinct(list_col_a, + list_col_b, + cudf::null_equality::EQUAL, + cudf::nan_equality::ALL_EQUAL, + cudf::test::get_default_stream()); +} + +TEST_F(ListTest, UnionDistinct) +{ + cudf::test::lists_column_wrapper list_col_a{{0, 1}, {2, 3, 7, 8}, {4, 5}}; + cudf::test::lists_column_wrapper list_col_b{{0, 1}, {1, 3, 6, 8}, {5}}; + cudf::lists::union_distinct(list_col_a, + list_col_b, + cudf::null_equality::EQUAL, + cudf::nan_equality::ALL_EQUAL, + cudf::test::get_default_stream()); +} + +TEST_F(ListTest, HaveOverlap) +{ + cudf::test::lists_column_wrapper list_col_a{{0, 1}, {2, 3, 7, 8}, {4, 5}}; + cudf::test::lists_column_wrapper list_col_b{{0, 1}, {1, 3, 6, 8}, {5}}; + cudf::lists::have_overlap(list_col_a, + list_col_b, + cudf::null_equality::EQUAL, + cudf::nan_equality::ALL_EQUAL, + cudf::test::get_default_stream()); +}