Skip to content

[CUB] Refactor DevicePartition::Flagged to always take an environment - #9463

Merged
bernhardmgruber merged 2 commits into
mainfrom
device_partition_flagged
Jul 15, 2026
Merged

bernhardmgruber merged 2 commits into
mainfrom
device_partition_flagged

Conversation

@miscco

@miscco miscco commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

closes

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented Jun 15, 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 Jun 15, 2026
@miscco
miscco force-pushed the device_partition_flagged branch from 724ef30 to 04194e2 Compare June 15, 2026 09:51
@miscco
miscco force-pushed the device_partition_flagged branch 2 times, most recently from 558503f to 003860d Compare June 16, 2026 10:49
@miscco
miscco force-pushed the device_partition_flagged branch from 003860d to 214516b Compare June 22, 2026 10:17
@copy-pr-bot

copy-pr-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@miscco
miscco marked this pull request as ready for review June 22, 2026 10:18
@miscco
miscco requested review from a team as code owners June 22, 2026 10:18
@miscco
miscco requested review from griwes and srinivasyadav18 June 22, 2026 10:18
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jun 22, 2026
@miscco
miscco force-pushed the device_partition_flagged branch 2 times, most recently from ef6e110 to 5fc7e96 Compare June 22, 2026 11:20
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_partition_flagged branch from 5fc7e96 to 7252c69 Compare June 23, 2026 07:21
@miscco
miscco force-pushed the device_partition_flagged branch from 7252c69 to 45c5b58 Compare June 23, 2026 08:46
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_partition_flagged branch from 45c5b58 to e2fea4c Compare June 25, 2026 08:26
@miscco
miscco force-pushed the device_partition_flagged branch from bac0c41 to 81235e5 Compare July 2, 2026 18:49
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_partition_flagged branch from 81235e5 to e1b621b Compare July 3, 2026 07:22
@github-actions

This comment has been minimized.

@bernhardmgruber
bernhardmgruber requested a review from a team as a code owner July 9, 2026 12:21
Base automatically changed from device_select_unique_by_key to main July 15, 2026 17:08
We want to be able to pass tunings to the APIs that take user provided memory

Make sure we can pass any environment or stream type to them
@bernhardmgruber
bernhardmgruber force-pushed the device_partition_flagged branch from e1b621b to 277942e Compare July 15, 2026 17:10
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added execution-environment overload support for device partitioning (including compatibility with different execution policy styles).
  • Bug Fixes

    • Improved integration of device partitioning with rotate and rotate_copy by consistently using execution policies during temporary-storage sizing and kernel launches.
    • Fixed/adjusted temporary-storage pointer usage during these operations.
  • Tests

    • Expanded device partitioning Flagged test coverage to validate user-provided temporary storage across multiple execution environment forms.

Walkthrough

Changes

DevicePartition::Flagged now accepts execution environments and performs environment-aware tuned dispatch. rotate and rotate_copy pass execution policies to Flagged, while tests cover temporary storage and multiple environment forms.

Partition environment dispatch

Layer / File(s) Summary
Flagged environment API and dispatch
cub/cub/device/device_partition.cuh
Flagged adds EnvT, dispatches through the environment and tuning path, and accepts the environment by const reference.
PSTL partition call integration
libcudacxx/include/cuda/std/__pstl/cuda/rotate.h, libcudacxx/include/cuda/std/__pstl/cuda/rotate_copy.h
PSTL calls pass __policy to DevicePartition::Flagged; rotate also passes a raw temporary-storage pointer.
Environment overload coverage
cub/test/catch2_test_device_partition_flagged.cu
Tests query temporary-storage requirements, execute Flagged with multiple environment forms, and verify the resulting count and partitioned output.

Suggested reviewers: griwes, gevtushenko, srinivasyadav18


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

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
cub/cub/device/device_partition.cuh (1)

340-340: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

suggestion: good change to avoid a copy of env. For consistency, the sibling If env overloads (two-way at Line 604, three-way at Line 989) still take EnvT env = {} by value — worth aligning them the same way in a follow-up if EnvT types aren't guaranteed trivial.

cub/test/catch2_test_device_partition_flagged.cu (1)

268-305: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

suggestion: none of these sections pass a custom PartitionPolicy selector through env for this overload — only stream/default-policy variants are covered. Given the dispatch-path concern flagged in device_partition.cuh (Flagged's temp-storage overload possibly mishandling custom PartitionPolicy tunings), adding a section that supplies a custom policy selector (mirroring the pattern in catch2_test_device_partition_env_api.cu) would close this coverage gap and catch that class of regression.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1501ead6-4c92-4c22-a6a0-8c7fee5b73bc

📥 Commits

Reviewing files that changed from the base of the PR and between 3c6a002 and 277942e.

📒 Files selected for processing (4)
  • cub/cub/device/device_partition.cuh
  • cub/test/catch2_test_device_partition_flagged.cu
  • libcudacxx/include/cuda/std/__pstl/cuda/rotate.h
  • libcudacxx/include/cuda/std/__pstl/cuda/rotate_copy.h

Comment thread cub/cub/device/device_partition.cuh Resolved

@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/device_partition.cuh (1)

340-379: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: lines 360-378 duplicate the dispatch/policy-selection body of lines 239-260 almost verbatim (same default_policy_selector, policy_selector_t, and __policy_selector_adapter wiring), differing only in the outer dispatch_with_env call shape. Given the earlier critical bug stemmed from exactly this kind of overload divergence (one path skipping the adapter), extracting a shared private helper that builds the policy-adapted dispatch lambda would remove the duplication and prevent future drift between the two overloads.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8aaf1d55-86c8-4327-8caa-b1ef1355db81

📥 Commits

Reviewing files that changed from the base of the PR and between 277942e and 932b4f9.

📒 Files selected for processing (1)
  • cub/cub/device/device_partition.cuh

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 34m: Pass: 100%/345 | Total: 6d 20h | Max: 1h 33m | Hits: 66%/780706

See results here.

@bernhardmgruber
bernhardmgruber merged commit 8ce2dd4 into main Jul 15, 2026
364 checks passed
@bernhardmgruber
bernhardmgruber deleted the device_partition_flagged branch July 15, 2026 20:39
davebayer pushed a commit to davebayer/cccl that referenced this pull request Aug 4, 2026
…nt (NVIDIA#9463)

We want to be able to pass tunings to the APIs that take user provided memory

Make sure we can pass any environment or stream type to them

Co-authored-by: Bernhard Manfred Gruber <[email protected]>
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