From 389348a1323b2b9c6a237252a957deec714445bc Mon Sep 17 00:00:00 2001 From: Elias Stehle <3958403+elstehle@users.noreply.github.com> Date: Fri, 24 Jan 2025 09:46:09 +0100 Subject: [PATCH] deprecates policy hubs (#3514) --- cub/cub/device/device_radix_sort.cuh | 28 +++++++++++-------- cub/cub/device/dispatch/dispatch_reduce.cuh | 2 +- .../dispatch/dispatch_streaming_reduce.cuh | 2 +- .../tuning/tuning_adjacent_difference.cuh | 5 ++-- .../dispatch/tuning/tuning_merge_sort.cuh | 3 +- .../dispatch/tuning/tuning_radix_sort.cuh | 4 +-- .../device/dispatch/tuning/tuning_reduce.cuh | 19 +++++++++---- .../device/dispatch/tuning/tuning_scan.cuh | 4 +-- .../dispatch/tuning/tuning_scan_by_key.cuh | 5 ++-- .../dispatch/tuning/tuning_segmented_sort.cuh | 5 ++-- .../dispatch/tuning/tuning_unique_by_key.cuh | 4 +-- 11 files changed, 49 insertions(+), 32 deletions(-) diff --git a/cub/cub/device/device_radix_sort.cuh b/cub/cub/device/device_radix_sort.cuh index 32156b75e34..9a099ee3cb9 100644 --- a/cub/cub/device/device_radix_sort.cuh +++ b/cub/cub/device/device_radix_sort.cuh @@ -151,18 +151,22 @@ private: int end_bit, cudaStream_t stream) { - return DispatchRadixSort, DecomposerT>:: - Dispatch( - d_temp_storage, - temp_storage_bytes, - d_keys, - d_values, - static_cast(num_items), - begin_bit, - end_bit, - is_overwrite_okay, - stream, - decomposer); + return DispatchRadixSort< + IsDescending, + KeyT, + ValueT, + OffsetT, + detail::radix::policy_hub, + DecomposerT>::Dispatch(d_temp_storage, + temp_storage_bytes, + d_keys, + d_values, + static_cast(num_items), + begin_bit, + end_bit, + is_overwrite_okay, + stream, + decomposer); } template diff --git a/cub/cub/device/dispatch/dispatch_reduce.cuh b/cub/cub/device/dispatch/dispatch_reduce.cuh index 8aaa5728d1c..d3e20785e57 100644 --- a/cub/cub/device/dispatch/dispatch_reduce.cuh +++ b/cub/cub/device/dispatch/dispatch_reduce.cuh @@ -590,7 +590,7 @@ struct DispatchReduce template CUB_RUNTIME_FUNCTION _CCCL_FORCEINLINE cudaError_t Invoke(ActivePolicyT active_policy = {}) { - auto wrapped_policy = MakeReducePolicyWrapper(active_policy); + auto wrapped_policy = detail::reduce::MakeReducePolicyWrapper(active_policy); if (num_items <= static_cast( wrapped_policy.SingleTile().BlockThreads() * wrapped_policy.SingleTile().ItemsPerThread())) { diff --git a/cub/cub/device/dispatch/dispatch_streaming_reduce.cuh b/cub/cub/device/dispatch/dispatch_streaming_reduce.cuh index d4af506a6d9..5d6729f67dd 100644 --- a/cub/cub/device/dispatch/dispatch_streaming_reduce.cuh +++ b/cub/cub/device/dispatch/dispatch_streaming_reduce.cuh @@ -189,7 +189,7 @@ template , PerPartitionOffsetT, ReductionOpT>> + detail::reduce::policy_hub, PerPartitionOffsetT, ReductionOpT>> struct dispatch_streaming_arg_reduce_t { // Internal dispatch routine for computing a device-wide argument extremum, like `ArgMin` and `ArgMax` diff --git a/cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh b/cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh index b4bae244371..20717e1c68a 100644 --- a/cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_adjacent_difference.cuh @@ -77,8 +77,9 @@ struct policy_hub } // namespace adjacent_difference } // namespace detail -// TODO(bgruber): deprecate this alias. Users should not access policy_hubs directly. template -using DeviceAdjacentDifferencePolicy = detail::adjacent_difference::policy_hub; +using DeviceAdjacentDifferencePolicy CCCL_DEPRECATED_BECAUSE( + "This class is considered an implementation detail and it " + "will be removed.") = detail::adjacent_difference::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh b/cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh index e2154d5e337..94d54b08509 100644 --- a/cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_merge_sort.cuh @@ -92,6 +92,7 @@ struct policy_hub } // namespace detail template -using DeviceMergeSortPolicy = detail::merge_sort::policy_hub; +using DeviceMergeSortPolicy CCCL_DEPRECATED_BECAUSE("This class is considered an implementation detail and it will be " + "removed.") = detail::merge_sort::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh b/cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh index 4c1c2f53042..99b8dbda413 100644 --- a/cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh @@ -887,7 +887,6 @@ struct policy_hub } // namespace radix } // namespace detail -// TODO(bgruber): deprecate this alias. Users should not access policy_hubs directly. /** * @brief Tuning policy for kernel specialization * @@ -901,6 +900,7 @@ struct policy_hub * Signed integer type for global offsets */ template -using DeviceRadixSortPolicy = detail::radix::policy_hub; +using DeviceRadixSortPolicy CCCL_DEPRECATED_BECAUSE("This class is considered an implementation detail and it will be " + "removed.") = detail::radix::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_reduce.cuh b/cub/cub/device/dispatch/tuning/tuning_reduce.cuh index dc844efef3b..a87b6b9d6d6 100644 --- a/cub/cub/device/dispatch/tuning/tuning_reduce.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_reduce.cuh @@ -141,7 +141,6 @@ struct policy_hub } // namespace reduce } // namespace detail -// TODO(bgruber): deprecate at some point when we have a better API for users to supply tunings /// @tparam AccumT /// Accumulator data type /// @@ -152,10 +151,20 @@ struct policy_hub /// Binary reduction functor type having member /// `auto operator()(const T &a, const U &b)` template -using DeviceReducePolicy = detail::reduce::policy_hub; +using DeviceReducePolicy CCCL_DEPRECATED_BECAUSE( + "This class is considered an implementation detail and it will be " + "removed.") = detail::reduce::policy_hub; -// TODO(bgruber): deprecate those -using detail::reduce::MakeReducePolicyWrapper; -using detail::reduce::ReducePolicyWrapper; +template +using ReducePolicyWrapper CCCL_DEPRECATED_BECAUSE("This class is considered an implementation detail and it will be " + "removed.") = detail::reduce::ReducePolicyWrapper; + +template +CCCL_DEPRECATED_BECAUSE("This function is considered an implementation detail and it will " + "be removed.") +CUB_RUNTIME_FUNCTION detail::reduce::ReducePolicyWrapper MakeReducePolicyWrapper(PolicyT policy) +{ + return detail::reduce::ReducePolicyWrapper{policy}; +} CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_scan.cuh b/cub/cub/device/dispatch/tuning/tuning_scan.cuh index 2163c4b7431..1c76064da1d 100644 --- a/cub/cub/device/dispatch/tuning/tuning_scan.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_scan.cuh @@ -296,8 +296,8 @@ struct policy_hub } // namespace scan } // namespace detail -// TODO(bgruber): deprecate this at some point when we have a better way to allow users to supply tunings template > -using DeviceScanPolicy = detail::scan::policy_hub; +using DeviceScanPolicy CCCL_DEPRECATED_BECAUSE("This class is considered an implementation detail and it will be " + "removed.") = detail::scan::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh b/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh index b3eaa4e513c..cdd2468dc38 100644 --- a/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_scan_by_key.cuh @@ -790,8 +790,9 @@ struct policy_hub } // namespace scan_by_key } // namespace detail -// TODO(bgruber): deprecate this at some point in the future when we have a better API for users to supply policies template > -using DeviceScanByKeyPolicy = detail::scan_by_key::policy_hub; +using DeviceScanByKeyPolicy CCCL_DEPRECATED_BECAUSE( + "This class is considered an implementation detail and it will be " + "removed.") = detail::scan_by_key::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh b/cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh index b1b72637f4b..fc442a4f982 100644 --- a/cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh @@ -272,8 +272,9 @@ struct policy_hub } // namespace segmented_sort } // namespace detail -// TODO(bgruber): Deprecate this at some point when we have a better API for users to provide tunings template -using DeviceSegmentedSortPolicy = detail::segmented_sort::policy_hub; +using DeviceSegmentedSortPolicy CCCL_DEPRECATED_BECAUSE( + "This class is considered an implementation detail and it will " + "be removed.") = detail::segmented_sort::policy_hub; CUB_NAMESPACE_END diff --git a/cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh b/cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh index b1c4c91ea23..f988d6fb29e 100644 --- a/cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh +++ b/cub/cub/device/dispatch/tuning/tuning_unique_by_key.cuh @@ -581,9 +581,9 @@ struct policy_hub } // namespace unique_by_key } // namespace detail -// TODO(bgruber): deprecate at some point when we have an API to pass tuning policies template -using DeviceUniqueByKeyPolicy = +using DeviceUniqueByKeyPolicy CCCL_DEPRECATED_BECAUSE("This class is considered an implementation detail and it will " + "be removed.") = detail::unique_by_key::policy_hub, detail::value_t>; CUB_NAMESPACE_END