Skip to content

[CUB] Refactor DeviceAdjacentDifference::SubtractRight to always take an environment - #9419

Merged
miscco merged 1 commit into
mainfrom
device_adjacent_difference_subtract_right_env
Jun 24, 2026
Merged

miscco merged 1 commit into
mainfrom
device_adjacent_difference_subtract_right_env

Conversation

@miscco

@miscco miscco commented Jun 12, 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 12, 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.

@github-project-automation github-project-automation Bot moved this to Todo in CCCL Jun 12, 2026
@cccl-authenticator-app cccl-authenticator-app Bot moved this from Todo to In Progress in CCCL Jun 12, 2026
@miscco
miscco marked this pull request as ready for review June 12, 2026 11:03
@miscco
miscco requested a review from a team as a code owner June 12, 2026 11:03
@miscco
miscco requested a review from elstehle June 12, 2026 11:03
@cccl-authenticator-app cccl-authenticator-app Bot moved this from In Progress to In Review in CCCL Jun 12, 2026
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 18e8403 to 8cfab18 Compare June 12, 2026 11:21
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 8cfab18 to c000627 Compare June 12, 2026 11:21
@copy-pr-bot

copy-pr-bot Bot commented Jun 12, 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.


c2h::host_vector<type> h_in = in;
c2h::host_vector<type> reference(num_items);
std::adjacent_difference(h_in.begin(), h_in.end(), reference.begin(), ref_diff<type>{});

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.

std::????

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.

The use of cuda::std:: would be generally encouraged. There was a time, where we didn't have our own STL implementation, so we used the host stdlib to compare with.

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 really do not want to change the tests at all

I basically copy and paste the existing tests and if there are changed to be made those should be made consistently in a follow up

Comment on lines +112 to +114
auto error = cub::DeviceAdjacentDifference::SubtractRight(
static_cast<void*>(nullptr), expected_allocation_size, in.begin(), num_items, cuda::std::minus<>{});
REQUIRE(error == cudaSuccess);

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.

REQUIRE_CUB()?

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.

Not a fan, this is move expressive

Comment on lines +115 to +116
REQUIRE(cudaSuccess == cudaPeekAtLastError());
REQUIRE(cudaSuccess == cudaDeviceSynchronize());

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.

REQUIRE_CUDART()

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from c000627 to 9ade375 Compare June 12, 2026 12:03
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 9ade375 to 0dcfcac Compare June 12, 2026 12:04
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 0dcfcac to 657a73c Compare June 12, 2026 15:30
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 657a73c to 187b964 Compare June 15, 2026 06:56
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 187b964 to 72b06a4 Compare June 15, 2026 12:51
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 72b06a4 to 1150ed2 Compare June 15, 2026 12:51
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 03e9cb8 to 636dfb3 Compare June 17, 2026 10:53
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 636dfb3 to 8a97bee Compare June 17, 2026 10:53
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 8a97bee to 4ac6311 Compare June 22, 2026 09:50
@github-actions

This comment has been minimized.

@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 4ac6311 to 126a60c Compare June 23, 2026 07:11
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch 2 times, most recently from 5485479 to 6b55427 Compare June 23, 2026 09:48
@github-actions

This comment has been minimized.

Base automatically changed from device_adjacent_difference_subtract_left_env to main June 24, 2026 07:45
…ke an environment

We want to be able to pass tunings to the APIs that take user provided memory.
@miscco
miscco force-pushed the device_adjacent_difference_subtract_right_env branch from 6b55427 to 613ffed Compare June 24, 2026 07:45
@coderabbitai

coderabbitai Bot commented Jun 24, 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

  • Refactored DeviceAdjacentDifference::SubtractRight and SubtractRightCopy to always accept an environment parameter for dispatch.
  • Switched the right-variant implementations from stream-based overloads to env-based dispatch wiring, enabling tunings to flow through user-provided-memory APIs.
  • Tightened template constraints for the convenience overloads to use iterator-based invocability checks.
  • Updated documentation comments and removed an unused integral type-traits include.
  • Added device tests covering user-provided memory with multiple execution environments for both SubtractRight and SubtractRightCopy.

Walkthrough

SubtractRight and SubtractRightCopy in DeviceAdjacentDifference are migrated from cudaStream_t-based dispatch to EnvT environment-based dispatch via dispatch_with_env_and_tuning. SFINAE constraints on convenience overloads switch from integral predicates to __indirectly_binary_invocable. Tests are added for correctness across multiple environment types.

Changes

DeviceAdjacentDifference right-variant env dispatch migration

Layer / File(s) Summary
Explicit-temp overloads: cudaStream_t → EnvT
cub/cub/device/device_adjacent_difference.cuh
Adds EnvT template parameter to SubtractRightCopy and SubtractRight d_temp_storage overloads, removes cudaStream_t stream, routes through dispatch_with_env_and_tuning with policy-selector lambda. Updates Doxygen. Removes is_integral.h include.
Convenience-overload SFINAE and lambda fixes
cub/cub/device/device_adjacent_difference.cuh
Replaces is_integral_v<NumItemsT>-based enable_if with __indirectly_binary_invocable<DifferenceOpT, IteratorT, IteratorT> on both convenience overloads; tightens env to const EnvT&; adjusts dispatch lambda arguments for SubtractRight.
Multi-environment tests
cub/test/catch2_test_device_adjacent_difference_substract_right.cu
Adds cuda/devices and cuda/std/execution includes. Inserts TEST_LAUNCH == 0 tests for SubtractRight and SubtractRightCopy that query temp-storage size, allocate, then validate output and allocation size across cudaStream_t, cuda::stream, cuda::stream_ref, cuda::std::execution::env, and cuda::execution::gpu policy variants.

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.

🧹 Nitpick comments (1)
cub/test/catch2_test_device_adjacent_difference_substract_right.cu (1)

172-182: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

suggestion: Add one explicit custom-tuning/policy-selector environment case for these user-provided-memory overloads. The current sections cover stream-shaped environments, but they do not prove that dispatch_with_env_and_tuning actually forwards a tuning from EnvT, which is the PR’s stated behavior change. As per path instructions, focus on dispatch/policy selection and test coverage.

Also applies to: 283-293

Source: Path instructions


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8f144539-eb7e-4dd8-9754-5470a542d42e

📥 Commits

Reviewing files that changed from the base of the PR and between 8a23394 and 613ffed.

📒 Files selected for processing (2)
  • cub/cub/device/device_adjacent_difference.cuh
  • cub/test/catch2_test_device_adjacent_difference_substract_right.cu

@miscco

miscco commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@copy-pr-bot

copy-pr-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

/ok to test

@miscco, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

@miscco

miscco commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 613ffed

@github-actions

Copy link
Copy Markdown
Contributor

🥳 CI Workflow Results

🟩 Finished in 1h 25m: Pass: 100%/287 | Total: 3d 16h | Max: 58m 34s | Hits: 64%/332942

See results here.

@miscco
miscco merged commit f871292 into main Jun 24, 2026
306 checks passed
@miscco
miscco deleted the device_adjacent_difference_subtract_right_env branch June 24, 2026 13:31
@github-project-automation github-project-automation Bot moved this from In Review to Done in CCCL Jun 24, 2026
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