Skip to content

Swap small_segment and medium_segment in SegmentedSortPolicy - #9716

Merged
bernhardmgruber merged 3 commits into
NVIDIA:mainfrom
bernhardmgruber:swap_members
Jul 8, 2026
Merged

bernhardmgruber merged 3 commits into
NVIDIA:mainfrom
bernhardmgruber:swap_members

Conversation

@bernhardmgruber

Copy link
Copy Markdown
Contributor

Improves consistency with other policies

Fixes part of: #9378

Improves consistency with other policies
@bernhardmgruber
bernhardmgruber requested review from a team as code owners July 6, 2026 09:48
@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jul 6, 2026
@bernhardmgruber bernhardmgruber changed the title Swap small_segment and medium_segment in SegmentedSortPolicy Swap small_segment and medium_segment in SegmentedSortPolicy Jul 6, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Review in CCCL Jul 6, 2026
@bernhardmgruber bernhardmgruber mentioned this pull request Jul 6, 2026
17 tasks done
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 683eaab9-60ea-4ba0-9758-b3c884742a1c

📥 Commits

Reviewing files that changed from the base of the PR and between 4e0a6a2 and 78c80fd.

📒 Files selected for processing (1)
  • cub/test/catch2_test_device_segmented_sort_pairs_env.cu

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Standardized the ordering of segmented sort sub-policies returned by the tuning/policy selector across compute-capability ranges.
    • Updated segmented sort policy equality checks and string output to match the new member ordering.
  • Tests
    • Updated segmented sort keys and pairs environment tests to reflect the reordered policy initialization for consistent validation.

Walkthrough

SegmentedSortPolicy now declares medium_segment before small_segment. The tuning selector, dispatch paths, benchmark construction, and tests were updated so initializer order matches the new member layout. Equality and stream output were adjusted accordingly.

Changes

SegmentedSortPolicy member reorder

Layer / File(s) Summary
Struct definition and comparisons
cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh
SegmentedSortPolicy member order changes to medium_segment then small_segment; operator== and operator<< updated to match.
Tuning selector branches
cub/cub/device/dispatch/tuning/tuning_segmented_sort.cuh
All compute-capability branches (8.6, 8.0, 7.0, 6.2, 6.1, 6.0, default) swap medium/small initializer order in returned SegmentedSortPolicy{...}.
Dispatch and benchmark construction
cub/cub/device/dispatch/dispatch_segmented_sort.cuh, cub/benchmarks/bench/segmented_sort/keys.cu
Medium policy initializer now precedes small policy initializer in returned SegmentedSortPolicy.
Test initializers
cub/test/catch2_test_device_segmented_sort_keys_env.cu, cub/test/catch2_test_device_segmented_sort_keys_env_api.cu, cub/test/catch2_test_device_segmented_sort_pairs_env.cu
Aggregate and designated initializers reordered so .medium_segment precedes .small_segment; values unchanged.

Suggested reviewers: fbusato


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

@github-actions

This comment has been minimized.

Match the new member order (medium_segment before small_segment) in
the segmented_sort_tuning test helper.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@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.

♻️ Duplicate comments (1)
cub/test/catch2_test_device_segmented_sort_keys_env.cu (1)

481-488: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

critical: the two SegmentedSortSubWarpMergeSortPolicy blocks (32-thread then 4-thread) are still in their original relative order here, but the struct field order is now medium_segment before small_segment. Since this is positional aggregate init, the 32-thread block now binds to medium_segment and the 4-thread block to small_segment — the opposite of before the struct reorder. Either swap these two blocks to preserve prior semantics, or confirm this reassignment is intentional.

This is the same concern raised in a prior review on this PR ("Critical: these need to be swapped after this change") and appears unresolved.

🐛 Proposed fix
       cub::SegmentedSortSubWarpMergeSortPolicy{
-        BlockThreads, 32, 1, cub::WARP_LOAD_DIRECT, cub::LOAD_DEFAULT, cub::WARP_STORE_DIRECT},
-      cub::SegmentedSortSubWarpMergeSortPolicy{
         BlockThreads, 4, 1, cub::WARP_LOAD_DIRECT, cub::LOAD_DEFAULT, cub::WARP_STORE_DIRECT},
+      cub::SegmentedSortSubWarpMergeSortPolicy{
+        BlockThreads, 32, 1, cub::WARP_LOAD_DIRECT, cub::LOAD_DEFAULT, cub::WARP_STORE_DIRECT},
       1000000};

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3f4bb8fd-e6fa-4b94-9be8-f0e9cf42c5cf

📥 Commits

Reviewing files that changed from the base of the PR and between 366a271 and 4e0a6a2.

📒 Files selected for processing (1)
  • cub/test/catch2_test_device_segmented_sort_keys_env.cu

@github-actions

This comment has been minimized.

@NaderAlAwar NaderAlAwar 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.

Suggestion: the same issue of swapped policies appears at catch2_test_device_segmented_sort_pairs_env.cu:746 if you want to fix it

@bernhardmgruber

Copy link
Copy Markdown
Contributor Author

Suggestion: the same issue of swapped policies appears at catch2_test_device_segmented_sort_pairs_env.cu:746 if you want to fix it

Applied. Thx!

@bernhardmgruber
bernhardmgruber enabled auto-merge (squash) July 8, 2026 07:12
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 4h 33m: Pass: 100%/287 | Total: 12d 00h | Max: 2h 44m | Hits: 10%/1543260

See results here.

@bernhardmgruber
bernhardmgruber merged commit b1b4353 into NVIDIA:main Jul 8, 2026
605 of 610 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jul 8, 2026
@bernhardmgruber
bernhardmgruber deleted the swap_members branch July 8, 2026 11:54
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.

3 participants