Skip to content

Add env-based cub::DeviceSelect algorithms - #5335

Merged
gonidelis merged 10 commits into
NVIDIA:mainfrom
gonidelis:select_env
Feb 19, 2026
Merged

gonidelis merged 10 commits into
NVIDIA:mainfrom
gonidelis:select_env

Conversation

@gonidelis

@gonidelis gonidelis commented Jul 22, 2025 •

Copy link
Copy Markdown
Member

partially fixes #7552

Adds Select::If and Select::Flagged

cub::DeviceSelect::FlaggedIf() cub::DeviceSelect::Unique() and cub::DeviceSelect::UniqueByKey() to be added in a subsequent PR.

@copy-pr-bot

copy-pr-bot Bot commented Jul 22, 2025

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 22, 2025
@gonidelis
gonidelis marked this pull request as ready for review January 8, 2026 18:57
@gonidelis
gonidelis requested a review from a team as a code owner January 8, 2026 18:57
@gonidelis
gonidelis requested a review from NaderAlAwar January 8, 2026 18:57
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jan 8, 2026
@github-actions

This comment has been minimized.

@gonidelis
gonidelis force-pushed the select_env branch 2 times, most recently from f709708 to 861f0c0 Compare January 12, 2026 11:33
Comment thread cub/cub/device/device_select.cuh Outdated
::cuda::execution::determinism::run_to_run_t>;

// Static assert to reject gpu_to_gpu determinism since it makes no sense for DeviceSelect
static_assert(!::cuda::std::is_same_v<requested_determinism_t, ::cuda::execution::determinism::gpu_to_gpu_t>,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am defaulting deterministic requirements for select-if to only run-to-run. Not sure if gpu-to-gpu would make sense. Please ack @NaderAlAwar @fbusato

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 think you can default it to gpu_to_gpu, as select_op is a unary predicate and doesn't interact with neighbouring elements (will not be dealing with Associativity).
We any how promise to maintain relative ordering previously (mentioned in documentation above https://github.com/gonidelis/cccl/blob/select_env/cub/cub/device/device_select.cuh#L403). But in any case, both new API and old might have side effects if the select_op is used in bad way, such as depending on global state or have some randomness such that results are not-deterministic from the functor itself. But, its totally on user. IMO, In short if select_op is deterministic, API will be deterministic.

@github-actions

This comment has been minimized.

Comment thread cub/cub/device/device_select.cuh Resolved
@github-actions

This comment has been minimized.

Comment thread cub/cub/device/device_select.cuh Resolved
Comment on lines +161 to +162
cudaStream_t custom_stream;
REQUIRE(cudaSuccess == cudaStreamCreate(&custom_stream));

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: can we just use cuda::stream instead of manual stream management?

Comment thread cub/cub/device/device_select.cuh Resolved
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@gonidelis gonidelis linked an issue Jan 14, 2026 that may be closed by this pull request
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread cub/cub/device/device_select.cuh Resolved
Comment thread cub/cub/device/device_select.cuh Outdated
::cuda::execution::determinism::run_to_run_t>;

// Static assert to reject gpu_to_gpu determinism since it makes no sense for DeviceSelect
static_assert(!::cuda::std::is_same_v<requested_determinism_t, ::cuda::execution::determinism::gpu_to_gpu_t>,

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 think you can default it to gpu_to_gpu, as select_op is a unary predicate and doesn't interact with neighbouring elements (will not be dealing with Associativity).
We any how promise to maintain relative ordering previously (mentioned in documentation above https://github.com/gonidelis/cccl/blob/select_env/cub/cub/device/device_select.cuh#L403). But in any case, both new API and old might have side effects if the select_op is used in bad way, such as depending on global state or have some randomness such that results are not-deterministic from the functor itself. But, its totally on user. IMO, In short if select_op is deterministic, API will be deterministic.

Comment thread cub/cub/device/device_select.cuh Resolved
@gonidelis
gonidelis requested a review from miscco January 27, 2026 16:02
@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 3h 51m: Pass: 100%/249 | Total: 9d 20h | Max: 3h 50m | Hits: 54%/153668

See results here.

@gonidelis
gonidelis merged commit 0a7b7b1 into NVIDIA:main Feb 19, 2026
263 of 266 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Feb 19, 2026
@gonidelis gonidelis mentioned this pull request Feb 19, 2026
5 tasks done
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.

Add env-based API for cub::DeviceSelect Add env-based cub::DeviceSelect::Flagged()

4 participants