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

Reimplement cudf::merge for nested types without using comparators #14250

Merged
merged 22 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b0dc5d3
passing tests
divyegala Oct 4, 2023
3343ddb
use new algorithm only for nested types
divyegala Oct 4, 2023
2426c0b
auto const everything
divyegala Oct 4, 2023
264b112
experimental comparators for non-nested case
divyegala Oct 11, 2023
9d9fe7c
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 16, 2023
61dec01
add device constructor for experimental comparator
divyegala Oct 16, 2023
5329634
fix regression, address initial review
divyegala Oct 16, 2023
66964b6
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 16, 2023
377c9cd
default construction unnecessary
divyegala Oct 16, 2023
29d51c0
add noexcept back
divyegala Oct 16, 2023
c4036e0
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 17, 2023
b62fe89
passing tests, benchmarks, and detail API rework
divyegala Oct 20, 2023
d3a2425
delete accidentally included files
divyegala Oct 20, 2023
b799e5f
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 20, 2023
6bcff40
Update cpp/include/cudf/merge.hpp
divyegala Oct 25, 2023
7774caf
header includes according to dev guide
divyegala Oct 25, 2023
29a8428
address review
divyegala Oct 26, 2023
88eea0b
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 26, 2023
611ace2
Merge branch 'branch-23.12' into merge-new-algo
divyegala Oct 26, 2023
e5a6d5d
no column checks in comparator functor needed
divyegala Oct 26, 2023
d84391e
address review feedback
divyegala Oct 27, 2023
5ca5d42
Merge remote-tracking branch 'upstream/branch-23.12' into merge-new-algo
divyegala Oct 27, 2023
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
1 change: 1 addition & 0 deletions cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ ConfigureNVBench(HASHING_NVBENCH hashing/hash.cpp)
# ##################################################################################################
# * merge benchmark -------------------------------------------------------------------------------
ConfigureBench(MERGE_BENCH merge/merge.cpp)
ConfigureNVBench(MERGE_NVBENCH merge/merge_structs.cpp merge/merge_lists.cpp)

# ##################################################################################################
# * null_mask benchmark ---------------------------------------------------------------------------
Expand Down
54 changes: 54 additions & 0 deletions cpp/benchmarks/merge/merge_lists.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <benchmarks/common/generate_nested_types.hpp>

#include <cudf/detail/merge.hpp>
#include <cudf/detail/sorting.hpp>

#include <nvbench/nvbench.cuh>

void nvbench_merge_list(nvbench::state& state)
{
rmm::cuda_stream_view stream;

auto const input1 = create_lists_data(state);
auto const sorted_input1 =
cudf::detail::sort(*input1, {}, {}, stream, rmm::mr::get_current_device_resource());

auto const input2 = create_lists_data(state);
auto const sorted_input2 =
cudf::detail::sort(*input2, {}, {}, stream, rmm::mr::get_current_device_resource());

stream.synchronize();

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
rmm::cuda_stream_view stream_view{launch.get_stream()};

cudf::detail::merge({*sorted_input1, *sorted_input2},
{0},
{cudf::order::ASCENDING},
{},
stream_view,
rmm::mr::get_current_device_resource());
});
}

NVBENCH_BENCH(nvbench_merge_list)
.set_name("merge_lists")
.add_int64_power_of_two_axis("size_bytes", {10, 18, 24, 28})
.add_int64_axis("depth", {1, 4})
.add_float64_axis("null_frequency", {0, 0.2});
54 changes: 54 additions & 0 deletions cpp/benchmarks/merge/merge_structs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <benchmarks/common/generate_nested_types.hpp>

#include <cudf/detail/merge.hpp>
#include <cudf/detail/sorting.hpp>

#include <nvbench/nvbench.cuh>

void nvbench_merge_struct(nvbench::state& state)
{
rmm::cuda_stream_view stream;

auto const input1 = create_structs_data(state);
auto const sorted_input1 =
cudf::detail::sort(*input1, {}, {}, stream, rmm::mr::get_current_device_resource());

auto const input2 = create_structs_data(state);
auto const sorted_input2 =
cudf::detail::sort(*input2, {}, {}, stream, rmm::mr::get_current_device_resource());

stream.synchronize();

state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) {
rmm::cuda_stream_view stream_view{launch.get_stream()};

cudf::detail::merge({*sorted_input1, *sorted_input2},
{0},
{cudf::order::ASCENDING},
{},
stream_view,
rmm::mr::get_current_device_resource());
});
}

NVBENCH_BENCH(nvbench_merge_struct)
.set_name("merge_struct")
.add_int64_power_of_two_axis("NumRows", {10, 18, 26})
.add_int64_axis("Depth", {0, 1, 8})
.add_int64_axis("Nulls", {0, 1});
2 changes: 1 addition & 1 deletion cpp/benchmarks/sort/rank_lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include "nested_types_common.hpp"
#include "rank_types_common.hpp"
#include <benchmarks/common/generate_nested_types.hpp>
bdice marked this conversation as resolved.
Show resolved Hide resolved

#include <cudf/sorting.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/sort/rank_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include "nested_types_common.hpp"
#include "rank_types_common.hpp"
#include <benchmarks/common/generate_nested_types.hpp>
divyegala marked this conversation as resolved.
Show resolved Hide resolved

#include <cudf/sorting.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/sort/sort_lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "nested_types_common.hpp"
#include <benchmarks/common/generate_nested_types.hpp>

#include <cudf/detail/sorting.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/sort/sort_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "nested_types_common.hpp"
#include <benchmarks/common/generate_nested_types.hpp>

#include <cudf/detail/sorting.hpp>

Expand Down
166 changes: 0 additions & 166 deletions cpp/include/cudf/detail/merge.cuh

This file was deleted.

60 changes: 60 additions & 0 deletions cpp/include/cudf/detail/merge.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2018-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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include <rmm/device_uvector.hpp>

#include <thrust/pair.h>

namespace cudf {
namespace detail {

/**
* @brief Source table identifier to copy data from.
*/
enum class side : bool { LEFT, RIGHT };

/**
* @brief Tagged index type: `thrust::get<0>` indicates left/right side,
* `thrust::get<1>` indicates the row index
*/
using index_type = thrust::pair<side, cudf::size_type>;

/**
* @brief Vector of `index_type` values.
*/
using index_vector = rmm::device_uvector<index_type>;

/**
* @copydoc std::unique_ptr<cudf::table> merge(
* std::vector<table_view> const& tables_to_merge,
* std::vector<cudf::size_type> const& key_cols,
* std::vector<cudf::order> const& column_order,
* std::vector<cudf::null_order> const& null_precedence,
* rmm::mr::device_memory_resource* mr)
*
* @param stream CUDA stream used for device memory operations and kernel launches
*/
std::unique_ptr<cudf::table> merge(std::vector<table_view> const& tables_to_merge,
std::vector<cudf::size_type> const& key_cols,
std::vector<cudf::order> const& column_order,
std::vector<cudf::null_order> const& null_precedence,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);

} // namespace detail
} // namespace cudf
4 changes: 2 additions & 2 deletions cpp/include/cudf/dictionary/detail/merge.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
* Copyright (c) 2020-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.
Expand All @@ -16,7 +16,7 @@
#pragma once

#include <cudf/column/column.hpp>
#include <cudf/detail/merge.cuh>
#include <cudf/detail/merge.hpp>
#include <cudf/dictionary/dictionary_column_view.hpp>

#include <rmm/cuda_stream_view.hpp>
Expand Down
Loading