Skip to content

Commit 59e2194

Browse files
authored
Move detail::sorted_order decl from sort_column_impl.cuh to sort.hpp (rapidsai#21436)
Moves the `cudf::detail::sorted_order` declaration from internal `sort_column_impl.cuh` to `sort.hpp` several files including the .cuh depend only on the declaration but none of the device code in the .cuh file. Part of rapidsai#21420 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Bradley Dice (https://github.com/bdice) - Yunsong Wang (https://github.com/PointKernel) URL: rapidsai#21436
1 parent 5927fae commit 59e2194

8 files changed

Lines changed: 39 additions & 36 deletions

File tree

cpp/src/sort/segmented_top_k.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include "sort_column_impl.cuh"
6+
#include "sort.hpp"
77

88
#include <cudf/column/column.hpp>
99
#include <cudf/column/column_factories.hpp>

cpp/src/sort/sort.cu

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -17,9 +17,6 @@
1717

1818
#include <rmm/cuda_stream_view.hpp>
1919

20-
#include <thrust/functional.h>
21-
#include <thrust/sort.h>
22-
2320
namespace cudf {
2421
namespace detail {
2522
std::unique_ptr<column> sorted_order(table_view const& input,

cpp/src/sort/sort.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55
#pragma once
66

7+
#include <cudf/column/column_view.hpp>
8+
#include <cudf/sorting.hpp>
9+
#include <cudf/utilities/memory_resource.hpp>
10+
11+
#include <rmm/cuda_stream_view.hpp>
12+
713
namespace cudf {
814
namespace detail {
915

@@ -12,5 +18,26 @@ namespace detail {
1218
*/
1319
enum class sort_method : bool { STABLE, UNSTABLE };
1420

21+
/**
22+
* @brief Sort indices of a single column.
23+
*
24+
* This API offers fast sorting for primitive types. It cannot handle nested types and will not
25+
* consider `NaN` as equivalent to other `NaN`.
26+
*
27+
* @tparam method Whether to use stable sort
28+
* @param input Column to sort. The column data is not modified.
29+
* @param column_order Ascending or descending sort order
30+
* @param null_precedence How null rows are to be ordered
31+
* @param stream CUDA stream used for device memory operations and kernel launches
32+
* @param mr Device memory resource used to allocate the returned column's device memory
33+
* @return Sorted indices for the input column.
34+
*/
35+
template <sort_method method>
36+
std::unique_ptr<column> sorted_order(column_view const& input,
37+
order column_order,
38+
null_order null_precedence,
39+
rmm::cuda_stream_view stream,
40+
rmm::device_async_resource_ref mr);
41+
1542
} // namespace detail
1643
} // namespace cudf

cpp/src/sort/sort_column.cu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include "sort.hpp"
76
#include "sort_column_impl.cuh"
87
#include "sort_radix.hpp"
98

cpp/src/sort/sort_column_impl.cuh

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,6 @@
2222
namespace cudf {
2323
namespace detail {
2424

25-
/**
26-
* @brief Sort indices of a single column.
27-
*
28-
* This API offers fast sorting for primitive types. It cannot handle nested types and will not
29-
* consider `NaN` as equivalent to other `NaN`.
30-
*
31-
* @tparam method Whether to use stable sort
32-
* @param input Column to sort. The column data is not modified.
33-
* @param column_order Ascending or descending sort order
34-
* @param null_precedence How null rows are to be ordered
35-
* @param stream CUDA stream used for device memory operations and kernel launches
36-
* @param mr Device memory resource used to allocate the returned column's device memory
37-
* @return Sorted indices for the input column.
38-
*/
39-
template <sort_method method>
40-
std::unique_ptr<column> sorted_order(column_view const& input,
41-
order column_order,
42-
null_order null_precedence,
43-
rmm::cuda_stream_view stream,
44-
rmm::device_async_resource_ref mr);
45-
4625
/**
4726
* @brief Comparator functor needed for single column sort.
4827
*
@@ -61,16 +40,16 @@ struct simple_comparator {
6140
}
6241
}
6342

64-
auto left_elememt = d_column.type().id() == type_id::DICTIONARY32
43+
auto left_element = d_column.type().id() == type_id::DICTIONARY32
6544
? d_column.child(dictionary_column_view::keys_column_index)
6645
.element<T>(d_column.element<dictionary32>(lhs).value())
6746
: d_column.element<T>(lhs);
68-
auto right_elememt = d_column.type().id() == type_id::DICTIONARY32
47+
auto right_element = d_column.type().id() == type_id::DICTIONARY32
6948
? d_column.child(dictionary_column_view::keys_column_index)
7049
.element<T>(d_column.element<dictionary32>(rhs).value())
7150
: d_column.element<T>(rhs);
7251

73-
return relational_compare(left_elememt, right_elememt) ==
52+
return relational_compare(left_element, right_element) ==
7453
(ascending ? weak_ordering::LESS : weak_ordering::GREATER);
7554
}
7655
column_device_view const d_column;

cpp/src/sort/sort_impl.cuh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
#pragma once
77

88
#include "sort.hpp"
9-
#include "sort_column_impl.cuh"
109

10+
#include <cudf/column/column_device_view.cuh>
1111
#include <cudf/column/column_factories.hpp>
1212
#include <cudf/detail/row_operator/lexicographic.cuh>
1313
#include <cudf/utilities/memory_resource.hpp>
1414

15+
#include <rmm/exec_policy.hpp>
16+
1517
#include <thrust/sequence.h>
1618
#include <thrust/sort.h>
1719

cpp/src/sort/stable_sort_column.cu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include "sort.hpp"
76
#include "sort_column_impl.cuh"
87
#include "sort_radix.hpp"
98

cpp/src/sort/top_k.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
#include "sort_column_impl.cuh"
6+
#include "sort.hpp"
77

88
#include <cudf/column/column.hpp>
99
#include <cudf/column/column_factories.hpp>

0 commit comments

Comments
 (0)