Skip to content

Commit

Permalink
Patch CUB DeviceSegmentedSort and remove workaround (#12234)
Browse files Browse the repository at this point in the history
Fix in CUB DeviceSegmentedSort allows for workaround to removed. The CUB fix is applied as a patch in the libcudf build process.
Reference NVIDIA/cub#594 and #12217

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Elias Stehle (https://github.com/elstehle)
  - Robert Maynard (https://github.com/robertmaynard)

URL: #12234
  • Loading branch information
davidwendt authored Nov 29, 2022
1 parent 3bf6d1d commit 2a5411a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cpp/cmake/thirdparty/patches/cub_segmented_sort_with_bool_key.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh b/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
index ad65f2a3..ad45a21e 100644
--- a/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
+++ b/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
@@ -221,7 +221,8 @@ public:
using UnsignedBitsT = typename Traits<KeyT>::UnsignedBits;
UnsignedBitsT default_key_bits = IS_DESCENDING ? Traits<KeyT>::LOWEST_KEY
: Traits<KeyT>::MAX_KEY;
- KeyT oob_default = reinterpret_cast<KeyT &>(default_key_bits);
+ KeyT oob_default = std::is_same_v<KeyT, bool> ? !IS_DESCENDING
+ : reinterpret_cast<KeyT &>(default_key_bits);

WarpLoadKeysT(storage.load_keys)
.Load(keys_input, keys, segment_size, oob_default);
5 changes: 5 additions & 0 deletions cpp/cmake/thirdparty/patches/thrust_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"file" : "${current_json_dir}/thrust_faster_scan_compile_times.diff",
"issue" : "Improve Thrust scan compile times by reducing the number of kernels generated [https://github.com/rapidsai/cudf/pull/8183]",
"fixed_in" : ""
},
{
"file" : "${current_json_dir}/cub_segmented_sort_with_bool_key.diff",
"issue" : "Fix an error in CUB DeviceSegmentedSort when the keys are bool type [https://github.com/NVIDIA/cub/issues/594]",
"fixed_in" : "2.1"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/sort/segmented_sort.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct column_fast_sort_fn {
static bool is_fast_sort_supported(column_view const& col)
{
return !col.has_nulls() and
((cudf::is_integral(col.type()) && !cudf::is_boolean(col.type())) ||
(cudf::is_integral(col.type()) ||
(cudf::is_fixed_point(col.type()) and (col.type().id() != type_id::DECIMAL128)));
}

Expand Down

0 comments on commit 2a5411a

Please sign in to comment.