Skip to content

Radix sort policy name improvements - #9489

Merged
bernhardmgruber merged 9 commits into
NVIDIA:mainfrom
bernhardmgruber:radix_policy_renames
Jun 17, 2026
Merged

bernhardmgruber merged 9 commits into
NVIDIA:mainfrom
bernhardmgruber:radix_policy_renames

Conversation

@bernhardmgruber

@bernhardmgruber bernhardmgruber commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

Here are a few improvements to the radix sort tuning policies:

  • Rename num_parts in radix histogram policy to num_private_partitions
  • Rename rank_num_parts in radix onesweep policy to ranknum_private_partitions
  • Put radix_bits last in all affected policies
  • Reorder members in radix_sort_onesweep_policy for consistency with other tuning policies
  • Drop onesweep_radix_bits from radix_sort_policy. It seems this was added by accident and it's unused.
  • Turn bool use_onesweep into an algorithm enumeration
  • No SASS changes for cub.bench.radix_sort.pairs.base for SM80;90;100

@bernhardmgruber
bernhardmgruber requested review from a team as code owners June 16, 2026 10:41
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 16, 2026
@bernhardmgruber bernhardmgruber changed the title Radix sort policy renames Radix sort policy name improvements Jun 16, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note: CodeRabbit is enabled on this repository as a convenience for maintainers
and contributors. Use your best judgment when considering its review comments and
suggestions — a suggested change may be inadequate, unnecessary, or safe to ignore.
Contributors are not expected to address every comment. Human reviews are what
ultimately matter for merging.

Summary

This PR refactors the CCCL library's radix sort tuning policies to improve naming consistency, standardize member ordering, and remove obsolete configuration options. The changes introduce an algorithm enumeration to replace a boolean flag and rename partition-related members across multiple policy structures.

Key Changes

Policy Structure Updates

Naming improvements:

  • Renamed num_parts → num_private_partitions in radix_sort_histogram_policy to clarify its purpose as a shared memory partitioning parameter
  • Renamed rank_num_parts → rank_num_private_partitions in radix_sort_onesweep_policy for consistency

Algorithm selection refactor:

  • Introduced enum class RadixSortAlgorithm with values multi_pass and onesweep
  • Converted bool use_onesweep field in radix_sort_policy to RadixSortAlgorithm algorithm
  • Removed obsolete onesweep_radix_bits member from radix_sort_policy (no longer needed with the new enum approach)

Member reordering:

  • Repositioned radix_bits as the last member in radix_sort_histogram_policy, radix_sort_onesweep_policy, and radix_sort_downsweep_policy for consistent member ordering across all radix sort policies
  • Reordered members in radix_sort_onesweep_policy to align with the structure of other tuning policies (threads, items, algorithms, partitions, then bits)

Dispatch and Kernel Updates

Policy selection (dispatch_radix_sort.cuh):

  • Updated algorithm selection logic to check policy.algorithm == RadixSortAlgorithm::onesweep instead of use_onesweep flag
  • Maintained consistency across GCC version branches

Kernel wiring (kernel_radix_sort.cuh):

  • Updated DeviceRadixSortHistogramKernel to pass policy.num_private_partitions to AgentRadixSortHistogramPolicy
  • Updated DeviceRadixSortOnesweepKernel to pass policy.rank_num_private_partitions and policy.rank_algorithm to AgentRadixSortOnesweepPolicy

Benchmark and Policy Selection Updates

Policy selector (policy_selector.h):

  • Changed histogram and onesweep policy construction to use TUNE_RADIX_BITS instead of ONESWEEP_RADIX_BITS
  • Updated returned radix_sort_policy to explicitly set algorithm field to RadixSortAlgorithm::onesweep
  • Adjusted shared-memory size helpers to use renamed members (num_private_partitions, rank_num_private_partitions)
  • Updated compile-time assertion from checking active_policy.use_onesweep to checking active_policy.algorithm == RadixSortAlgorithm::onesweep

Segmented radix sort tuning (tuning_segmented_radix_sort.cuh):

  • Reordered arguments to make_reg_scaled_radix_sort_downsweep_policy to move radix_bits to the final position

Test updates (catch2_test_device_radix_sort_env.cu):

  • Updated tiny_onesweep_policy_selector to use new enum-based algorithm selection
  • Modified histogram configuration to use num_private_partitions instead of num_parts

