Skip to content

Allow public tuning of cub::DeviceSegmentedRadixSort - #9685

Merged
bernhardmgruber merged 4 commits into
NVIDIA:mainfrom
bernhardmgruber:tune_seg_radix
Jul 3, 2026
Merged

bernhardmgruber merged 4 commits into
NVIDIA:mainfrom
bernhardmgruber:tune_seg_radix

Conversation

@bernhardmgruber

Copy link
Copy Markdown
Contributor

Fixes: #8579

@copy-pr-bot

copy-pr-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jul 2, 2026
@bernhardmgruber
bernhardmgruber marked this pull request as ready for review July 2, 2026 09:47
@bernhardmgruber
bernhardmgruber requested a review from a team as a code owner July 2, 2026 09:47
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jul 2, 2026
@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added environment-based tuning for segmented radix sort with a customizable policy selector that controls regular vs alternate passes.
    • Introduced SegmentedRadixSortPolicy for configuring downsweep tuning across compute capabilities.
  • Documentation

    • Expanded DeviceSegmentedRadixSort tuning guidance, including new referenced examples.
  • Bug Fixes

    • Updated segmented radix sort dispatcher and kernel tuning to use SegmentedRadixSortPolicy consistently.
  • Tests

    • Added coverage for policy aggregate/semiregularity and the env-based SortKeys tuning API.
  • Chores

    • Marked the legacy DispatchSegmentedRadixSort entrypoint as deprecated in favor of DeviceSegmentedRadixSort.

Walkthrough

Introduces SegmentedRadixSortPolicy as the public segmented radix sort tuning type, updates dispatch and kernel code to use it, and adds tuning documentation plus compile-time and env-based tests for DeviceSegmentedRadixSort.

Changes

SegmentedRadixSortPolicy tuning API

Layer / File(s) Summary
Policy type and selectors
cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh
Defines SegmentedRadixSortPolicy, keeps the legacy alias, and updates policy selectors to return the new type.
Dispatch and kernel usage
cub/cub/device/dispatch/dispatch_segmented_radix_sort.cuh, cub/cub/device/dispatch/kernels/kernel_segmented_radix_sort.cuh
Threads SegmentedRadixSortPolicy through dispatch, launch configuration, and kernel policy selection, and deprecates DispatchSegmentedRadixSort.
Docs and tuning tests
cub/cub/device/device_segmented_radix_sort.cuh, cub/test/catch2_test_device_segmented_radix_sort_env.cu, cub/test/catch2_test_device_segmented_radix_sort_env_api.cu
Adds tuning docs and examples, updates policy-shape tests, and adds an env-based tuning API test using cuda::execution::tune.

Assessment against linked issues

Objective Addressed Explanation
Productize cub::DeviceSegmentedRadixSort tuning API [#8579] ✅

Suggested reviewers: shwina, NaderAlAwar


Comment @coderabbitai help to get the list of available commands.

Comment on lines +26 to +27
RadixSortDownsweepPolicy segmented; //!< Policy for the primary radix sort pass on each segment
RadixSortDownsweepPolicy alt_segmented; //!< Policy for the alternate radix sort pass on each segment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we give those members different names?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say either upsweep_policy / downsweep_policy or the same with segmented_

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the fun thing, RadixSortDownsweepPolicy segmented is used to parameterize an upsweep, scan and downsweep agent in the kernel.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed them regular_pass and alternate_pass now.

Comment on lines +26 to +27
RadixSortDownsweepPolicy segmented; //!< Policy for the primary radix sort pass on each segment
RadixSortDownsweepPolicy alt_segmented; //!< Policy for the alternate radix sort pass on each segment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say either upsweep_policy / downsweep_policy or the same with segmented_

@github-actions

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh (1)

298-308: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: qualify cuda::compute_capability as ::cuda::compute_capability here for consistency with every other use in this file (lines 76, 103, 130, 157, 184, 213, 240 all use the leading ::).

diff
-  [[nodiscard]] _CCCL_HOST_DEVICE_API constexpr auto operator()(cuda::compute_capability cc) const
+  [[nodiscard]] _CCCL_HOST_DEVICE_API constexpr auto operator()(::cuda::compute_capability cc) const
     -> SegmentedRadixSortPolicy

As per coding guidelines: "apply the required global qualification rules for free-function calls, including ::cuda::... qualification where mandated by the subproject."

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 7a611307-9f25-4798-a455-7141459c0c7d

📥 Commits

Reviewing files that changed from the base of the PR and between 168bf52 and 635cf8e.

📒 Files selected for processing (6)
  • cub/cub/device/device_segmented_radix_sort.cuh
  • cub/cub/device/dispatch/dispatch_segmented_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_segmented_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh
  • cub/test/catch2_test_device_segmented_radix_sort_env.cu
  • cub/test/catch2_test_device_segmented_radix_sort_env_api.cu
✅ Files skipped from review due to trivial changes (1)
  • cub/cub/device/device_segmented_radix_sort.cuh
🚧 Files skipped from review as they are similar to previous changes (4)
  • cub/cub/device/dispatch/kernels/kernel_segmented_radix_sort.cuh
  • cub/test/catch2_test_device_segmented_radix_sort_env.cu
  • cub/test/catch2_test_device_segmented_radix_sort_env_api.cu
  • cub/cub/device/dispatch/dispatch_segmented_radix_sort.cuh

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 2h 15m: Pass: 100%/287 | Total: 7d 21h | Max: 1h 11m | Hits: 39%/523239

See results here.

@bernhardmgruber
bernhardmgruber merged commit b13bfd6 into NVIDIA:main Jul 3, 2026
305 of 306 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jul 3, 2026
@bernhardmgruber
bernhardmgruber deleted the tune_seg_radix branch July 3, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Productize the cub::DeviceSegmentedRadixSort tuning API

2 participants