Impact

  • No changes to public API or function signatures — these are internal tuning policy structures
  • Improved code clarity through more descriptive naming
  • Standardized member ordering across policy structures for better maintainability
  • Eliminated redundant configuration options by using the algorithm enumeration as the single source of truth

Walkthrough

Replaces the use_onesweep boolean and onesweep_radix_bits field in radix_sort_policy with a RadixSortAlgorithm enum (onesweep/multi_pass). Renames num_parts, rank_num_parts, and the misspelled rank_algorith to num_private_partitions, rank_num_private_partitions, and rank_algorithm. Reorders make_reg_scaled_radix_sort_*_policy helper parameters and propagates all changes through every per-SM tuning branch, segmented sort tuning, dispatch, kernel wiring, benchmarks, and test fixtures.

Changes

Radix Sort Policy Struct Refactor

Layer / File(s) Summary
Policy struct definitions and RadixSortAlgorithm enum
cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
Adds enum class RadixSortAlgorithm; refactors radix_sort_histogram_policy (num_parts → num_private_partitions), radix_sort_onesweep_policy (adds store_algorithm, rank_algorithm, scan_algorithm, rank_num_private_partitions), radix_sort_downsweep_policy (moves radix_bits after scan_algorithm), and radix_sort_policy (replaces use_onesweep/onesweep_radix_bits with algorithm); all operator== and operator<< updated to match.
make_reg_scaled_radix_sort_*_policy helpers and per-SM branches
cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
Updates parameter ordering for make_reg_scaled_radix_sort_onesweep_policy, make_reg_scaled_radix_sort_downsweep_policy, and make_reg_scaled_radix_sort_upsweep_policy; propagates new signatures into all policy_selector compute-capability branches (SM50–SM100), replacing use_onesweep boolean with RadixSortAlgorithm enum in each branch's radix_sort_policy construction.
Segmented sort downsweep call-site argument reordering
cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh
Reorders make_reg_scaled_radix_sort_downsweep_policy call arguments for every compute-capability branch (SM50–SM100) to pass segmented_radix_bits last, matching the updated helper signature.
Kernel and dispatch wiring
cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh, cub/cub/device/dispatch/dispatch_radix_sort.cuh
DeviceRadixSortHistogramKernel uses policy.num_private_partitions; DeviceRadixSortOnesweepKernel uses policy.rank_num_private_partitions and policy.rank_algorithm with hardcoded 0, 0, void placeholders; DispatchRadixSort::__invoke checks algorithm == RadixSortAlgorithm::onesweep in the GCC < 10 preprocessor branch.
Benchmark selector and test fixture
cub/benchmarks/bench/radix_sort/policy_selector.h, cub/test/catch2_test_device_radix_sort_env.cu
Benchmark policy selector switches from ONESWEEP_RADIX_BITS to TUNE_RADIX_BITS, uses renamed partition fields, and sets algorithm = RadixSortAlgorithm::onesweep; test tiny_onesweep_policy_selector sets histogram.num_private_partitions = 1 instead of num_parts/use_onesweep.

Suggested reviewers

  • oleksandr-pavlyk
  • gonidelis
  • pauleonix

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

@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/benchmarks/bench/radix_sort/policy_selector.h (1)

30-30: suggestion: __scale_num_parts lacks documentation despite being used in benchmark policy tuning. While the function has _CCCL_HOST_DEVICE_API attributes suggesting formal exposure, the double-underscore prefix and absence of comments create ambiguity about stability. Add a comment explaining the function's role in scaling histogram partitions based on key size, or consider moving it to a public location if it's a stable tuning interface.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 590ad3c6-49ea-4d85-888f-cb207c0fbdb5

📥 Commits

Reviewing files that changed from the base of the PR and between 910bea4 and a7ce2b6.

📒 Files selected for processing (6)
  • cub/benchmarks/bench/radix_sort/policy_selector.h
  • cub/cub/device/dispatch/dispatch_radix_sort.cuh
  • cub/cub/device/dispatch/kernels/kernel_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_radix_sort.cuh
  • cub/cub/device/dispatch/tuning/tuning_segmented_radix_sort.cuh
  • cub/test/catch2_test_device_radix_sort_env.cu

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 41m: Pass: 100%/287 | Total: 6d 12h | Max: 1h 08m | Hits: 43%/479080

See results here.

@bernhardmgruber
bernhardmgruber merged commit 173e7e3 into NVIDIA:main Jun 17, 2026
312 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 17, 2026
@bernhardmgruber
bernhardmgruber deleted the radix_policy_renames branch June 17, 2026 20:14
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.

2 participants